Skip to content
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

Merged
merged 8 commits into from
Oct 19, 2023

Conversation

mythrnr
Copy link
Contributor

@mythrnr mythrnr commented Oct 18, 2023

What does this change?

  • Create feature tracing to support tokio-rs/tracing.
  • Run cargo update.

References

None.

Screenshots

None.

What can I check for bug fixes?

None.

Comment on lines +72 to +86
## 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"
```
Copy link
Contributor Author

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update Rust toolchain

Comment on lines +92 to +97
#[cfg_attr(feature = "tracing", tracing::instrument(
level = tracing::Level::DEBUG,
name = "dynamodb::action",
skip_all,
fields(api = "transact_write_items")
))]
Copy link
Contributor Author

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.

Comment on lines +95 to +106
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! {},
)
};
Copy link
Contributor Author

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.

Comment on lines +90 to +94
let fut = fut.instrument(::tracing::debug_span!(
"dynamodb::action",
table = #table_name,
api = std::stringify!(#operation),
));
Copy link
Contributor Author

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}",
    )
)]

@mythrnr mythrnr marked this pull request as ready for review October 19, 2023 03:10
Copy link
Member

@bokuweb bokuweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bokuweb bokuweb merged commit 29ec2f3 into raiden-rs:master Oct 19, 2023
1 check passed
@mythrnr mythrnr deleted the feat/tracing-span branch October 19, 2023 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants