Skip to content

Commit

Permalink
Merge branch 'aws:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-armen authored Mar 28, 2022
2 parents ad20483 + 1e04f89 commit 37cb6b4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ We support instrumenting ASP.NET Core web app on Lambda. Please follow the steps

### Logging (.NET)

The AWS X-Ray .NET SDK share the same logging mechanism as AWS .NET SDK. If the application had already configured logging for AWS .NET SDK, it should just work for AWS X-Ray .NET SDK.
The AWS X-Ray .NET SDK share the same logging mechanism as [AWS .NET SDK](https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-config-other.html#config-setting-awslogging). If the application had already configured logging for AWS .NET SDK, it should just work for AWS X-Ray .NET SDK.
The recommended way to configure an application is to use the <aws> element in the project’s `App.config` or `Web.config` file.

```xml
Expand All @@ -712,8 +712,9 @@ Other ways to configure logging is to edit the <appsetting> element in the `App.

### Logging (.NET Core)

Currently we support `log4net` logging and options provided in [LoggingOptions](https://docs.aws.amazon.com/sdkfornet/v3/apidocs/items/Amazon/TLoggingOptions.html). You should configure logging before initialization of `AWSXRayRecorder` instance or using any X-Ray methods.
Following is the way to configure logging with X-Ray SDK:
The AWS X-Ray .NET SDK share the same logging mechanism as [AWS .NET SDK](https://docs.aws.amazon.com/sdk-for-net/v3/developer-guide/net-dg-config-other.html#config-setting-awslogging). To configure logging for .NET Core application, pass one of these options to the `AWSXRayRecorder.RegisterLogger` method.

Following is the way to configure `log4net` with X-Ray SDK:

```csharp
using Amazon;
Expand Down
6 changes: 6 additions & 0 deletions sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,12 @@ private static void WriteValue (object obj, JsonWriter writer,
return;
}

if (obj is Guid)
{
writer.Write(obj.ToString());
return;
}

if (obj is Array) {
writer.WriteArrayStart ();

Expand Down
27 changes: 27 additions & 0 deletions sdk/test/UnitTests/JsonMapperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

using Amazon.XRay.Recorder.Core.Sampling.Model;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using ThirdParty.LitJson;

namespace Amazon.XRay.Recorder.UnitTests
Expand Down Expand Up @@ -271,5 +272,31 @@ public void TestUnmarshallSamplingTargetResponseWithNull()

Assert.IsNull(samplingTargetResponseModel);
}

[TestMethod]
public void SerializeObjectContainingEmptyGuid()
{
var obj = new AnythingWithGuid();
var actual = JsonMapper.ToJson(obj);
var expected = "{\"Id\":\"00000000-0000-0000-0000-000000000000\"}";

Assert.AreEqual(expected, actual);
}

[TestMethod]
public void SerializeObjectContainingNonEmptyGuid()
{
var guid = Guid.Parse("b2aee583-770c-42c5-b5d8-d25e0df4d161");
var obj = new AnythingWithGuid { Id = guid };
var actual = JsonMapper.ToJson(obj);
var expected = "{\"Id\":\"b2aee583-770c-42c5-b5d8-d25e0df4d161\"}";

Assert.AreEqual(expected, actual);
}

public class AnythingWithGuid
{
public Guid Id { get; set; }
}
}
}

0 comments on commit 37cb6b4

Please sign in to comment.