Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix: Prevent data duplication in TraceTelemetry with IncludeFormatted…
…Message.
  • Loading branch information
rajkumar-rangaraj committed Oct 16, 2023
commit d47d797e32979af9b1474225b134aa00814a2e53
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
the telemetry offline for retrying at a later time.
([#38832](https://github.com/Azure/azure-sdk-for-net/pull/38832))

* Fixed an issue where `OriginalFormat` persisted in TraceTelemetry properties
with IncludeFormattedMessage enabled in OpenTelemetry LoggerProvider. This fix
prevents data duplication in message fields and properties.
([#](https://github.com/Azure/azure-sdk-for-net/pull/))

### Other Changes

* Update OpenTelemetry dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ private static void ExtractProperties(ref string? message, IDictionary<string, s
{
message = item.Value.ToString();
}
else
{
properties.Add("OriginalFormat", item.Value.ToString().Truncate(SchemaConstants.KVP_MaxValueLength) ?? "null");
}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ public void MessageIsSetToExceptionMessage(bool parseStateValues)

Assert.Equal("Test Exception", message);

Assert.True(properties.TryGetValue("OriginalFormat", out string value));
Assert.Equal(log, value);
Assert.True(properties.TryGetValue("name", out string name));
Assert.Equal("tomato", name);
Assert.True(properties.TryGetValue("price", out string price));
Assert.Equal("2.99", price);
Assert.Equal(3, properties.Count);
Assert.Equal(2, properties.Count);
}

[Fact]
Expand All @@ -87,13 +85,11 @@ public void MessageIsSetToFormattedMessageWhenIncludeFormattedMessageIsSet()
var message = LogsHelper.GetMessageAndSetProperties(logRecords[0], properties);

Assert.Equal("Hello from tomato 2.99.", message);
Assert.True(properties.TryGetValue("OriginalFormat", out string value));
Assert.Equal(log, value);
Assert.True(properties.TryGetValue("name", out string name));
Assert.Equal("tomato", name);
Assert.True(properties.TryGetValue("price", out string price));
Assert.Equal("2.99", price);
Assert.Equal(3, properties.Count);
Assert.Equal(2, properties.Count);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ public void ValidateTelemetryExceptionData(LogLevel logLevel)

Assert.Equal(2, exceptionData.Version);
Assert.Equal(LogsHelper.GetSeverityLevel(logLevel), exceptionData.SeverityLevel);
Assert.Equal("Log Message", exceptionData.Properties["OriginalFormat"]);
Assert.Empty(exceptionData.Measurements);
Assert.Equal(typeof(Exception).FullName + " at UnknownMethod", exceptionData.ProblemId);
Assert.Equal(1, exceptionData.Exceptions.Count);
Expand Down