-
Notifications
You must be signed in to change notification settings - Fork 358
Add Cosmos client-side observability layer #4789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 9 commits
4076048
5f85f21
06bcb04
8659a5d
2a745d7
22640d1
618b238
308dac3
bb1dade
a872e5a
b445087
ef64112
6360d1f
149aee6
5849ac7
74c29b7
4d0216e
1f2a3d1
328027f
50e1fd8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
|
|
||
| use crate::{ | ||
| clients::{offers_client, ClientContext}, | ||
| diagnostics::CosmosOperationContext, | ||
| feed::{ChangeFeedPageIterator, FeedRange, FeedScope, QueryItemIterator}, | ||
| models::TransactionalBatch, | ||
| models::{BatchResponse, ItemResponse, ResourceResponse}, | ||
|
|
@@ -62,6 +63,16 @@ impl ContainerClient { | |
| }) | ||
| } | ||
|
|
||
| /// Builds the SDK-side [`CosmosOperationContext`] for this container's | ||
| /// operations, carrying the operation name plus the database and container | ||
| /// identity the driver context does not know. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Surprised the driver doesn't have this context. Doesn't it have these on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It has some of it. |
||
| fn operation_context(&self, operation_name: &'static str) -> CosmosOperationContext { | ||
| CosmosOperationContext::new() | ||
| .with_operation_name(operation_name) | ||
| .with_database_name(self.container_ref.database_name().to_string()) | ||
| .with_container_name(self.container_ref.name().to_string()) | ||
| } | ||
|
|
||
| /// Reads the properties of the container. | ||
| /// | ||
| /// # Arguments | ||
|
|
@@ -92,7 +103,8 @@ impl ContainerClient { | |
| .await?; | ||
|
|
||
| Ok(ResourceResponse::new( | ||
| crate::driver_bridge::driver_response_to_cosmos_response(driver_response), | ||
| self.context | ||
| .complete_operation(driver_response, || self.operation_context("read_container")), | ||
| )) | ||
| } | ||
|
|
||
|
|
@@ -145,7 +157,9 @@ impl ContainerClient { | |
| .await?; | ||
|
|
||
| Ok(ResourceResponse::new( | ||
| crate::driver_bridge::driver_response_to_cosmos_response(driver_response), | ||
| self.context.complete_operation(driver_response, || { | ||
| self.operation_context("replace_container") | ||
| }), | ||
| )) | ||
| } | ||
|
|
||
|
|
@@ -231,7 +245,9 @@ impl ContainerClient { | |
| .await?; | ||
|
|
||
| Ok(ResourceResponse::new( | ||
| crate::driver_bridge::driver_response_to_cosmos_response(driver_response), | ||
| self.context.complete_operation(driver_response, || { | ||
| self.operation_context("delete_container") | ||
| }), | ||
| )) | ||
| } | ||
|
|
||
|
|
@@ -330,7 +346,8 @@ impl ContainerClient { | |
|
|
||
| // Bridge the driver response to the SDK response type. | ||
| Ok(ItemResponse::new( | ||
| crate::driver_bridge::driver_response_to_cosmos_response(driver_response), | ||
| self.context | ||
| .complete_operation(driver_response, || self.operation_context("create_item")), | ||
| )) | ||
| } | ||
|
|
||
|
|
@@ -428,7 +445,8 @@ impl ContainerClient { | |
|
|
||
| // Bridge the driver response to the SDK response type. | ||
| Ok(ItemResponse::new( | ||
| crate::driver_bridge::driver_response_to_cosmos_response(driver_response), | ||
| self.context | ||
| .complete_operation(driver_response, || self.operation_context("replace_item")), | ||
| )) | ||
| } | ||
|
|
||
|
|
@@ -534,7 +552,8 @@ impl ContainerClient { | |
| .await?; | ||
|
|
||
| Ok(ItemResponse::new( | ||
| crate::driver_bridge::driver_response_to_cosmos_response(driver_response), | ||
| self.context | ||
| .complete_operation(driver_response, || self.operation_context("patch_item")), | ||
| )) | ||
| } | ||
|
|
||
|
|
@@ -636,7 +655,8 @@ impl ContainerClient { | |
|
|
||
| // Bridge the driver response to the SDK response type. | ||
| Ok(ItemResponse::new( | ||
| crate::driver_bridge::driver_response_to_cosmos_response(driver_response), | ||
| self.context | ||
| .complete_operation(driver_response, || self.operation_context("upsert_item")), | ||
| )) | ||
| } | ||
|
|
||
|
|
@@ -696,7 +716,8 @@ impl ContainerClient { | |
|
|
||
| // Bridge the driver response to the SDK response type. | ||
| Ok(ItemResponse::new( | ||
| crate::driver_bridge::driver_response_to_cosmos_response(driver_response), | ||
| self.context | ||
| .complete_operation(driver_response, || self.operation_context("read_item")), | ||
| )) | ||
| } | ||
|
|
||
|
|
@@ -748,7 +769,8 @@ impl ContainerClient { | |
|
|
||
| // Bridge the driver response to the SDK response type. | ||
| Ok(ItemResponse::new( | ||
| crate::driver_bridge::driver_response_to_cosmos_response(driver_response), | ||
| self.context | ||
| .complete_operation(driver_response, || self.operation_context("delete_item")), | ||
| )) | ||
| } | ||
|
|
||
|
|
@@ -1007,7 +1029,9 @@ impl ContainerClient { | |
| .await?; | ||
|
|
||
| Ok(BatchResponse::new( | ||
| crate::driver_bridge::driver_response_to_cosmos_response(driver_response), | ||
| self.context.complete_operation(driver_response, || { | ||
| self.operation_context("execute_transactional_batch") | ||
| }), | ||
| )) | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.