From 0a0ba465df6c7fc0c79cdfe8914f39ceccb3ae82 Mon Sep 17 00:00:00 2001 From: Rajkumar Rangaraj Date: Fri, 7 Jul 2023 15:22:37 -0700 Subject: [PATCH] [AzureMonitorExporter] Add support new HTTP semantics - Dependency Telemetry (#37464) * Add support new HTTP semantics - Dependency Telemetry * Merge two conditions. * PR feedback --- .../Models/RemoteDependencyData.Schema.New.cs | 71 ++++++++++ .../Models/RequestData.Schema.New.cs | 48 +++++++ .../Customizations/Models/RequestDataV2.cs | 49 ------- .../Customizations/Models/TelemetryItem.cs | 2 +- .../src/Internals/AzMonListExtensionsV2.cs | 44 ------- .../src/Internals/AzMonNewListExtensions.cs | 91 +++++++++++++ .../src/Internals/OperationType.cs | 2 + .../src/Internals/SchemaConstants.cs | 2 + .../src/Internals/TraceHelper.cs | 6 +- .../AzMonListExtensionsV2Tests.cs | 38 ------ .../AzMonNewListExtensionsTests.cs | 81 ++++++++++++ .../RemoteDependencyDataNewTests.cs | 122 ++++++++++++++++++ ...tDataV2Tests.cs => RequestDataNewTests.cs} | 18 +-- .../TagsTests.cs | 2 +- ...elperV2Tests.cs => TraceHelperNewTests.cs} | 42 +++--- 15 files changed, 452 insertions(+), 166 deletions(-) create mode 100644 sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/RemoteDependencyData.Schema.New.cs create mode 100644 sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/RequestData.Schema.New.cs delete mode 100644 sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/RequestDataV2.cs delete mode 100644 sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/AzMonListExtensionsV2.cs create mode 100644 sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/AzMonNewListExtensions.cs delete mode 100644 sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/AzMonListExtensionsV2Tests.cs create mode 100644 sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/AzMonNewListExtensionsTests.cs create mode 100644 sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/RemoteDependencyDataNewTests.cs rename sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/{RequestDataV2Tests.cs => RequestDataNewTests.cs} (94%) rename sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/{TraceHelperV2Tests.cs => TraceHelperNewTests.cs} (76%) diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/RemoteDependencyData.Schema.New.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/RemoteDependencyData.Schema.New.cs new file mode 100644 index 0000000000000..8513057ee7e04 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/RemoteDependencyData.Schema.New.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Diagnostics; +using System.Globalization; +using Azure.Core; +using Azure.Monitor.OpenTelemetry.Exporter.Internals; + +namespace Azure.Monitor.OpenTelemetry.Exporter.Models; + +internal partial class RemoteDependencyData +{ + public RemoteDependencyData(int version, Activity activity, ref ActivityTagsProcessor activityTagsProcessor, string schemaVersion) : base(version) + { + Properties = new ChangeTrackingDictionary(); + Measurements = new ChangeTrackingDictionary(); + + string? httpUrl = null; + string dependencyName; + + if (activityTagsProcessor.activityType.HasFlag(OperationType.Http)) + { + httpUrl = AzMonList.GetTagValue(ref activityTagsProcessor.MappedTags, SemanticConventions.AttributeUrlFull)?.ToString(); + dependencyName = activityTagsProcessor.MappedTags.GetNewSchemaHttpDependencyName(httpUrl) ?? activity.DisplayName; + Data = httpUrl.Truncate(SchemaConstants.RemoteDependencyData_Data_MaxLength); + Target = activityTagsProcessor.MappedTags.GetNewSchemaHttpDependencyTarget().Truncate(SchemaConstants.RemoteDependencyData_Target_MaxLength); + Type = "Http"; + ResultCode = AzMonList.GetTagValue(ref activityTagsProcessor.MappedTags, SemanticConventions.AttributeHttpResponseStatusCode) + ?.ToString().Truncate(SchemaConstants.RemoteDependencyData_ResultCode_MaxLength) + ?? "0"; + } + else + { + dependencyName = activity.DisplayName; + } + + Name = dependencyName.Truncate(SchemaConstants.RemoteDependencyData_Name_MaxLength); + Id = activity.Context.SpanId.ToHexString(); + Duration = activity.Duration < SchemaConstants.RemoteDependencyData_Duration_LessThanDays + ? activity.Duration.ToString("c", CultureInfo.InvariantCulture) + : SchemaConstants.Duration_MaxValue; + Success = activity.Status != ActivityStatusCode.Error; + + // TODO: Other operation types. + + if (activityTagsProcessor.AzureNamespace != null) + { + if (activity.Kind == ActivityKind.Internal) + { + Type = $"InProc | {activityTagsProcessor.AzureNamespace}"; + } + else if (activity.Kind == ActivityKind.Producer) + { + Type = $"Queue Message | {activityTagsProcessor.AzureNamespace}"; + } + else + { + // The Azure SDK sets az.namespace with its resource provider information. + // When ActivityKind is not internal and az.namespace is present, set the value of Type to az.namespace. + Type = activityTagsProcessor.AzureNamespace ?? Type; + } + } + else if (activity.Kind == ActivityKind.Internal) + { + Type = "InProc"; + } + + TraceHelper.AddActivityLinksToProperties(activity, ref activityTagsProcessor.UnMappedTags); + TraceHelper.AddPropertiesToTelemetry(Properties, ref activityTagsProcessor.UnMappedTags); + } +} diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/RequestData.Schema.New.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/RequestData.Schema.New.cs new file mode 100644 index 0000000000000..784212b483bf4 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/RequestData.Schema.New.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Diagnostics; +using System.Globalization; +using Azure.Core; +using Azure.Monitor.OpenTelemetry.Exporter.Internals; + +namespace Azure.Monitor.OpenTelemetry.Exporter.Models; + +internal partial class RequestData +{ + public RequestData(int version, Activity activity, ref ActivityTagsProcessor activityTagsProcessor, string schemaVersion) : base(version) + { + string? url = null; + + if (activityTagsProcessor.activityType.HasFlag(OperationType.Http)) + { + url = activityTagsProcessor.MappedTags.GetNewSchemaRequestUrl(); + } + + Id = activity.Context.SpanId.ToHexString(); + Name = TraceHelper.GetNewSchemaOperationName(activity, url, ref activityTagsProcessor.MappedTags).Truncate(SchemaConstants.RequestData_Name_MaxLength); + Duration = activity.Duration < SchemaConstants.RequestData_Duration_LessThanDays + ? activity.Duration.ToString("c", CultureInfo.InvariantCulture) + : SchemaConstants.Duration_MaxValue; + ResponseCode = AzMonList.GetTagValue(ref activityTagsProcessor.MappedTags, SemanticConventions.AttributeHttpResponseStatusCode) + ?.ToString().Truncate(SchemaConstants.RequestData_ResponseCode_MaxLength) + ?? "0"; + + Success = IsSuccess(activity, ResponseCode, activityTagsProcessor.activityType); + + Url = url.Truncate(SchemaConstants.RequestData_Url_MaxLength); + Properties = new ChangeTrackingDictionary(); + Measurements = new ChangeTrackingDictionary(); + + if (activity.Kind == ActivityKind.Consumer) + { + TraceHelper.AddEnqueuedTimeToMeasurementsAndLinksToProperties(activity, Measurements, ref activityTagsProcessor.UnMappedTags); + } + else + { + TraceHelper.AddActivityLinksToProperties(activity, ref activityTagsProcessor.UnMappedTags); + } + + TraceHelper.AddPropertiesToTelemetry(Properties, ref activityTagsProcessor.UnMappedTags); + } +} diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/RequestDataV2.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/RequestDataV2.cs deleted file mode 100644 index 2b06b3823755c..0000000000000 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/RequestDataV2.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Diagnostics; -using System.Globalization; -using Azure.Core; -using Azure.Monitor.OpenTelemetry.Exporter.Internals; - -namespace Azure.Monitor.OpenTelemetry.Exporter.Models -{ - internal partial class RequestData - { - public RequestData(int version, Activity activity, ref ActivityTagsProcessor activityTagsProcessor, string schemaVersion) : base(version) - { - string? url = null; - - if (activityTagsProcessor.activityType.HasFlag(OperationType.Http)) - { - url = activityTagsProcessor.MappedTags.GetV2RequestUrl(); - } - - Id = activity.Context.SpanId.ToHexString(); - Name = TraceHelper.GetV2OperationName(activity, url, ref activityTagsProcessor.MappedTags).Truncate(SchemaConstants.RequestData_Name_MaxLength); - Duration = activity.Duration < SchemaConstants.RequestData_Duration_LessThanDays - ? activity.Duration.ToString("c", CultureInfo.InvariantCulture) - : SchemaConstants.Duration_MaxValue; - ResponseCode = AzMonList.GetTagValue(ref activityTagsProcessor.MappedTags, SemanticConventions.AttributeHttpResponseStatusCode) - ?.ToString().Truncate(SchemaConstants.RequestData_ResponseCode_MaxLength) - ?? "0"; - - Success = IsSuccess(activity, ResponseCode, activityTagsProcessor.activityType); - - Url = url.Truncate(SchemaConstants.RequestData_Url_MaxLength); - Properties = new ChangeTrackingDictionary(); - Measurements = new ChangeTrackingDictionary(); - - if (activity.Kind == ActivityKind.Consumer) - { - TraceHelper.AddEnqueuedTimeToMeasurementsAndLinksToProperties(activity, Measurements, ref activityTagsProcessor.UnMappedTags); - } - else - { - TraceHelper.AddActivityLinksToProperties(activity, ref activityTagsProcessor.UnMappedTags); - } - - TraceHelper.AddPropertiesToTelemetry(Properties, ref activityTagsProcessor.UnMappedTags); - } - } -} diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/TelemetryItem.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/TelemetryItem.cs index 1bb43e095ff3b..3664fcb6e3872 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/TelemetryItem.cs +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Customizations/Models/TelemetryItem.cs @@ -38,7 +38,7 @@ public TelemetryItem(Activity activity, ref ActivityTagsProcessor activityTagsPr if (activity.Kind == ActivityKind.Server) { Tags[ContextTagKeys.AiOperationName.ToString()] = activityTagsProcessor.activityType.HasFlag(OperationType.V2) - ? TraceHelper.GetV2OperationName(activity, null, ref activityTagsProcessor.MappedTags) + ? TraceHelper.GetNewSchemaOperationName(activity, null, ref activityTagsProcessor.MappedTags) : TraceHelper.GetOperationName(activity, ref activityTagsProcessor.MappedTags); Tags[ContextTagKeys.AiLocationIp.ToString()] = TraceHelper.GetLocationIp(ref activityTagsProcessor.MappedTags); } diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/AzMonListExtensionsV2.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/AzMonListExtensionsV2.cs deleted file mode 100644 index b7a87499ace05..0000000000000 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/AzMonListExtensionsV2.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; - -namespace Azure.Monitor.OpenTelemetry.Exporter.Internals -{ - internal static class AzMonListExtensionsV2 - { - /// - /// Gets http request url from activity tag objects. - /// - internal static string? GetV2RequestUrl(this AzMonList tagObjects) - { - try - { - var serverAddress = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeServerAddress)?.ToString(); - if (serverAddress != null) - { - UriBuilder uriBuilder = new() - { - Scheme = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeUrlScheme)?.ToString(), - Host = serverAddress, - Path = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeUrlPath)?.ToString(), - Query = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeUrlQuery)?.ToString() - }; - - if (int.TryParse(AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeServerPort)?.ToString(), out int port)) - { - uriBuilder.Port = port; - } - - return uriBuilder.Uri.AbsoluteUri; - } - } - catch - { - // If URI building fails, there is no need to throw an exception. Instead, we can simply return null. - } - - return null; - } - } -} diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/AzMonNewListExtensions.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/AzMonNewListExtensions.cs new file mode 100644 index 0000000000000..03215897fb397 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/AzMonNewListExtensions.cs @@ -0,0 +1,91 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Runtime.CompilerServices; + +namespace Azure.Monitor.OpenTelemetry.Exporter.Internals; + +internal static class AzMonNewListExtensions +{ + /// + /// Gets http request url from activity tag objects. + /// + internal static string? GetNewSchemaRequestUrl(this AzMonList tagObjects) + { + try + { + var serverAddress = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeServerAddress)?.ToString(); + if (serverAddress != null) + { + UriBuilder uriBuilder = new() + { + Scheme = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeUrlScheme)?.ToString(), + Host = serverAddress, + Path = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeUrlPath)?.ToString(), + Query = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeUrlQuery)?.ToString() + }; + + if (int.TryParse(AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeServerPort)?.ToString(), out int port)) + { + uriBuilder.Port = port; + } + + return uriBuilder.Uri.AbsoluteUri; + } + } + catch + { + // If URI building fails, there is no need to throw an exception. Instead, we can simply return null. + } + + return null; + } + + /// + /// Gets Http dependency target from activity tag objects. + /// + internal static string? GetNewSchemaHttpDependencyTarget(this AzMonList tagObjects) + { + var tagValues = AzMonList.GetTagValues(ref tagObjects, SemanticConventions.AttributeServerAddress, SemanticConventions.AttributeServerPort); + var serverAddress = tagValues[0]?.ToString(); // tagValues[0] => SemanticConventions.AttributeServerAddress. + var serverPort = tagValues[1]?.ToString(); // tagValues[1] => SemanticConventions.AttributeServerPort. + + if (string.IsNullOrWhiteSpace(serverAddress)) + { + return null; + } + + if (int.TryParse(serverPort, out int port) && !IsDefaultPort(port)) + { + return $"{serverAddress}:{serverPort}"; + } + + return serverAddress; + } + + internal static string? GetNewSchemaHttpDependencyName(this AzMonList tagObjects, string? httpUrl) + { + if (string.IsNullOrWhiteSpace(httpUrl)) + { + return null; + } + + var httpMethod = AzMonList.GetTagValue(ref tagObjects, SemanticConventions.AttributeHttpRequestMethod)?.ToString(); + if (!string.IsNullOrWhiteSpace(httpMethod)) + { + if (Uri.TryCreate(httpUrl!.ToString(), UriKind.Absolute, out var uri) && uri.IsAbsoluteUri) + { + return $"{httpMethod} {uri.AbsolutePath}"; + } + } + + return null; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static bool IsDefaultPort(int port) + { + return port == 0 || port == 80 || port == 443; + } +} diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/OperationType.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/OperationType.cs index 7f654791b02d5..2f3d749a796af 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/OperationType.cs +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/OperationType.cs @@ -16,6 +16,8 @@ internal enum OperationType Http = 16, Messaging = 32, Rpc = 64, + // TODO: https://github.com/Azure/azure-sdk-for-net/pull/37357/files#r1253383825 + // Check if V2 could be moved outside of this Enum. V2 = 128 } } diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/SchemaConstants.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/SchemaConstants.cs index fbe7b606fd09a..20c70ab300c8b 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/SchemaConstants.cs +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/SchemaConstants.cs @@ -115,5 +115,7 @@ internal static class SchemaConstants public const int TelemetryEnvelope_Name_MaxLength = 1024; public const int TelemetryEnvelope_Time_MaxLength = 64; public const int TelemetryEnvelope_InstrumentationKey_MaxLength = 40; + + public const string DefaultSchemaVersion = "1.21.0"; } } diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/TraceHelper.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/TraceHelper.cs index 0e71024b851ae..90f0b46b12d39 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/TraceHelper.cs +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/src/Internals/TraceHelper.cs @@ -49,7 +49,7 @@ internal static List OtelToAzureMonitorTrace(Batch batc { BaseType = "RequestData", BaseData = activityTagsProcessor.activityType.HasFlag(OperationType.V2) - ? new RequestData(Version, activity, ref activityTagsProcessor, schemaVersion: "V2") + ? new RequestData(Version, activity, ref activityTagsProcessor, schemaVersion: SchemaConstants.DefaultSchemaVersion) : new RequestData(Version, activity, ref activityTagsProcessor) }; break; @@ -173,7 +173,7 @@ internal static string GetOperationName(Activity activity, ref AzMonList MappedT return activity.DisplayName; } - internal static string GetV2OperationName(Activity activity, string? url, ref AzMonList MappedTags) + internal static string GetNewSchemaOperationName(Activity activity, string? url, ref AzMonList MappedTags) { var httpMethod = AzMonList.GetTagValue(ref MappedTags, SemanticConventions.AttributeHttpRequestMethod)?.ToString(); if (!string.IsNullOrWhiteSpace(httpMethod)) @@ -187,7 +187,7 @@ internal static string GetV2OperationName(Activity activity, string? url, ref A return $"{httpMethod} {httpRoute}"; } - url ??= MappedTags.GetV2RequestUrl(); + url ??= MappedTags.GetNewSchemaRequestUrl(); if (url != null) { return $"{httpMethod} {url}"; diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/AzMonListExtensionsV2Tests.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/AzMonListExtensionsV2Tests.cs deleted file mode 100644 index 4e590c415e7c2..0000000000000 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/AzMonListExtensionsV2Tests.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Collections.Generic; - -using Azure.Monitor.OpenTelemetry.Exporter.Internals; - -using Xunit; - -namespace Azure.Monitor.OpenTelemetry.Exporter.Tests -{ - public class AzMonListExtensionsV2Tests - { - [Theory] - [InlineData("http", "example.com", "8080", "/search", "q=OpenTelemetry", "http://example.com:8080/search?q=OpenTelemetry")] - [InlineData(null, "example.com", "8080", "/search", "q=OpenTelemetry", "example.com:8080/search?q=OpenTelemetry")] - [InlineData("http", null, "8080", "/search", "q=OpenTelemetry", null)] - [InlineData("http", "example.com", null, "/search", "q=OpenTelemetry", "http://example.com/search?q=OpenTelemetry")] - [InlineData("http", "example.com", "8080", null, "q=OpenTelemetry", "http://example.com:8080/?q=OpenTelemetry")] - [InlineData("http", "example.com", "8080", "/search", null, "http://example.com:8080/search")] - public void GetV2RequestUrl_ReturnsCorrectUrl(string urlScheme, string serverAddress, string serverPort, string urlPath, string urlQuery, string expectedUrl) - { - // Arrange - AzMonList tagObjects = AzMonList.Initialize(); - AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeUrlScheme, urlScheme)); - AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeServerAddress, serverAddress)); - AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeServerPort, serverPort)); - AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeUrlPath, urlPath)); - AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeUrlQuery, urlQuery)); - - // Act - string? url = tagObjects.GetV2RequestUrl(); - - // Assert - Assert.Equal(expectedUrl, url); - } - } -} diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/AzMonNewListExtensionsTests.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/AzMonNewListExtensionsTests.cs new file mode 100644 index 0000000000000..7fe3a125e7d40 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/AzMonNewListExtensionsTests.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; + +using Azure.Monitor.OpenTelemetry.Exporter.Internals; +using Xunit; + +namespace Azure.Monitor.OpenTelemetry.Exporter.Tests +{ + public class AzMonNewListExtensionsTests + { + [Theory] + [InlineData("http", "example.com", "8080", "/search", "q=OpenTelemetry", "http://example.com:8080/search?q=OpenTelemetry")] + [InlineData(null, "example.com", "8080", "/search", "q=OpenTelemetry", "example.com:8080/search?q=OpenTelemetry")] + [InlineData("http", null, "8080", "/search", "q=OpenTelemetry", null)] + [InlineData("http", "example.com", null, "/search", "q=OpenTelemetry", "http://example.com/search?q=OpenTelemetry")] + [InlineData("http", "example.com", "8080", null, "q=OpenTelemetry", "http://example.com:8080/?q=OpenTelemetry")] + [InlineData("http", "example.com", "8080", "/search", null, "http://example.com:8080/search")] + public void GetNewRequestUrl_ReturnsCorrectUrl(string urlScheme, string serverAddress, string serverPort, string urlPath, string urlQuery, string expectedUrl) + { + // Arrange + AzMonList tagObjects = AzMonList.Initialize(); + AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeUrlScheme, urlScheme)); + AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeServerAddress, serverAddress)); + AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeServerPort, serverPort)); + AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeUrlPath, urlPath)); + AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeUrlQuery, urlQuery)); + + // Act + string? url = tagObjects.GetNewSchemaRequestUrl(); + + // Assert + Assert.Equal(expectedUrl, url); + } + + [Theory] + [InlineData("example.com", "80", "example.com")] + [InlineData("example.com", "443", "example.com")] + [InlineData("example.com", "8080", "example.com:8080")] + [InlineData("example.com", null, "example.com")] + [InlineData("example.com", "", "example.com")] + [InlineData(null, "8080", null)] + [InlineData("", "8080", null)] + public void GetNewHttpDependencyTarget_ReturnsExpectedResult(string serverAddress, string serverPort, string expected) + { + // Arrange + AzMonList tagObjects = AzMonList.Initialize(); + AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeServerAddress, serverAddress)); + AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeServerPort, serverPort)); + + // Act + string? result = tagObjects.GetNewSchemaHttpDependencyTarget(); + + // Assert + Assert.Equal(expected, result); + } + + [Theory] + [InlineData("POST", "http://example.com/api/users", "POST /api/users")] + [InlineData("GET", "http://example.com/api/posts?page=2", "GET /api/posts")] + [InlineData("PUT", "http://example.com", "PUT /")] + [InlineData("", "http://example.com", null)] + [InlineData(null, "http://example.com", null)] + [InlineData("GET", "", null)] + [InlineData("GET", null, null)] + [InlineData("", "", null)] + public void GetNewHttpDependencyName_ReturnsExpectedResult(string httpMethod, string httpUrl, string expected) + { + // Arrange + AzMonList tagObjects = AzMonList.Initialize(); + AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeHttpRequestMethod, httpMethod)); + + // Act + string? result = tagObjects.GetNewSchemaHttpDependencyName(httpUrl); + + // Assert + Assert.Equal(expected, result); + } + } +} diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/RemoteDependencyDataNewTests.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/RemoteDependencyDataNewTests.cs new file mode 100644 index 0000000000000..b5cabdc59e519 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/RemoteDependencyDataNewTests.cs @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Diagnostics; +using System.Globalization; + +using Azure.Monitor.OpenTelemetry.Exporter.Internals; +using Azure.Monitor.OpenTelemetry.Exporter.Models; +using OpenTelemetry; +using OpenTelemetry.Trace; + +using Xunit; + +namespace Azure.Monitor.OpenTelemetry.Exporter.Tests +{ + public class RemoteDependencyDataNewTests + { + private const string ActivityName = "RemoteDependencyDataNewActivity"; + + [Fact] + public void DependencyTypeIsSetToInProcForInternalSpan() + { + using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddSource(nameof(DependencyTypeIsSetToInProcForInternalSpan)).Build(); + using var activitySource = new ActivitySource(nameof(DependencyTypeIsSetToInProcForInternalSpan)); + using var activity = activitySource.StartActivity("Activity", ActivityKind.Internal); + + Assert.NotNull(activity); + var activityTagsProcessor = TraceHelper.EnumerateActivityTags(activity); + + var remoteDependencyDataType = new RemoteDependencyData(2, activity, ref activityTagsProcessor, schemaVersion:SchemaConstants.DefaultSchemaVersion).Type; + + Assert.Equal("InProc", remoteDependencyDataType); + } + + [Theory] + [InlineData(ActivityKind.Client)] + [InlineData(ActivityKind.Producer)] + [InlineData(ActivityKind.Internal)] + public void RemoteDependencyTypeReflectsAzureNamespace(ActivityKind activityKind) + { + using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddSource(nameof(RemoteDependencyTypeReflectsAzureNamespace)).Build(); + using var activitySource = new ActivitySource(nameof(RemoteDependencyTypeReflectsAzureNamespace)); + using var activity = activitySource.StartActivity("Activity", activityKind); + activity?.AddTag("az.namespace", "DemoAzureResource"); + + Assert.NotNull(activity); + var activityTagsProcessor = TraceHelper.EnumerateActivityTags(activity); + + var remoteDependencyData = new RemoteDependencyData(2, activity, ref activityTagsProcessor, schemaVersion:SchemaConstants.DefaultSchemaVersion); + + Assert.Equal("DemoAzureResource", activityTagsProcessor.AzureNamespace); + if (activity.Kind == ActivityKind.Internal) + { + Assert.Equal("InProc | DemoAzureResource", remoteDependencyData.Type); + } + else if (activity.Kind == ActivityKind.Producer) + { + Assert.Equal("Queue Message | DemoAzureResource", remoteDependencyData.Type); + } + else + { + Assert.Equal("DemoAzureResource", remoteDependencyData.Type); + } + } + + [Fact] + public void ValidateHttpRemoteDependencyData() + { + using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddSource(nameof(ValidateHttpRemoteDependencyData)).Build(); + using var activitySource = new ActivitySource(nameof(ValidateHttpRemoteDependencyData)); + using var activity = activitySource.StartActivity( + ActivityName, + ActivityKind.Client, + parentContext: new ActivityContext(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.Recorded), + startTime: DateTime.UtcNow); + Assert.NotNull(activity); + activity.Stop(); + + var httpUrl = "https://www.foo.bar/search"; + activity.SetStatus(Status.Ok); + activity.SetTag(SemanticConventions.AttributeHttpRequestMethod, "GET"); + activity.SetTag(SemanticConventions.AttributeUrlFull, httpUrl); + + var activityTagsProcessor = TraceHelper.EnumerateActivityTags(activity); + + var remoteDependencyData = new RemoteDependencyData(2, activity, ref activityTagsProcessor, schemaVersion: SchemaConstants.DefaultSchemaVersion); + + Assert.Equal("GET /search", remoteDependencyData.Name); + Assert.Equal(activity.Context.SpanId.ToHexString(), remoteDependencyData.Id); + Assert.Equal(httpUrl, remoteDependencyData.Data); + Assert.Equal("0", remoteDependencyData.ResultCode); + Assert.Equal(activity.Duration.ToString("c", CultureInfo.InvariantCulture), remoteDependencyData.Duration); + Assert.Equal(activity.GetStatus() != Status.Error, remoteDependencyData.Success); + Assert.True(remoteDependencyData.Properties.Count == 0); + Assert.True(remoteDependencyData.Measurements.Count == 0); + } + + [Fact] + public void HttpDependencyNameIsActivityDisplayNameByDefault() + { + using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddSource(nameof(HttpDependencyNameIsActivityDisplayNameByDefault)).Build(); + using var activitySource = new ActivitySource(nameof(HttpDependencyNameIsActivityDisplayNameByDefault)); + using var activity = activitySource.StartActivity( + ActivityName, + ActivityKind.Client, + parentContext: new ActivityContext(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.Recorded), + startTime: DateTime.UtcNow); + + Assert.NotNull(activity); + activity.SetTag(SemanticConventions.AttributeHttpRequestMethod, "GET"); + + activity.DisplayName = "HTTP GET"; + + var activityTagsProcessor = TraceHelper.EnumerateActivityTags(activity); + + var remoteDependencyDataName = new RemoteDependencyData(2, activity, ref activityTagsProcessor, schemaVersion: SchemaConstants.DefaultSchemaVersion).Name; + + Assert.Equal(activity.DisplayName, remoteDependencyDataName); + } + } +} diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/RequestDataV2Tests.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/RequestDataNewTests.cs similarity index 94% rename from sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/RequestDataV2Tests.cs rename to sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/RequestDataNewTests.cs index 8c247a4524711..7f0ee2a362c87 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/RequestDataV2Tests.cs +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/RequestDataNewTests.cs @@ -14,9 +14,9 @@ namespace Azure.Monitor.OpenTelemetry.Exporter.Tests { - public class RequestDataV2Tests + public class RequestDataNewTests { - private const string ActivityName = "RequestDataActivity"; + private const string ActivityName = "RequestDataNewActivity"; [Fact] public void ValidateHttpRequestData() @@ -42,7 +42,7 @@ public void ValidateHttpRequestData() var activityTagsProcessor = TraceHelper.EnumerateActivityTags(activity); - var requestData = new RequestData(2, activity, ref activityTagsProcessor, "V2"); + var requestData = new RequestData(2, activity, ref activityTagsProcessor, schemaVersion: SchemaConstants.DefaultSchemaVersion); Assert.Equal("GET /search", requestData.Name); Assert.Equal(activity.Context.SpanId.ToHexString(), requestData.Id); @@ -76,7 +76,7 @@ public void ValidateHttpRequestDataResponseCode(string httpStatusCode) var activityTagsProcessor = TraceHelper.EnumerateActivityTags(activity); - var requestData = new RequestData(2, activity, ref activityTagsProcessor, schemaVersion: "V2"); + var requestData = new RequestData(2, activity, ref activityTagsProcessor, schemaVersion: SchemaConstants.DefaultSchemaVersion); Assert.Equal(httpResponseCode, requestData.ResponseCode); } @@ -104,7 +104,7 @@ public void ValidateHttpRequestSuccess(string httpStatusCode, bool isSuccess) var activityTagsProcessor = TraceHelper.EnumerateActivityTags(activity); - var requestData = new RequestData(2, activity, ref activityTagsProcessor, schemaVersion: "V2"); + var requestData = new RequestData(2, activity, ref activityTagsProcessor, schemaVersion: SchemaConstants.DefaultSchemaVersion); Assert.Equal(httpResponseCode, requestData.ResponseCode); Assert.Equal(isSuccess, requestData.Success); @@ -122,7 +122,7 @@ public void RequestDataContainsAzureNamespace() Assert.NotNull(activity); var activityTagsProcessor = TraceHelper.EnumerateActivityTags(activity); - var requestData = new RequestData(2, activity, ref activityTagsProcessor, schemaVersion: "V2"); + var requestData = new RequestData(2, activity, ref activityTagsProcessor, schemaVersion: SchemaConstants.DefaultSchemaVersion); Assert.Equal("DemoAzureResource", activityTagsProcessor.AzureNamespace); } @@ -147,7 +147,7 @@ public void RequestDataContainsTimeSinceEnqueuedForConsumerSpans() Assert.NotNull(activity); var activityTagsProcessor = TraceHelper.EnumerateActivityTags(activity); - var requestData = new RequestData(2, activity, ref activityTagsProcessor, schemaVersion: "V2"); + var requestData = new RequestData(2, activity, ref activityTagsProcessor, schemaVersion: SchemaConstants.DefaultSchemaVersion); DateTimeOffset startTime = activity.StartTimeUtc; var startTimeEpoch = startTime.ToUnixTimeMilliseconds(); @@ -181,7 +181,7 @@ public void RequestDataTimeSinceEnqueuedNegative() Assert.NotNull(activity); var activityTagsProcessor = TraceHelper.EnumerateActivityTags(activity); - var requestData = new RequestData(2, activity, ref activityTagsProcessor, schemaVersion: "V2"); + var requestData = new RequestData(2, activity, ref activityTagsProcessor, schemaVersion: SchemaConstants.DefaultSchemaVersion); DateTimeOffset startTime = activity.StartTimeUtc; var startTimeEpoch = startTime.ToUnixTimeMilliseconds(); @@ -212,7 +212,7 @@ public void RequestDataTimeSinceEnqueuedInvalidEmqueuedTime() Assert.NotNull(activity); var activityTagsProcessor = TraceHelper.EnumerateActivityTags(activity); - var requestData = new RequestData(2, activity, ref activityTagsProcessor, schemaVersion: "V2"); + var requestData = new RequestData(2, activity, ref activityTagsProcessor, schemaVersion: SchemaConstants.DefaultSchemaVersion); DateTimeOffset startTime = activity.StartTimeUtc; var startTimeEpoch = startTime.ToUnixTimeMilliseconds(); diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/TagsTests.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/TagsTests.cs index a57453c1deeaa..e997870763ad2 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/TagsTests.cs +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/TagsTests.cs @@ -117,7 +117,7 @@ public void TagObjects_Mapped() } [Fact] - public void TagObjects_Mapped_HonorsV2() + public void TagObjects_Mapped_HonorsNewSchema() { var activityTagsProcessor = new ActivityTagsProcessor(); diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/TraceHelperV2Tests.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/TraceHelperNewTests.cs similarity index 76% rename from sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/TraceHelperV2Tests.cs rename to sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/TraceHelperNewTests.cs index 984234301b454..32728d3d6c226 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/TraceHelperV2Tests.cs +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Azure.Monitor.OpenTelemetry.Exporter.Tests/TraceHelperNewTests.cs @@ -13,7 +13,7 @@ namespace Azure.Monitor.OpenTelemetry.Exporter.Tests { - public class TraceHelperV2Tests + public class TraceHelperNewTests { private const string ActivityName = "AzureMonitorTraceHelperTestsActivity"; @@ -21,11 +21,11 @@ public class TraceHelperV2Tests [InlineData("GET", "/api/{controller}/{action}", "GET /api/urltest")] [InlineData("GET", "/api/routetest", "GET /api/routetest")] [InlineData("POST", "/api/routetest", "POST /api/routetest")] - public void GetV2OperationName_ValidateHttpMethodAndHttpRoute(string httpMethod, string httpRoute, string expected) + public void GetNewOperationName_ValidateHttpMethodAndHttpRoute(string httpMethod, string httpRoute, string expected) { // Arrange - using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddSource(nameof(GetV2OperationName_ValidateHttpMethodAndHttpRoute)).Build(); - using var activitySource = new ActivitySource(nameof(GetV2OperationName_ValidateHttpMethodAndHttpRoute)); + using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddSource(nameof(GetNewOperationName_ValidateHttpMethodAndHttpRoute)).Build(); + using var activitySource = new ActivitySource(nameof(GetNewOperationName_ValidateHttpMethodAndHttpRoute)); using var activity = activitySource.StartActivity( ActivityName, ActivityKind.Server); @@ -37,18 +37,18 @@ public void GetV2OperationName_ValidateHttpMethodAndHttpRoute(string httpMethod, AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeHttpRoute, httpRoute)); // Act - var result = TraceHelper.GetV2OperationName(activity!, url, ref tagObjects); + var result = TraceHelper.GetNewSchemaOperationName(activity!, url, ref tagObjects); // Assert Assert.Equal(expected, result); } [Fact] - public void GetV2OperationName_WithValidHttpMethodAndUrl() + public void GetNewOperationName_WithValidHttpMethodAndUrl() { // Arrange - using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddSource(nameof(GetV2OperationName_WithValidHttpMethodAndUrl)).Build(); - using var activitySource = new ActivitySource(nameof(GetV2OperationName_WithValidHttpMethodAndUrl)); + using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddSource(nameof(GetNewOperationName_WithValidHttpMethodAndUrl)).Build(); + using var activitySource = new ActivitySource(nameof(GetNewOperationName_WithValidHttpMethodAndUrl)); using var activity = activitySource.StartActivity( ActivityName, ActivityKind.Server); @@ -58,7 +58,7 @@ public void GetV2OperationName_WithValidHttpMethodAndUrl() AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeHttpRequestMethod, "GET")); // Act - var result = TraceHelper.GetV2OperationName(activity!, "/api/test", ref tagObjects); + var result = TraceHelper.GetNewSchemaOperationName(activity!, "/api/test", ref tagObjects); // Assert Assert.Equal("GET /api/test", result); @@ -67,11 +67,11 @@ public void GetV2OperationName_WithValidHttpMethodAndUrl() [Theory] [InlineData(null, "/api/test")] [InlineData("", "/api/test")] - public void GetV2OperationName_WithNullHttpMethod_ReturnsActivityDisplayName(string httpMethod, string httpRoute) + public void GetNewOperationName_WithNullHttpMethod_ReturnsActivityDisplayName(string httpMethod, string httpRoute) { // Arrange - using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddSource(nameof(GetV2OperationName_WithNullHttpMethod_ReturnsActivityDisplayName)).Build(); - using var activitySource = new ActivitySource(nameof(GetV2OperationName_WithNullHttpMethod_ReturnsActivityDisplayName)); + using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddSource(nameof(GetNewOperationName_WithNullHttpMethod_ReturnsActivityDisplayName)).Build(); + using var activitySource = new ActivitySource(nameof(GetNewOperationName_WithNullHttpMethod_ReturnsActivityDisplayName)); using var activity = activitySource.StartActivity( ActivityName, ActivityKind.Server); @@ -83,18 +83,18 @@ public void GetV2OperationName_WithNullHttpMethod_ReturnsActivityDisplayName(str AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeHttpRoute, httpRoute)); // Act - var result = TraceHelper.GetV2OperationName(activity!, url, ref tagObjects); + var result = TraceHelper.GetNewSchemaOperationName(activity!, url, ref tagObjects); // Assert Assert.Equal(ActivityName, result); } [Fact] - public void GetV2OperationName_WithNullHttpRoute_ReturnsActivityDisplayName() + public void GetNewOperationName_WithNullHttpRoute_ReturnsActivityDisplayName() { // Arrange - using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddSource(nameof(GetV2OperationName_WithNullHttpRoute_ReturnsActivityDisplayName)).Build(); - using var activitySource = new ActivitySource(nameof(GetV2OperationName_WithNullHttpRoute_ReturnsActivityDisplayName)); + using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddSource(nameof(GetNewOperationName_WithNullHttpRoute_ReturnsActivityDisplayName)).Build(); + using var activitySource = new ActivitySource(nameof(GetNewOperationName_WithNullHttpRoute_ReturnsActivityDisplayName)); using var activity = activitySource.StartActivity( ActivityName, ActivityKind.Server); @@ -104,18 +104,18 @@ public void GetV2OperationName_WithNullHttpRoute_ReturnsActivityDisplayName() AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeHttpRequestMethod, "POST")); // Act - var result = TraceHelper.GetV2OperationName(activity!, url: null, ref tagObjects); + var result = TraceHelper.GetNewSchemaOperationName(activity!, url: null, ref tagObjects); // Assert Assert.Equal(ActivityName, result); } [Fact] - public void GetV2OperationName_WithNullUrl_ReturnsFormattedStringFromMappedTags() + public void GetNewOperationName_WithNullUrl_ReturnsFormattedStringFromMappedTags() { // Arrange - using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddSource(nameof(GetV2OperationName_WithNullUrl_ReturnsFormattedStringFromMappedTags)).Build(); - using var activitySource = new ActivitySource(nameof(GetV2OperationName_WithNullUrl_ReturnsFormattedStringFromMappedTags)); + using var tracerProvider = Sdk.CreateTracerProviderBuilder().AddSource(nameof(GetNewOperationName_WithNullUrl_ReturnsFormattedStringFromMappedTags)).Build(); + using var activitySource = new ActivitySource(nameof(GetNewOperationName_WithNullUrl_ReturnsFormattedStringFromMappedTags)); using var activity = activitySource.StartActivity( ActivityName, ActivityKind.Server); @@ -126,7 +126,7 @@ public void GetV2OperationName_WithNullUrl_ReturnsFormattedStringFromMappedTags( AzMonList.Add(ref tagObjects, new KeyValuePair(SemanticConventions.AttributeHttpRoute, "/api/test")); // Act - var result = TraceHelper.GetV2OperationName(activity!, null, ref tagObjects); + var result = TraceHelper.GetNewSchemaOperationName(activity!, null, ref tagObjects); // Assert Assert.Equal("GET /api/test", result);