diff --git a/Directory.Build.props b/Directory.Build.props index 50e90feb06..6fd763199e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -3,7 +3,7 @@ 3.46.0 3.47.0 preview.0 - 3.37.1 + 3.37.2 2.0.4 2.1.0 preview4 diff --git a/Microsoft.Azure.Cosmos/src/DocumentClient.cs b/Microsoft.Azure.Cosmos/src/DocumentClient.cs index 984ad0371a..8371d3ea6f 100644 --- a/Microsoft.Azure.Cosmos/src/DocumentClient.cs +++ b/Microsoft.Azure.Cosmos/src/DocumentClient.cs @@ -959,7 +959,8 @@ internal virtual void Initialize(Uri serviceEndpoint, if (this.cosmosClientTelemetryOptions.IsClientMetricsEnabled) { CosmosDbOperationMeter.Initialize(); - + CosmosDbNetworkMeter.Initialize(); + CosmosDbOperationMeter.AddInstanceCount(this.ServiceEndpoint); } diff --git a/Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs b/Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs index 0c0768a8a9..6da7d745c2 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs @@ -533,17 +533,23 @@ private async Task RunWithDiagnosticsHelperAsync( && (!this.ClientOptions.CosmosClientTelemetryOptions.DisableDistributedTracing || this.ClientOptions.CosmosClientTelemetryOptions.IsClientMetricsEnabled)) { // Extracts and records telemetry data from the result of the operation. - OpenTelemetryAttributes response = openTelemetry?.Item2(result); + OpenTelemetryAttributes otelAttributes = openTelemetry?.Item2(result); // Records the telemetry attributes for Distributed Tracing (if enabled) - recorder.Record(response); + recorder.Record(otelAttributes); // Records metrics such as request units, latency, and item count for the operation. CosmosDbOperationMeter.RecordTelemetry(getOperationName: getOperationName, accountName: this.client.Endpoint, containerName: containerName, databaseName: databaseName, - attributes: response); + attributes: otelAttributes); + + CosmosDbNetworkMeter.RecordTelemetry(getOperationName: getOperationName, + accountName: this.client.Endpoint, + containerName: containerName, + databaseName: databaseName, + attributes: otelAttributes); } return result; } @@ -584,6 +590,12 @@ private async Task RunWithDiagnosticsHelperAsync( containerName: containerName, databaseName: databaseName, ex: cosmosException); + CosmosDbNetworkMeter.RecordTelemetry(getOperationName: getOperationName, + accountName: this.client.Endpoint, + containerName: containerName, + databaseName: databaseName, + ex: cosmosException); + } throw; diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/AppInsightClassicAttributeKeys.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/AppInsightClassicAttributeKeys.cs index daf1b31cbe..32759464af 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/AppInsightClassicAttributeKeys.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/AppInsightClassicAttributeKeys.cs @@ -7,6 +7,7 @@ namespace Microsoft.Azure.Cosmos.Telemetry using System; using System.Collections.Generic; using global::Azure.Core; + using Microsoft.Azure.Cosmos.Tracing.TraceData; internal sealed class AppInsightClassicAttributeKeys : IActivityAttributePopulator { @@ -162,12 +163,29 @@ public void PopulateAttributes(DiagnosticScope scope, QueryTextMode? queryTextMo } } + public KeyValuePair[] PopulateNetworkMeterDimensions(string operationName, Uri accountName, string containerName, string databaseName, OpenTelemetryAttributes attributes, CosmosException ex, ClientSideRequestStatisticsTraceDatum.StoreResponseStatistics tcpStats = null, ClientSideRequestStatisticsTraceDatum.HttpResponseStatistics? httpStats = null) + { + return new KeyValuePair[] + { + new KeyValuePair(AppInsightClassicAttributeKeys.ContainerName, containerName), + new KeyValuePair(AppInsightClassicAttributeKeys.DbName, databaseName), + new KeyValuePair(AppInsightClassicAttributeKeys.ServerAddress, accountName?.Host), + new KeyValuePair(AppInsightClassicAttributeKeys.DbOperation, operationName), + new KeyValuePair(AppInsightClassicAttributeKeys.StatusCode, (int)(attributes?.StatusCode ?? ex?.StatusCode)), + new KeyValuePair(AppInsightClassicAttributeKeys.SubStatusCode, attributes?.SubStatusCode ?? ex?.SubStatusCode) + }; + } + public KeyValuePair[] PopulateOperationMeterDimensions(string operationName, string containerName, string databaseName, Uri accountName, OpenTelemetryAttributes attributes, CosmosException ex) { return new KeyValuePair[] { new KeyValuePair(AppInsightClassicAttributeKeys.ContainerName, containerName), new KeyValuePair(AppInsightClassicAttributeKeys.DbName, databaseName), + new KeyValuePair(AppInsightClassicAttributeKeys.ServerAddress, accountName?.Host), + new KeyValuePair(AppInsightClassicAttributeKeys.DbOperation, operationName), + new KeyValuePair(AppInsightClassicAttributeKeys.StatusCode, (int)(attributes?.StatusCode ?? ex?.StatusCode)), + new KeyValuePair(AppInsightClassicAttributeKeys.SubStatusCode, attributes?.SubStatusCode ?? ex?.SubStatusCode), new KeyValuePair(AppInsightClassicAttributeKeys.ServerAddress, accountName.Host), new KeyValuePair(AppInsightClassicAttributeKeys.DbOperation, operationName), new KeyValuePair(AppInsightClassicAttributeKeys.StatusCode, (int)(attributes?.StatusCode ?? ex?.StatusCode)), diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbClientMetrics.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbClientMetrics.cs index f295022504..bcaf0818fe 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbClientMetrics.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbClientMetrics.cs @@ -12,7 +12,7 @@ namespace Microsoft.Azure.Cosmos public sealed class CosmosDbClientMetrics { /// - /// OperationMetrics + /// Operation Metrics /// public static class OperationMetrics { @@ -101,6 +101,120 @@ public static class Description } } + /// + /// Network Metrics + /// + public static class NetworkMetrics + { + /// + /// the name of the operation meter + /// + public const string MeterName = "Azure.Cosmos.Client.Request"; + + /// + /// Version of the operation meter + /// + public const string Version = "1.0.0"; + + /// + /// Metric Names + /// + public static class Name + { + /// + /// Network Call Latency + /// + public const string Latency = "db.client.cosmosdb.request.duration"; + + /// + /// Request Payload Size + /// + public const string RequestBodySize = "db.client.cosmosdb.request.body.size"; + + /// + /// Request Payload Size + /// + public const string ResponseBodySize = "db.client.cosmosdb.response.body.size"; + + /// + /// Channel Aquisition Latency + /// + public const string ChannelAquisitionLatency = "db.client.cosmosdb.request.channel_aquisition.duration"; + + /// + /// Backend Server Latency + /// + public const string BackendLatency = "db.server.cosmosdb.request.duration"; + + /// + /// Transit Time Latency + /// + public const string TransitTimeLatency = "db.client.cosmosdb.request.transit.duration"; + + /// + /// Received Time Latency + /// + public const string ReceivedTimeLatency = "db.client.cosmosdb.request.received.duration"; + } + + /// + /// Unit for metrics + /// + public static class Unit + { + /// + /// Unit representing bytes + /// + public const string Bytes = "bytes"; + + /// + /// Unit representing time in seconds + /// + public const string Sec = "s"; + } + + /// + /// Provides descriptions for metrics. + /// + public static class Description + { + /// + /// Network Call Latency + /// + public const string Latency = "Duration of client requests."; + + /// + /// Request Payload Size + /// + public const string RequestBodySize = "Size of client request body."; + + /// + /// Request Payload Size + /// + public const string ResponseBodySize = "Size of client response body."; + + /// + /// Channel Aquisition Latency + /// + public const string ChannelAquisitionLatency = "The duration of the successfully established outbound TCP connections. i.e. Channel Aquisition Time (for direct mode)."; + + /// + /// Backend Server Latency + /// + public const string BackendLatency = "Backend Latency (for direct mode)."; + + /// + /// Transit Time Latency + /// + public const string TransitTimeLatency = "Time spent on the wire (for direct mode)."; + + /// + /// Received Time Latency + /// + public const string ReceivedTimeLatency = "Time spent on 'Received' stage (for direct mode)."; + } + } + /// /// Buckets /// diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbNetworkMeter.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbNetworkMeter.cs new file mode 100644 index 0000000000..5e1b3d417f --- /dev/null +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbNetworkMeter.cs @@ -0,0 +1,148 @@ +// ------------------------------------------------------------ +// Copyright (c) Microsoft Corporation. All rights reserved. +// ------------------------------------------------------------ + +namespace Microsoft.Azure.Cosmos.Telemetry +{ + using System; + using System.Collections.Generic; + using System.Diagnostics.Metrics; + using Microsoft.Azure.Cosmos.Diagnostics; + using Microsoft.Azure.Cosmos.Tracing.TraceData; + + internal static class CosmosDbNetworkMeter + { + /// + /// Meter instance for capturing various metrics related to Cosmos DB operations. + /// + private static readonly Meter NetworkMeter = new Meter(CosmosDbClientMetrics.NetworkMetrics.MeterName, CosmosDbClientMetrics.NetworkMetrics.Version); + + /// + /// Populator Used for Dimension Attributes + /// + private static readonly IActivityAttributePopulator DimensionPopulator = TracesStabilityFactory.GetAttributePopulator(); + + private static Histogram RequestLatencyHistogram = null; + + private static Histogram RequestBodySizeHistogram = null; + + private static Histogram ResponseBodySizeHistogram = null; + + private static Histogram ChannelAquisitionLatencyHistogram = null; + + private static Histogram BackendLatencyHistogram = null; + + private static Histogram TransitLatencyHistogram = null; + + private static Histogram ReceivedLatencyHistogram = null; + + private static bool IsEnabled = false; + + /// + /// Initializes the histograms and counters for capturing Cosmos DB metrics. + /// + internal static void Initialize() + { + // If already initialized, do not initialize again + if (IsEnabled) + { + return; + } + + CosmosDbNetworkMeter.RequestLatencyHistogram ??= NetworkMeter.CreateHistogram(name: CosmosDbClientMetrics.NetworkMetrics.Name.Latency, + unit: CosmosDbClientMetrics.NetworkMetrics.Unit.Sec, + description: CosmosDbClientMetrics.NetworkMetrics.Description.Latency); + + CosmosDbNetworkMeter.RequestBodySizeHistogram ??= NetworkMeter.CreateHistogram(name: CosmosDbClientMetrics.NetworkMetrics.Name.RequestBodySize, + unit: CosmosDbClientMetrics.NetworkMetrics.Unit.Bytes, + description: CosmosDbClientMetrics.NetworkMetrics.Description.RequestBodySize); + + CosmosDbNetworkMeter.ResponseBodySizeHistogram ??= NetworkMeter.CreateHistogram(name: CosmosDbClientMetrics.NetworkMetrics.Name.ResponseBodySize, + unit: CosmosDbClientMetrics.NetworkMetrics.Unit.Bytes, + description: CosmosDbClientMetrics.NetworkMetrics.Description.ResponseBodySize); + + CosmosDbNetworkMeter.ChannelAquisitionLatencyHistogram ??= NetworkMeter.CreateHistogram(name: CosmosDbClientMetrics.NetworkMetrics.Name.ChannelAquisitionLatency, + unit: CosmosDbClientMetrics.NetworkMetrics.Unit.Sec, + description: CosmosDbClientMetrics.NetworkMetrics.Description.ChannelAquisitionLatency); + + CosmosDbNetworkMeter.BackendLatencyHistogram ??= NetworkMeter.CreateHistogram(name: CosmosDbClientMetrics.NetworkMetrics.Name.BackendLatency, + unit: CosmosDbClientMetrics.NetworkMetrics.Unit.Sec, + description: CosmosDbClientMetrics.NetworkMetrics.Description.BackendLatency); + + CosmosDbNetworkMeter.TransitLatencyHistogram ??= NetworkMeter.CreateHistogram(name: CosmosDbClientMetrics.NetworkMetrics.Name.TransitTimeLatency, + unit: CosmosDbClientMetrics.NetworkMetrics.Unit.Sec, + description: CosmosDbClientMetrics.NetworkMetrics.Description.TransitTimeLatency); + + CosmosDbNetworkMeter.ReceivedLatencyHistogram ??= NetworkMeter.CreateHistogram(name: CosmosDbClientMetrics.NetworkMetrics.Name.ReceivedTimeLatency, + unit: CosmosDbClientMetrics.NetworkMetrics.Unit.Sec, + description: CosmosDbClientMetrics.NetworkMetrics.Description.ReceivedTimeLatency); + + IsEnabled = true; + } + + internal static void RecordTelemetry(Func getOperationName, + Uri accountName, + string containerName, + string databaseName, + OpenTelemetryAttributes attributes = null, + CosmosException ex = null) + { + if (!IsEnabled) + { + return; + } + + SummaryDiagnostics summaryDiagnostics + = new SummaryDiagnostics(((CosmosTraceDiagnostics)(ex?.Diagnostics ?? attributes?.Diagnostics)).Value); + summaryDiagnostics.StoreResponseStatistics.Value.ForEach(stat => + { + if (stat?.StoreResult == null) + { + return; + } + + Func[]> dimensionsFunc = () => DimensionPopulator.PopulateNetworkMeterDimensions( + getOperationName(), accountName, containerName, databaseName, attributes, ex, tcpStats: stat); + + CosmosDbMeterUtil.RecordHistogramMetric(stat.RequestLatency.TotalSeconds, dimensionsFunc, RequestLatencyHistogram); + CosmosDbMeterUtil.RecordHistogramMetric(stat?.StoreResult?.TransportRequestStats?.RequestBodySizeInBytes, dimensionsFunc, RequestBodySizeHistogram); + CosmosDbMeterUtil.RecordHistogramMetric(stat?.StoreResult?.TransportRequestStats?.ResponseBodySizeInBytes, dimensionsFunc, ResponseBodySizeHistogram); + CosmosDbMeterUtil.RecordHistogramMetric(stat?.StoreResult?.BackendRequestDurationInMs, dimensionsFunc, BackendLatencyHistogram, (value) => Convert.ToDouble(value) / 1000); + CosmosDbMeterUtil.RecordHistogramMetric(CalculateLatency( + stat?.StoreResult?.TransportRequestStats?.channelAcquisitionStartedTime, + stat?.StoreResult?.TransportRequestStats?.requestPipelinedTime, + stat?.StoreResult?.TransportRequestStats?.requestFailedTime), + dimensionsFunc, ChannelAquisitionLatencyHistogram); + CosmosDbMeterUtil.RecordHistogramMetric(CalculateLatency( + stat?.StoreResult?.TransportRequestStats?.requestSentTime, + stat?.StoreResult?.TransportRequestStats?.requestReceivedTime, + stat?.StoreResult?.TransportRequestStats?.requestFailedTime), + dimensionsFunc, TransitLatencyHistogram); + CosmosDbMeterUtil.RecordHistogramMetric(CalculateLatency( + stat?.StoreResult?.TransportRequestStats?.requestReceivedTime, + stat?.StoreResult?.TransportRequestStats?.requestCompletedTime, + stat?.StoreResult?.TransportRequestStats?.requestFailedTime), + dimensionsFunc, ReceivedLatencyHistogram); + }); + + summaryDiagnostics.HttpResponseStatistics.Value.ForEach(stat => + { + Func[]> dimensionsFunc = () => DimensionPopulator.PopulateNetworkMeterDimensions( + getOperationName(), accountName, containerName, databaseName, attributes, ex, httpStats: stat); + + CosmosDbMeterUtil.RecordHistogramMetric(stat.Duration.TotalSeconds, dimensionsFunc, RequestLatencyHistogram); + CosmosDbMeterUtil.RecordHistogramMetric(stat.HttpResponseMessage?.RequestMessage?.Content?.Headers?.ContentLength, dimensionsFunc, RequestBodySizeHistogram); + CosmosDbMeterUtil.RecordHistogramMetric(stat.ResponseContentLength, dimensionsFunc, ResponseBodySizeHistogram); + }); + } + + private static double? CalculateLatency( + TimeSpan? start, + TimeSpan? end, + TimeSpan? failed) + { + TimeSpan? requestend = end ?? failed; + return start.HasValue && requestend.HasValue ? (requestend.Value - start.Value).TotalSeconds : (double?)null; + } + } +} diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbOperationMeter.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbOperationMeter.cs index 9dfecbd9e2..1af71042e7 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbOperationMeter.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbOperationMeter.cs @@ -8,7 +8,6 @@ namespace Microsoft.Azure.Cosmos.Telemetry using System.Collections.Generic; using System.Diagnostics.Metrics; using Microsoft.Azure.Cosmos.Core.Trace; - using Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry; /// /// CosmosOperationMeter is a utility class responsible for collecting and recording telemetry metrics related to Cosmos DB operations. diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/DatabaseDupAttributeKeys.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/DatabaseDupAttributeKeys.cs index 9cbb173ad8..a133d94718 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/DatabaseDupAttributeKeys.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/DatabaseDupAttributeKeys.cs @@ -8,6 +8,7 @@ namespace Microsoft.Azure.Cosmos.Telemetry using System.Collections.Generic; using System.Linq; using global::Azure.Core; + using Microsoft.Azure.Cosmos.Tracing.TraceData; internal class DatabaseDupAttributeKeys : IActivityAttributePopulator { @@ -38,6 +39,30 @@ public void PopulateAttributes(DiagnosticScope scope, QueryTextMode? queryTextMo this.otelPopulator.PopulateAttributes(scope, queryTextMode, operationType, response); } + public KeyValuePair[] PopulateNetworkMeterDimensions(string operationName, + Uri accountName, + string containerName, + string databaseName, + OpenTelemetryAttributes attributes, + CosmosException ex, + ClientSideRequestStatisticsTraceDatum.StoreResponseStatistics tcpStats = null, + ClientSideRequestStatisticsTraceDatum.HttpResponseStatistics? httpStats = null) + { + KeyValuePair[] appInsightDimensions = this.appInsightPopulator + .PopulateNetworkMeterDimensions(operationName, accountName, containerName, databaseName, attributes, ex, tcpStats, httpStats) + .ToArray(); + KeyValuePair[] otelDimensions = this.otelPopulator + .PopulateNetworkMeterDimensions(operationName, accountName, containerName, databaseName, attributes, ex, tcpStats, httpStats) + .ToArray(); + + KeyValuePair[] dimensions + = new KeyValuePair[appInsightDimensions.Length + otelDimensions.Length]; + dimensions + .Concat(appInsightDimensions) + .Concat(otelDimensions); + return dimensions; + } + public KeyValuePair[] PopulateOperationMeterDimensions(string operationName, string containerName, string databaseName, diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/IActivityAttributePopulator.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/IActivityAttributePopulator.cs index f7ad05f36a..edd7b3c350 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/IActivityAttributePopulator.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/IActivityAttributePopulator.cs @@ -6,8 +6,8 @@ namespace Microsoft.Azure.Cosmos.Telemetry { using System; using System.Collections.Generic; - using System.Xml.Linq; using global::Azure.Core; + using Microsoft.Azure.Cosmos.Tracing.TraceData; internal interface IActivityAttributePopulator { @@ -33,5 +33,14 @@ public KeyValuePair[] PopulateOperationMeterDimensions(string op string databaseName, Uri accountName, OpenTelemetryAttributes attributes, CosmosException ex); + + public KeyValuePair[] PopulateNetworkMeterDimensions(string operationName, + Uri accountName, + string containerName, + string databaseName, + OpenTelemetryAttributes attributes, + CosmosException ex, + ClientSideRequestStatisticsTraceDatum.StoreResponseStatistics tcpStats = null, + ClientSideRequestStatisticsTraceDatum.HttpResponseStatistics? httpStats = null); } } diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryAttributeKeys.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryAttributeKeys.cs index e6b822ca90..e4d4bb2329 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryAttributeKeys.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryAttributeKeys.cs @@ -4,11 +4,11 @@ namespace Microsoft.Azure.Cosmos.Telemetry { - using System; + using System; using System.Collections.Generic; using System.Linq; using global::Azure.Core; - using Microsoft.Azure.Cosmos.Diagnostics; + using Microsoft.Azure.Cosmos.Tracing.TraceData; /// /// Contains constant string values representing OpenTelemetry attribute keys for monitoring and tracing Cosmos DB operations. @@ -170,6 +170,20 @@ internal sealed class OpenTelemetryAttributeKeys : IActivityAttributePopulator /// public const string ExceptionStacktrace = "exception.stacktrace"; + public const string NetworkProtocolName = "network.protocol.name"; + + public const string ServiceEndpointHost = "network.protocol.host"; + + public const string ServiceEndPointPort = "network.protocol.port"; + + public const string ServiceEndpointStatusCode = "db.cosmosdb.network.response.status_code"; + + public const string ServiceEndpointSubStatusCode = "db.cosmosdb.network.response.sub_status_code"; + + public const string ServiceEndpointRegion = "cloud.region"; + + public const string ServiceEndpointResourceId = "db.cosmosdb.network.routing_id "; + /// /// Represents the type of error. /// @@ -247,7 +261,38 @@ public void PopulateAttributes(DiagnosticScope scope, QueryTextMode? queryTextMo OpenTelemetryAttributeKeys.Region, GetRegions(response.Diagnostics), (input) => string.Join(",", input)); } - + + } + + public KeyValuePair[] PopulateNetworkMeterDimensions(string operationName, + Uri accountName, + string containerName, + string databaseName, + OpenTelemetryAttributes attributes, + CosmosException ex, + ClientSideRequestStatisticsTraceDatum.StoreResponseStatistics tcpStats = null, + ClientSideRequestStatisticsTraceDatum.HttpResponseStatistics? httpStats = null) + { + return new KeyValuePair[] + { + new KeyValuePair(OpenTelemetryAttributeKeys.DbSystemName, OpenTelemetryCoreRecorder.CosmosDb), + new KeyValuePair(OpenTelemetryAttributeKeys.ContainerName, containerName), + new KeyValuePair(OpenTelemetryAttributeKeys.DbName, databaseName), + new KeyValuePair(OpenTelemetryAttributeKeys.ServerAddress, accountName?.Host), + new KeyValuePair(OpenTelemetryAttributeKeys.ServerPort, accountName?.Port), + new KeyValuePair(OpenTelemetryAttributeKeys.DbOperation, operationName), + new KeyValuePair(OpenTelemetryAttributeKeys.StatusCode, (int)(attributes?.StatusCode ?? ex?.StatusCode)), + new KeyValuePair(OpenTelemetryAttributeKeys.SubStatusCode, attributes?.SubStatusCode ?? ex?.SubStatusCode), + new KeyValuePair(OpenTelemetryAttributeKeys.ConsistencyLevel, attributes?.ConsistencyLevel ?? ex?.Headers?.ConsistencyLevel), + new KeyValuePair(OpenTelemetryAttributeKeys.NetworkProtocolName, GetEndpoint(tcpStats, httpStats).Scheme), + new KeyValuePair(OpenTelemetryAttributeKeys.ServiceEndpointHost, GetEndpoint(tcpStats, httpStats).Host), + new KeyValuePair(OpenTelemetryAttributeKeys.ServiceEndPointPort, GetEndpoint(tcpStats, httpStats).Port), + new KeyValuePair(OpenTelemetryAttributeKeys.ServiceEndpointResourceId, GetEndpoint(tcpStats, httpStats).PathAndQuery), + new KeyValuePair(OpenTelemetryAttributeKeys.ServiceEndpointStatusCode, GetStatusCode(tcpStats, httpStats)), + new KeyValuePair(OpenTelemetryAttributeKeys.ServiceEndpointSubStatusCode, GetSubStatusCode(tcpStats, httpStats)), + new KeyValuePair(OpenTelemetryAttributeKeys.ServiceEndpointRegion, GetRegion(tcpStats, httpStats)), + new KeyValuePair(OpenTelemetryAttributeKeys.ErrorType, GetException(tcpStats, httpStats)) + }; } public KeyValuePair[] PopulateOperationMeterDimensions(string operationName, @@ -281,5 +326,41 @@ private static string[] GetRegions(CosmosDiagnostics diagnostics) .Distinct() .ToArray(); } + + private static int? GetStatusCode(ClientSideRequestStatisticsTraceDatum.StoreResponseStatistics tcpStats, ClientSideRequestStatisticsTraceDatum.HttpResponseStatistics? httpStats) + { + return (int?)httpStats?.HttpResponseMessage?.StatusCode ?? (int?)tcpStats?.StoreResult?.StatusCode; + } + + private static Uri GetEndpoint(ClientSideRequestStatisticsTraceDatum.StoreResponseStatistics tcpStats, ClientSideRequestStatisticsTraceDatum.HttpResponseStatistics? httpStats) + { + return httpStats?.RequestUri ?? tcpStats?.LocationEndpoint; + } + + private static string GetRegion(ClientSideRequestStatisticsTraceDatum.StoreResponseStatistics tcpStats, ClientSideRequestStatisticsTraceDatum.HttpResponseStatistics? httpStats) + { + return httpStats?.Region ?? tcpStats.Region; + } + + private static string GetException(ClientSideRequestStatisticsTraceDatum.StoreResponseStatistics tcpStats, ClientSideRequestStatisticsTraceDatum.HttpResponseStatistics? httpStats) + { + return httpStats?.Exception?.Message ?? tcpStats?.StoreResult?.Exception?.Message; + } + + private static int GetSubStatusCode(ClientSideRequestStatisticsTraceDatum.StoreResponseStatistics tcpStats, ClientSideRequestStatisticsTraceDatum.HttpResponseStatistics? httpStats) + { + int? subStatuscode = null; + if (httpStats.HasValue && + httpStats.Value.HttpResponseMessage?.Headers != null && + httpStats.Value + .HttpResponseMessage + .Headers + .TryGetValues(Documents.WFConstants.BackendHeaders.SubStatus, out IEnumerable statuscodes)) + { + subStatuscode = Convert.ToInt32(statuscodes.FirstOrDefault()); + } + + return subStatuscode ?? Convert.ToInt32(tcpStats?.StoreResult?.SubStatusCode); + } } } diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryAttributes.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryAttributes.cs index 3206266291..f5b491c65f 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryAttributes.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryAttributes.cs @@ -5,6 +5,7 @@ namespace Microsoft.Azure.Cosmos.Telemetry { using System.Net; + using Microsoft.Azure.Cosmos.Diagnostics; using Microsoft.Azure.Cosmos.Query.Core; internal class OpenTelemetryAttributes diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/TracesStabilityFactory.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/TracesStabilityFactory.cs index 70398310fd..82b1ee905f 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/TracesStabilityFactory.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/TracesStabilityFactory.cs @@ -2,7 +2,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. //------------------------------------------------------------ -namespace Microsoft.Azure.Cosmos.Telemetry.OpenTelemetry +namespace Microsoft.Azure.Cosmos.Telemetry { using System; diff --git a/Microsoft.Azure.Cosmos/src/Tracing/TraceData/ClientSideRequestStatisticsTraceDatum.cs b/Microsoft.Azure.Cosmos/src/Tracing/TraceData/ClientSideRequestStatisticsTraceDatum.cs index 829899c4b1..5c45957081 100644 --- a/Microsoft.Azure.Cosmos/src/Tracing/TraceData/ClientSideRequestStatisticsTraceDatum.cs +++ b/Microsoft.Azure.Cosmos/src/Tracing/TraceData/ClientSideRequestStatisticsTraceDatum.cs @@ -12,6 +12,7 @@ namespace Microsoft.Azure.Cosmos.Tracing.TraceData using System.Text; using Microsoft.Azure.Cosmos.Handler; using Microsoft.Azure.Cosmos.Json; + using Microsoft.Azure.Cosmos.Pagination; using Microsoft.Azure.Documents; using Microsoft.Azure.Documents.Rntbd; @@ -260,7 +261,8 @@ public void RecordResponse( request.ResourceType, request.OperationType, request.Headers[HttpConstants.HttpHeaders.SessionToken], - locationEndpoint); + locationEndpoint, + regionName); lock (this.storeResponseStatistics) { @@ -352,8 +354,9 @@ public void RecordHttpResponse(HttpRequestMessage request, lock (this.httpResponseStatistics) { Uri locationEndpoint = request.RequestUri; + object regionName = null; if (request.Properties != null && - request.Properties.TryGetValue(HttpRequestRegionNameProperty, out object regionName)) + request.Properties.TryGetValue(HttpRequestRegionNameProperty, out regionName)) { this.TraceSummary.AddRegionContacted(Convert.ToString(regionName), locationEndpoint); } @@ -365,7 +368,8 @@ public void RecordHttpResponse(HttpRequestMessage request, request.Method, resourceType, response, - exception: null)); + exception: null, + region: Convert.ToString(regionName))); } } @@ -380,8 +384,10 @@ public void RecordHttpException(HttpRequestMessage request, lock (this.httpResponseStatistics) { Uri locationEndpoint = request.RequestUri; + + object regionName = null; if (request.Properties != null && - request.Properties.TryGetValue(HttpRequestRegionNameProperty, out object regionName)) + request.Properties.TryGetValue(HttpRequestRegionNameProperty, out regionName)) { this.TraceSummary.AddRegionContacted(Convert.ToString(regionName), locationEndpoint); } @@ -393,7 +399,8 @@ public void RecordHttpException(HttpRequestMessage request, request.Method, resourceType, responseMessage: null, - exception: exception)); + exception: exception, + region: Convert.ToString(regionName))); } } @@ -460,7 +467,8 @@ public StoreResponseStatistics( ResourceType resourceType, OperationType operationType, string requestSessionToken, - Uri locationEndpoint) + Uri locationEndpoint, + string region) { this.RequestStartTime = requestStartTime; this.RequestResponseTime = requestResponseTime; @@ -470,8 +478,10 @@ public StoreResponseStatistics( this.RequestSessionToken = requestSessionToken; this.LocationEndpoint = locationEndpoint; this.IsSupplementalResponse = operationType == OperationType.Head || operationType == OperationType.HeadFeed; + this.Region = region; } + public string Region { get; } public DateTime? RequestStartTime { get; } public DateTime RequestResponseTime { get; } public StoreResult StoreResult { get; } @@ -492,7 +502,8 @@ public HttpResponseStatistics( HttpMethod httpMethod, ResourceType resourceType, HttpResponseMessage responseMessage, - Exception exception) + Exception exception, + string region) { this.RequestStartTime = requestStartTime; this.Duration = requestEndTime - requestStartTime; @@ -501,7 +512,8 @@ public HttpResponseStatistics( this.ResourceType = resourceType; this.HttpMethod = httpMethod; this.RequestUri = requestUri; - + this.Region = region; + this.ResponseContentLength = responseMessage?.Content?.Headers?.ContentLength; if (responseMessage != null) { Headers headers = new Headers(GatewayStoreClient.ExtractResponseHeaders(responseMessage)); @@ -513,6 +525,7 @@ public HttpResponseStatistics( } } + public string Region { get; } public DateTime RequestStartTime { get; } public TimeSpan Duration { get; } public HttpResponseMessage HttpResponseMessage { get; } @@ -521,6 +534,7 @@ public HttpResponseStatistics( public HttpMethod HttpMethod { get; } public Uri RequestUri { get; } public string ActivityId { get; } + public long? ResponseContentLength { get; } } } } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Metrics/CustomMetricExporter.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Metrics/CustomMetricExporter.cs index 19024ae825..c253f0aa84 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Metrics/CustomMetricExporter.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Metrics/CustomMetricExporter.cs @@ -16,7 +16,27 @@ namespace Microsoft.Azure.Cosmos.SDK.EmulatorTests.Metrics public class CustomMetricExporter : BaseExporter { private readonly ManualResetEventSlim manualResetEventSlim = null; - private readonly static List expectedDimensions = new() + + internal static readonly Dictionary expectedOperationMetrics = new Dictionary() + { + { "db.client.operation.duration", MetricType.Histogram }, + { "db.client.response.row_count", MetricType.Histogram}, + { "db.client.cosmosdb.operation.request_charge", MetricType.Histogram }, + { "db.client.cosmosdb.active_instance.count", MetricType.LongSumNonMonotonic } + }; + + internal static readonly Dictionary expectedNetworkMetrics = new Dictionary() + { + { "db.client.cosmosdb.request.duration", MetricType.Histogram}, + { "db.client.cosmosdb.request.body.size", MetricType.Histogram}, + { "db.client.cosmosdb.response.body.size", MetricType.Histogram}, + { "db.server.cosmosdb.request.duration", MetricType.Histogram}, + { "db.client.cosmosdb.request.channel_aquisition.duration", MetricType.Histogram}, + { "db.client.cosmosdb.request.transit.duration", MetricType.Histogram}, + { "db.client.cosmosdb.request.received.duration", MetricType.Histogram} + }; + + private readonly static List expectedOperationDimensions = new() { OpenTelemetryAttributeKeys.DbSystemName, OpenTelemetryAttributeKeys.ContainerName, @@ -31,6 +51,27 @@ public class CustomMetricExporter : BaseExporter OpenTelemetryAttributeKeys.ErrorType }; + private readonly static List expectedNetworkDimensions = new() + { + OpenTelemetryAttributeKeys.DbSystemName, + OpenTelemetryAttributeKeys.ContainerName, + OpenTelemetryAttributeKeys.DbName, + OpenTelemetryAttributeKeys.ServerAddress, + OpenTelemetryAttributeKeys.ServerPort, + OpenTelemetryAttributeKeys.DbOperation, + OpenTelemetryAttributeKeys.StatusCode, + OpenTelemetryAttributeKeys.SubStatusCode, + OpenTelemetryAttributeKeys.ConsistencyLevel, + OpenTelemetryAttributeKeys.NetworkProtocolName, + OpenTelemetryAttributeKeys.ServiceEndpointHost, + OpenTelemetryAttributeKeys.ServiceEndPointPort, + OpenTelemetryAttributeKeys.ServiceEndpointResourceId, + OpenTelemetryAttributeKeys.ServiceEndpointStatusCode, + OpenTelemetryAttributeKeys.ServiceEndpointSubStatusCode, + OpenTelemetryAttributeKeys.ServiceEndpointRegion, + OpenTelemetryAttributeKeys.ErrorType + }; + private readonly static List expectedDimensionsForInstanceCountMetrics = new() { OpenTelemetryAttributeKeys.DbSystemName, @@ -66,9 +107,13 @@ public override ExportResult Export(in Batch batch) { CollectionAssert.AreEquivalent(expectedDimensionsForInstanceCountMetrics, actualDimensions.ToList(), $"Dimensions are not matching for {metric.Name}"); } - else + else if (expectedOperationMetrics.ContainsKey(metric.Name)) + { + CollectionAssert.AreEquivalent(expectedOperationDimensions, actualDimensions.ToList(), $"Dimensions are not matching for {metric.Name}"); + } + else if (expectedNetworkMetrics.ContainsKey(metric.Name)) { - CollectionAssert.AreEquivalent(expectedDimensions, actualDimensions.ToList(), $"Dimensions are not matching for {metric.Name}"); + CollectionAssert.AreEquivalent(expectedNetworkDimensions, actualDimensions.ToList(), $"Dimensions are not matching for {metric.Name}"); } } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Metrics/OpenTelemetryMetricsTest.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Metrics/OpenTelemetryMetricsTest.cs index b1789176aa..36de7175d7 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Metrics/OpenTelemetryMetricsTest.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Metrics/OpenTelemetryMetricsTest.cs @@ -20,13 +20,10 @@ public class OpenTelemetryMetricsTest : BaseCosmosClientHelper private const int AggregatingInterval = 500; private readonly ManualResetEventSlim manualResetEventSlim = new ManualResetEventSlim(false); - private static readonly Dictionary expectedMetrics = new Dictionary() - { - { "db.client.operation.duration", MetricType.Histogram }, - { "db.client.response.row_count", MetricType.Histogram}, - { "db.client.cosmosdb.operation.request_charge", MetricType.Histogram }, - { "db.client.cosmosdb.active_instance.count", MetricType.LongSumNonMonotonic } - }; + + private static readonly Dictionary expectedMetrics = CustomMetricExporter.expectedOperationMetrics + .Concat(CustomMetricExporter.expectedNetworkMetrics) + .ToDictionary(kv => kv.Key, kv => kv.Value); private MeterProvider meterProvider; [TestInitialize] @@ -35,8 +32,8 @@ public async Task Init() // Initialize OpenTelemetry MeterProvider this.meterProvider = Sdk .CreateMeterProviderBuilder() - .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("Azure Cosmos DB Operation Level Metrics")) - .AddMeter(CosmosDbClientMetrics.OperationMetrics.MeterName) + .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("Azure Cosmos DB Metrics")) + .AddMeter(CosmosDbClientMetrics.OperationMetrics.MeterName, CosmosDbClientMetrics.NetworkMetrics.MeterName) .AddView( instrumentName: CosmosDbClientMetrics.OperationMetrics.Name.RequestCharge, metricStreamConfiguration: new ExplicitBucketHistogramConfiguration diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/ClientRetryPolicyTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/ClientRetryPolicyTests.cs index 8df56bdc95..46e51348be 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/ClientRetryPolicyTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/ClientRetryPolicyTests.cs @@ -355,7 +355,8 @@ private async Task ValidateConnectTimeoutTriggersClientRetryPolicyAsync( useMultipleWriteLocations: useMultipleWriteLocations, detectClientConnectivityIssues: true, disableRetryWithRetryPolicy: false, - enableReplicaValidation: false); + enableReplicaValidation: false, + accountConfigurationProperties: null); // Reducing retry timeout to avoid long-running tests replicatedResourceClient.GoneAndRetryWithRetryTimeoutInSecondsOverride = 1; diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/StoreReaderTest.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/StoreReaderTest.cs index 10847fae57..2701cd90d7 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/StoreReaderTest.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/StoreReaderTest.cs @@ -599,13 +599,13 @@ public void GlobalStrongConsistentWriteMockTest() { TransportClient mockTransportClient = this.GetMockTransportClientForGlobalStrongWrites(addressInformation, i, false, false, false); StoreReader storeReader = new StoreReader(mockTransportClient, addressSelector, new AddressEnumerator(), sessionContainer, false); - ConsistencyWriter consistencyWriter = new ConsistencyWriter(addressSelector, sessionContainer, mockTransportClient, mockServiceConfigReader.Object, mockAuthorizationTokenProvider.Object, false, false); + ConsistencyWriter consistencyWriter = new ConsistencyWriter(addressSelector, sessionContainer, mockTransportClient, mockServiceConfigReader.Object, mockAuthorizationTokenProvider.Object, false, false, null); StoreResponse response = consistencyWriter.WriteAsync(entity, new TimeoutHelper(TimeSpan.FromSeconds(30)), false).Result; Assert.AreEqual(100, response.LSN); //globalCommittedLsn never catches up in this case mockTransportClient = this.GetMockTransportClientForGlobalStrongWrites(addressInformation, i, true, false, false); - consistencyWriter = new ConsistencyWriter(addressSelector, sessionContainer, mockTransportClient, mockServiceConfigReader.Object, mockAuthorizationTokenProvider.Object, false, false); + consistencyWriter = new ConsistencyWriter(addressSelector, sessionContainer, mockTransportClient, mockServiceConfigReader.Object, mockAuthorizationTokenProvider.Object, false, false, null); try { response = consistencyWriter.WriteAsync(entity, new TimeoutHelper(TimeSpan.FromSeconds(30)), false).Result; @@ -616,17 +616,17 @@ public void GlobalStrongConsistentWriteMockTest() } mockTransportClient = this.GetMockTransportClientForGlobalStrongWrites(addressInformation, i, false, true, false); - consistencyWriter = new ConsistencyWriter(addressSelector, sessionContainer, mockTransportClient, mockServiceConfigReader.Object, mockAuthorizationTokenProvider.Object, false, false); + consistencyWriter = new ConsistencyWriter(addressSelector, sessionContainer, mockTransportClient, mockServiceConfigReader.Object, mockAuthorizationTokenProvider.Object, false, false, null); response = consistencyWriter.WriteAsync(entity, new TimeoutHelper(TimeSpan.FromSeconds(30)), false).Result; Assert.AreEqual(100, response.LSN); mockTransportClient = this.GetMockTransportClientForGlobalStrongWrites(addressInformation, i, false, true, true); - consistencyWriter = new ConsistencyWriter(addressSelector, sessionContainer, mockTransportClient, mockServiceConfigReader.Object, mockAuthorizationTokenProvider.Object, false, false); + consistencyWriter = new ConsistencyWriter(addressSelector, sessionContainer, mockTransportClient, mockServiceConfigReader.Object, mockAuthorizationTokenProvider.Object, false, false, null); response = consistencyWriter.WriteAsync(entity, new TimeoutHelper(TimeSpan.FromSeconds(30)), false).Result; Assert.AreEqual(100, response.LSN); mockTransportClient = this.GetMockTransportClientForGlobalStrongWrites(addressInformation, i, false, false, true); - consistencyWriter = new ConsistencyWriter(addressSelector, sessionContainer, mockTransportClient, mockServiceConfigReader.Object, mockAuthorizationTokenProvider.Object, false, false); + consistencyWriter = new ConsistencyWriter(addressSelector, sessionContainer, mockTransportClient, mockServiceConfigReader.Object, mockAuthorizationTokenProvider.Object, false, false, null); response = consistencyWriter.WriteAsync(entity, new TimeoutHelper(TimeSpan.FromSeconds(30)), false).Result; Assert.AreEqual(100, response.LSN); } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Telemetry/NetworkDataRecorderTest.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Telemetry/NetworkDataRecorderTest.cs index fc6c8a25c3..be2600c31d 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Telemetry/NetworkDataRecorderTest.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Telemetry/NetworkDataRecorderTest.cs @@ -36,7 +36,8 @@ public void TestRecordWithErroredAndHighLatencyRequests() resourceType: Documents.ResourceType.Document, operationType: OperationType.Create, requestSessionToken: default, - locationEndpoint: new Uri("https://dummy.url")), + locationEndpoint: new Uri("https://dummy.url"), + "region1"), new StoreResponseStatistics( requestStartTime: DateTime.Now, @@ -48,7 +49,8 @@ public void TestRecordWithErroredAndHighLatencyRequests() resourceType: Documents.ResourceType.Document, operationType: OperationType.Create, requestSessionToken: default, - locationEndpoint: new Uri("https://dummy.url")) + locationEndpoint: new Uri("https://dummy.url"), + "region1") }; recorder.Record(stats, "databaseId", "containerId"); diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceTests.cs index 6e8b42b552..07472a3a44 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceTests.cs @@ -109,7 +109,8 @@ public void ValidateStoreResultSerialization() ResourceType.Document, OperationType.Query, "42", - new Uri("http://someUri1.com")); + new Uri("http://someUri1.com"), + "region1"); ((List)datum.GetType().GetField("storeResponseStatistics", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(datum)).Add(storeResponseStatistics); diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceWriterBaselineTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceWriterBaselineTests.cs index cefb82338d..9488d2373a 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceWriterBaselineTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Tracing/TraceWriterBaselineTests.cs @@ -367,7 +367,8 @@ public void TraceData() ResourceType.Document, OperationType.Query, "42", - uri1.Uri); + uri1.Uri, + "region1"); TraceWriterBaselineTests.GetPrivateField>(datum, "storeResponseStatistics").Add(storeResponseStatistics); rootTrace.AddDatum("Client Side Request Stats", datum); @@ -401,7 +402,8 @@ public void TraceData() resourceType: default, operationType: default, requestSessionToken: default, - locationEndpoint: default); + locationEndpoint: default, + "region1"); TraceWriterBaselineTests.GetPrivateField>(datum, "storeResponseStatistics").Add(storeResponseStatistics); rootTrace.AddDatum("Client Side Request Stats Default", datum); @@ -426,7 +428,8 @@ public void TraceData() HttpMethod.Get, ResourceType.Document, new HttpResponseMessage(System.Net.HttpStatusCode.OK) { ReasonPhrase = "Success" }, - exception: null); + exception: null, + "region1"); TraceWriterBaselineTests.GetPrivateField>(datum, "httpResponseStatistics").Add(httpResponseStatistics); @@ -437,7 +440,8 @@ public void TraceData() HttpMethod.Get, ResourceType.Document, responseMessage: null, - exception: new OperationCanceledException()); + exception: new OperationCanceledException(), + "region1"); TraceWriterBaselineTests.GetPrivateField>(datum, "httpResponseStatistics").Add(httpResponseStatisticsException); rootTrace.AddDatum("Client Side Request Stats", datum); @@ -939,7 +943,7 @@ public static TraceForBaselineTesting GetRootTrace() return new TraceForBaselineTesting("Trace For Baseline Testing", TraceLevel.Info, TraceComponent.Unknown, parent: null); } - public void UpdateRegionContacted(TraceDatum traceDatum) + public void UpdateRegionContacted(TraceDatum _) { //NoImplementation }