Unverified Commit 16ab8026 authored by Landon James's avatar Landon James Committed by GitHub
Browse files

Align spans with SRA and add tests (#4052)

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here -->
Update our tracing spans to better align with the SRA.

## Description
<!--- Describe your changes in detail -->
* Add top level `{ServiceName}.{OperationName}` span with various SRA
mandated attributes
* Make all spans debug level (was previously mix of debug and info)
* Add some useful fields to spans (attempt_number, etc.)
* Add tests for span behavior (checking nesting structure, number of
times span appears, etc.)

## Testing
<!--- Please describe in detail how you tested your changes -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
Added tests for span emission logic in the `integration-tests/metrics`
test suite

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [x] For changes to the smithy-rs codegen or runtime crates, I have
created a changelog entry Markdown file in the `.changelog` directory,
specifying "client," "server," or both in the `applies_to` key.
- [x] For changes to the AWS SDK, generated SDK code, or SDK runtime
crates, I have created a changelog entry Markdown file in the
`.changelog` directory, specifying "aws-sdk-rust" in the `applies_to`
key.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
parent fb721c15
Loading
Loading
Loading
Loading

.changelog/spans.md

0 → 100644
+10 −0
Original line number Diff line number Diff line
---
applies_to: ["client", "aws-sdk-rust"]
authors: ["landonxjames"]
references: ["smithy-rs#4052"]
breaking: false
new_feature: false
bug_fix: false
---

Update spans to better align with spec.
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ impl DefaultCredentialsChain {
    async fn credentials(&self) -> provider::Result {
        self.provider_chain
            .provide_credentials()
            .instrument(tracing::debug_span!("provide_credentials", provider = %"default_chain"))
            .instrument(tracing::debug_span!("default_credentials_chain"))
            .await
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ impl CredentialsProviderChain {

    async fn credentials(&self) -> provider::Result {
        for (name, provider) in &self.providers {
            let span = tracing::debug_span!("load_credentials", provider = %name);
            let span = tracing::debug_span!("credentials_provider_chain", provider = %name);
            match provider.provide_credentials().instrument(span).await {
                Ok(credentials) => {
                    tracing::debug!(provider = %name, "loaded credentials");
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ impl RegionProviderChain {
        for provider in &self.providers {
            if let Some(region) = provider
                .region()
                .instrument(tracing::info_span!("load_region", provider = ?provider))
                .instrument(tracing::debug_span!("region_provider_chain", provider = ?provider))
                .await
            {
                return Some(region);
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ impl TokenProviderChain {

    async fn token(&self) -> Result {
        for (name, provider) in &self.providers {
            let span = tracing::debug_span!("load_token", provider = %name);
            let span = tracing::debug_span!("token_provider_chain", provider = %name);
            match provider.provide_token().instrument(span).await {
                Ok(credentials) => {
                    tracing::debug!(provider = %name, "loaded access token");
Loading