diff --git a/README.md b/README.md index 01c7d389..bfd7000c 100644 --- a/README.md +++ b/README.md @@ -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 element in the project’s `App.config` or `Web.config` file. ```xml @@ -712,8 +712,9 @@ Other ways to configure logging is to edit the 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; diff --git a/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs b/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs index aa85e9fd..0b82c002 100644 --- a/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs +++ b/sdk/src/Core/ThirdParty/LitJson/JsonMapper.cs @@ -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 (); diff --git a/sdk/test/UnitTests/JsonMapperTest.cs b/sdk/test/UnitTests/JsonMapperTest.cs index 65c16807..c61aff1e 100644 --- a/sdk/test/UnitTests/JsonMapperTest.cs +++ b/sdk/test/UnitTests/JsonMapperTest.cs @@ -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 @@ -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; } + } } }