-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat: Make span when call DynamoDB API. #232
Conversation
## Support `tokio-rs/tracing` | ||
|
||
`raiden` supports making span for Tracing ( span name is `dynamodb::action` with table name and api name in field ). | ||
To activate this feature, you need to specify `tracing` feature in your `Cargo.toml`. And your crate needs `tracing` . | ||
|
||
```toml | ||
# Example | ||
[dependencies] | ||
raiden = { | ||
tag = "0.0.76", | ||
git = "https://github.com/raiden-rs/raiden-dynamo.git", | ||
features = [ "tracing"] | ||
} | ||
tracing = "0.1" | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add description to activate tracing
feature.
@@ -1 +1 @@ | |||
1.66.1 | |||
1.67.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update Rust toolchain
#[cfg_attr(feature = "tracing", tracing::instrument( | ||
level = tracing::Level::DEBUG, | ||
name = "dynamodb::action", | ||
skip_all, | ||
fields(api = "transact_write_items") | ||
))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make span at WriteTx::inner_run to wrap calling TransactWriteItems API.
This span does not support field for table name.
let api_call_token = super::api_call_token!("batch_write_item"); | ||
let (call_inner_run, inner_run_args) = if cfg!(feature = "tracing") { | ||
( | ||
quote! { #builder_name::inner_run(&self.table_name, &self.client, input).await? }, | ||
quote! { table_name: &str, }, | ||
) | ||
} else { | ||
( | ||
quote! { #builder_name::inner_run(&self.client, input).await? }, | ||
quote! {}, | ||
) | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create token stream to call DynamoDB API with span.
if feature tracing
is not active, token stream will be created without making span.
let fut = fut.instrument(::tracing::debug_span!( | ||
"dynamodb::action", | ||
table = #table_name, | ||
api = std::stringify!(#operation), | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This setting is same as next.
#[tracing::instrument(
level = tracing::Level::DEBUG,
name = "dynamodb::action",
skip_all,
fields(
table = "{table_name}",
api = "{operation}",
)
)]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What does this change?
tracing
to supporttokio-rs/tracing
.cargo update
.References
None.
Screenshots
None.
What can I check for bug fixes?
None.