diff --git a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs index 05bd949671..029c3f4031 100644 --- a/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs +++ b/Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/Filters/DiagnosticsFilterHelper.cs @@ -18,6 +18,7 @@ public static bool IsLatencyThresholdCrossed( OperationType operationType, OpenTelemetryAttributes response) { + config ??= new CosmosThresholdOptions(); TimeSpan latencyThreshold = operationType == OperationType.Query ? config.NonPointOperationLatencyThreshold : config.PointOperationLatencyThreshold; return response.Diagnostics.GetClientElapsedTime() > latencyThreshold; } diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/DistributedTracingOTelTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/DistributedTracingOTelTests.cs index 299055c611..6ed14ff7ca 100644 --- a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/DistributedTracingOTelTests.cs +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/DistributedTracingOTelTests.cs @@ -182,7 +182,7 @@ await base.TestInit(validateSinglePartitionKeyRangeCacheCall: false, customizeClientBuilder: (builder) => builder .WithClientTelemetryOptions(new CosmosClientTelemetryOptions() { - DisableDistributedTracing = enableDistributingTracing + DisableDistributedTracing = !enableDistributingTracing }) .WithConnectionModeGateway()); } @@ -192,7 +192,7 @@ await base.TestInit(validateSinglePartitionKeyRangeCacheCall: false, customizeClientBuilder: (builder) => builder .WithClientTelemetryOptions(new CosmosClientTelemetryOptions() { - DisableDistributedTracing = enableDistributingTracing + DisableDistributedTracing = !enableDistributingTracing })); }