Skip to content

Commit 0133d58

Browse files
committed
Revert "[Internal] Telemetry: Fixes Telemetry conditions and remove logging (#5380)"
This reverts commit 077b84d.
1 parent 077b84d commit 0133d58

2 files changed

Lines changed: 13 additions & 30 deletions

File tree

Microsoft.Azure.Cosmos/src/Resource/ClientContextCore.cs

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -532,53 +532,35 @@ private async Task<TResult> RunWithDiagnosticsHelperAsync<TResult>(
532532
try
533533
{
534534
TResult result = await task(trace).ConfigureAwait(false);
535-
535+
// Checks if OpenTelemetry is configured for this operation and either Trace or Metrics are enabled by customer
536536
if (isOtelCompatibleOperation)
537537
{
538538
// Extracts and records telemetry data from the result of the operation.
539539
OpenTelemetryAttributes otelAttributes = openTelemetry?.GetAttributes(result);
540540

541-
// Checks if OpenTelemetry is configured for this operation when Trace are enabled by customer
542-
if (!this.clientOptions.CosmosClientTelemetryOptions.DisableDistributedTracing)
543-
{
544-
// Records the telemetry attributes for Distributed Tracing (if enabled) and Metrics
545-
recorder.Record(otelAttributes);
546-
}
547-
548-
// Checks if OpenTelemetry is configured for this operation when Metrics are enabled by customer
549-
if (this.clientOptions.CosmosClientTelemetryOptions.IsClientMetricsEnabled)
550-
{
551-
RecordMetrics(getOperationName,
552-
this.client.Endpoint,
553-
containerName,
554-
databaseName,
555-
requestOptions,
556-
attributes: otelAttributes);
557-
}
541+
// Records the telemetry attributes for Distributed Tracing (if enabled) and Metrics
542+
recorder.Record(otelAttributes);
543+
RecordMetrics(getOperationName,
544+
this.client.Endpoint,
545+
containerName,
546+
databaseName,
547+
requestOptions,
548+
attributes: otelAttributes);
558549
}
559-
550+
560551
return result;
561552
}
562553
catch (Exception ex) when (TryTransformException(ex, trace, this.client, out Exception cosmosException))
563554
{
564555
if (isOtelCompatibleOperation)
565556
{
566-
// Checks if OpenTelemetry is configured for this operation when Trace are enabled by customer
567-
if (!this.clientOptions.CosmosClientTelemetryOptions.DisableDistributedTracing)
568-
{
569-
recorder.MarkFailed(cosmosException);
570-
}
571-
572-
// Checks if OpenTelemetry is configured for this operation when Metrics are enabled by customer
573-
if (this.clientOptions.CosmosClientTelemetryOptions.IsClientMetricsEnabled)
574-
{
575-
RecordMetrics(getOperationName,
557+
recorder.MarkFailed(cosmosException);
558+
RecordMetrics(getOperationName,
576559
gatewayEndpoint,
577560
containerName,
578561
databaseName,
579562
requestOptions,
580563
cosmosException: cosmosException);
581-
}
582564
}
583565

584566
throw cosmosException; // Rethrow after recording telemetry

Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/CosmosDbNetworkMeter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ internal static void RecordTelemetry(Func<string> getOperationName,
9494
{
9595
if (!IsEnabled || !CosmosDbMeterUtil.TryGetDiagnostics(attributes, ex, out CosmosTraceDiagnostics diagnostics))
9696
{
97+
DefaultTrace.TraceWarning("Network Meter is not enabled or Diagnostics is not available.");
9798
return;
9899
}
99100

0 commit comments

Comments
 (0)