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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
further fixes
  • Loading branch information
sourabh1007 committed Sep 17, 2024
commit 79543d0240d2f5685d8ece884cde64274d999a2b
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private QueryIterator(

this.container = container;
this.operationName = OpenTelemetryConstants.Operations.QueryItems;
this.operationType = Documents.OperationType.Query;
}

public static QueryIterator Create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,10 @@ public void Dispose()
/// Operation Name used for open telemetry traces
/// </summary>
internal string operationName;

/// <summary>
/// Operation Type used for open telemetry traces, it will set optionally, otherwise default operation type will be used in traces
/// </summary>
internal Documents.OperationType? operationType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public FeedIteratorCore(
this.container = container;

this.operationName = OpenTelemetryConstants.Operations.QueryItems;
this.operationType = OperationType.Query;
}

public override bool HasMoreResults => this.hasMoreResultsInternal;
Expand Down Expand Up @@ -216,7 +217,8 @@ internal FeedIteratorCore(
this.databaseName = feedIterator.databaseName;
this.container = feedIterator.container;

this.operationName = OpenTelemetryConstants.Operations.QueryItems;
this.operationName = feedIterator.operationName;
this.operationType = feedIterator.operationType;
}

public override bool HasMoreResults => this.feedIterator.HasMoreResults;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ internal FeedIteratorInlineCore(
this.databaseName = feedIteratorInternal.databaseName;

this.operationName = feedIteratorInternal.operationName;
this.operationType = feedIteratorInternal.operationType;
}

internal FeedIteratorInlineCore(
Expand All @@ -45,6 +46,7 @@ internal FeedIteratorInlineCore(
this.databaseName = feedIteratorInternal.databaseName;

this.operationName = feedIteratorInternal.operationName;
this.operationType = feedIteratorInternal.operationType;
}

public override bool HasMoreResults => this.feedIteratorInternal.HasMoreResults;
Expand All @@ -58,7 +60,16 @@ public override Task<ResponseMessage> ReadNextAsync(CancellationToken cancellati
operationType: Documents.OperationType.ReadFeed,
requestOptions: null,
task: (trace) => this.feedIteratorInternal.ReadNextAsync(trace, cancellationToken),
openTelemetry: new (this.operationName, (response) => new OpenTelemetryResponse(responseMessage: response)));
openTelemetry: new (this.operationName, (response) =>
{
OpenTelemetryResponse openTelemetryResponse = new OpenTelemetryResponse(responseMessage: response);

if (this.operationType.HasValue)
{
openTelemetryResponse.OperationType = this.operationType.Value;
}
return openTelemetryResponse;
}));
}

public override Task<ResponseMessage> ReadNextAsync(ITrace trace, CancellationToken cancellationToken = default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ internal FeedIteratorInlineCore(
this.databaseName = feedIteratorInternal.databaseName;

this.operationName = feedIteratorInternal.operationName;
this.operationType = feedIteratorInternal.operationType;
}

internal FeedIteratorInlineCore(
Expand All @@ -45,6 +46,7 @@ internal FeedIteratorInlineCore(
this.databaseName = feedIteratorInternal.databaseName;

this.operationName = feedIteratorInternal.operationName;
this.operationType = feedIteratorInternal.operationType;
}

public override bool HasMoreResults => this.feedIteratorInternal.HasMoreResults;
Expand All @@ -58,7 +60,16 @@ public override Task<FeedResponse<T>> ReadNextAsync(CancellationToken cancellati
operationType: Documents.OperationType.ReadFeed,
requestOptions: null,
task: trace => this.feedIteratorInternal.ReadNextAsync(trace, cancellationToken),
openTelemetry: new (this.feedIteratorInternal.operationName, (response) => new OpenTelemetryResponse<T>(responseMessage: response)));
openTelemetry: new (this.feedIteratorInternal.operationName, (response) =>
{
OpenTelemetryResponse<T> openTelemetryResponse = new OpenTelemetryResponse<T>(responseMessage: response);

if (this.operationType.HasValue)
{
openTelemetryResponse.OperationType = this.operationType.Value;
}
return openTelemetryResponse;
}));
}

public override Task<FeedResponse<T>> ReadNextAsync(ITrace trace, CancellationToken cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,10 @@ public void Dispose()
/// Operation Name used for open telemetry traces
/// </summary>
internal string operationName;

/// <summary>
/// Operation Type used for open telemetry traces
/// </summary>
internal Documents.OperationType? operationType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ internal sealed class OpenTelemetryAttributeKeys
/// <summary>
/// Represents the size of the batch operation.
/// </summary>
public const string BatchSize = "db.operation.batch.size";
public const string BatchSize = "db.operation.batch_size";

// Exceptions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="FailedRequest" />
</OTelActivities></Output>
</Result>
<Result>
Expand Down Expand Up @@ -690,6 +691,7 @@
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="FailedRequest" />
</OTelActivities></Output>
</Result>
<Result>
Expand Down Expand Up @@ -1027,6 +1029,7 @@
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="FailedRequest" />
</OTelActivities></Output>
</Result>
<Result>
Expand Down Expand Up @@ -1364,6 +1367,7 @@
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="FailedRequest" />
</OTelActivities></Output>
</Result>
<Result>
Expand Down Expand Up @@ -1701,6 +1705,7 @@
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="FailedRequest" />
</OTelActivities></Output>
</Result>
<Result>
Expand Down Expand Up @@ -2038,6 +2043,7 @@
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="FailedRequest" />
</OTelActivities></Output>
</Result>
<Result>
Expand Down Expand Up @@ -2375,6 +2381,7 @@
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="FailedRequest" />
</OTelActivities></Output>
</Result>
<Result>
Expand Down Expand Up @@ -2712,6 +2719,7 @@
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="FailedRequest" />
</OTelActivities></Output>
</Result>
<Result>
Expand Down Expand Up @@ -3049,6 +3057,7 @@
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="FailedRequest" />
</OTelActivities></Output>
</Result>
<Result>
Expand Down Expand Up @@ -3386,6 +3395,7 @@
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="ThresholdViolation" />
<EVENT name="FailedRequest" />
</OTelActivities></Output>
</Result>
<Result>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1769,10 +1769,10 @@
}
]
}]]></Json><OTelActivities>
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_items" displayName="query_items containerName">
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_change_feed" displayName="query_change_feed containerName">
<ATTRIBUTE key="az.namespace">Microsoft.DocumentDB</ATTRIBUTE>
<ATTRIBUTE key="az.schema_url">https://opentelemetry.io/schemas/1.23.0</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_items</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_change_feed</ATTRIBUTE>
<ATTRIBUTE key="db.namespace">databaseName</ATTRIBUTE>
<ATTRIBUTE key="db.collection.name">containerName</ATTRIBUTE>
<ATTRIBUTE key="db.system">cosmosdb</ATTRIBUTE>
Expand All @@ -1788,10 +1788,10 @@
<ATTRIBUTE key="db.cosmosdb.activity_id">Some Value</ATTRIBUTE>
<ATTRIBUTE key="db.cosmosdb.regions_contacted">South Central US</ATTRIBUTE>
</ACTIVITY>
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_items" displayName="query_items containerName">
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_change_feed" displayName="query_change_feed containerName">
<ATTRIBUTE key="az.namespace">Microsoft.DocumentDB</ATTRIBUTE>
<ATTRIBUTE key="az.schema_url">https://opentelemetry.io/schemas/1.23.0</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_items</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_change_feed</ATTRIBUTE>
<ATTRIBUTE key="db.namespace">databaseName</ATTRIBUTE>
<ATTRIBUTE key="db.collection.name">containerName</ATTRIBUTE>
<ATTRIBUTE key="db.system">cosmosdb</ATTRIBUTE>
Expand All @@ -1807,10 +1807,10 @@
<ATTRIBUTE key="db.cosmosdb.activity_id">Some Value</ATTRIBUTE>
<ATTRIBUTE key="db.cosmosdb.regions_contacted">South Central US</ATTRIBUTE>
</ACTIVITY>
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_items" displayName="query_items containerName">
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_change_feed" displayName="query_change_feed containerName">
<ATTRIBUTE key="az.namespace">Microsoft.DocumentDB</ATTRIBUTE>
<ATTRIBUTE key="az.schema_url">https://opentelemetry.io/schemas/1.23.0</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_items</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_change_feed</ATTRIBUTE>
<ATTRIBUTE key="db.namespace">databaseName</ATTRIBUTE>
<ATTRIBUTE key="db.collection.name">containerName</ATTRIBUTE>
<ATTRIBUTE key="db.system">cosmosdb</ATTRIBUTE>
Expand All @@ -1826,10 +1826,10 @@
<ATTRIBUTE key="db.cosmosdb.activity_id">Some Value</ATTRIBUTE>
<ATTRIBUTE key="db.cosmosdb.regions_contacted">South Central US</ATTRIBUTE>
</ACTIVITY>
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_items" displayName="query_items containerName">
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_change_feed" displayName="query_change_feed containerName">
<ATTRIBUTE key="az.namespace">Microsoft.DocumentDB</ATTRIBUTE>
<ATTRIBUTE key="az.schema_url">https://opentelemetry.io/schemas/1.23.0</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_items</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_change_feed</ATTRIBUTE>
<ATTRIBUTE key="db.namespace">databaseName</ATTRIBUTE>
<ATTRIBUTE key="db.collection.name">containerName</ATTRIBUTE>
<ATTRIBUTE key="db.system">cosmosdb</ATTRIBUTE>
Expand All @@ -1845,10 +1845,10 @@
<ATTRIBUTE key="db.cosmosdb.activity_id">Some Value</ATTRIBUTE>
<ATTRIBUTE key="db.cosmosdb.regions_contacted">South Central US</ATTRIBUTE>
</ACTIVITY>
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_items" displayName="query_items containerName">
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_change_feed" displayName="query_change_feed containerName">
<ATTRIBUTE key="az.namespace">Microsoft.DocumentDB</ATTRIBUTE>
<ATTRIBUTE key="az.schema_url">https://opentelemetry.io/schemas/1.23.0</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_items</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_change_feed</ATTRIBUTE>
<ATTRIBUTE key="db.namespace">databaseName</ATTRIBUTE>
<ATTRIBUTE key="db.collection.name">containerName</ATTRIBUTE>
<ATTRIBUTE key="db.system">cosmosdb</ATTRIBUTE>
Expand Down Expand Up @@ -3243,10 +3243,10 @@
}
]
}]]></Json><OTelActivities>
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_items" displayName="query_items containerName">
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_change_feed" displayName="query_change_feed containerName">
<ATTRIBUTE key="az.namespace">Microsoft.DocumentDB</ATTRIBUTE>
<ATTRIBUTE key="az.schema_url">https://opentelemetry.io/schemas/1.23.0</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_items</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_change_feed</ATTRIBUTE>
<ATTRIBUTE key="db.namespace">databaseName</ATTRIBUTE>
<ATTRIBUTE key="db.collection.name">containerName</ATTRIBUTE>
<ATTRIBUTE key="db.system">cosmosdb</ATTRIBUTE>
Expand All @@ -3262,10 +3262,10 @@
<ATTRIBUTE key="db.cosmosdb.activity_id">Some Value</ATTRIBUTE>
<ATTRIBUTE key="db.cosmosdb.regions_contacted">South Central US</ATTRIBUTE>
</ACTIVITY>
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_items" displayName="query_items containerName">
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_change_feed" displayName="query_change_feed containerName">
<ATTRIBUTE key="az.namespace">Microsoft.DocumentDB</ATTRIBUTE>
<ATTRIBUTE key="az.schema_url">https://opentelemetry.io/schemas/1.23.0</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_items</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_change_feed</ATTRIBUTE>
<ATTRIBUTE key="db.namespace">databaseName</ATTRIBUTE>
<ATTRIBUTE key="db.collection.name">containerName</ATTRIBUTE>
<ATTRIBUTE key="db.system">cosmosdb</ATTRIBUTE>
Expand All @@ -3281,10 +3281,10 @@
<ATTRIBUTE key="db.cosmosdb.activity_id">Some Value</ATTRIBUTE>
<ATTRIBUTE key="db.cosmosdb.regions_contacted">South Central US</ATTRIBUTE>
</ACTIVITY>
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_items" displayName="query_items containerName">
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_change_feed" displayName="query_change_feed containerName">
<ATTRIBUTE key="az.namespace">Microsoft.DocumentDB</ATTRIBUTE>
<ATTRIBUTE key="az.schema_url">https://opentelemetry.io/schemas/1.23.0</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_items</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_change_feed</ATTRIBUTE>
<ATTRIBUTE key="db.namespace">databaseName</ATTRIBUTE>
<ATTRIBUTE key="db.collection.name">containerName</ATTRIBUTE>
<ATTRIBUTE key="db.system">cosmosdb</ATTRIBUTE>
Expand All @@ -3300,10 +3300,10 @@
<ATTRIBUTE key="db.cosmosdb.activity_id">Some Value</ATTRIBUTE>
<ATTRIBUTE key="db.cosmosdb.regions_contacted">South Central US</ATTRIBUTE>
</ACTIVITY>
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_items" displayName="query_items containerName">
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_change_feed" displayName="query_change_feed containerName">
<ATTRIBUTE key="az.namespace">Microsoft.DocumentDB</ATTRIBUTE>
<ATTRIBUTE key="az.schema_url">https://opentelemetry.io/schemas/1.23.0</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_items</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_change_feed</ATTRIBUTE>
<ATTRIBUTE key="db.namespace">databaseName</ATTRIBUTE>
<ATTRIBUTE key="db.collection.name">containerName</ATTRIBUTE>
<ATTRIBUTE key="db.system">cosmosdb</ATTRIBUTE>
Expand All @@ -3319,10 +3319,10 @@
<ATTRIBUTE key="db.cosmosdb.activity_id">Some Value</ATTRIBUTE>
<ATTRIBUTE key="db.cosmosdb.regions_contacted">South Central US</ATTRIBUTE>
</ACTIVITY>
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_items" displayName="query_items containerName">
<ACTIVITY source="Azure.Cosmos.Operation" operationName="Operation.query_change_feed" displayName="query_change_feed containerName">
<ATTRIBUTE key="az.namespace">Microsoft.DocumentDB</ATTRIBUTE>
<ATTRIBUTE key="az.schema_url">https://opentelemetry.io/schemas/1.23.0</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_items</ATTRIBUTE>
<ATTRIBUTE key="db.operation.name">query_change_feed</ATTRIBUTE>
<ATTRIBUTE key="db.namespace">databaseName</ATTRIBUTE>
<ATTRIBUTE key="db.collection.name">containerName</ATTRIBUTE>
<ATTRIBUTE key="db.system">cosmosdb</ATTRIBUTE>
Expand Down
Loading