Skip to content

Conversation

@vcjana
Copy link
Contributor

@vcjana vcjana commented Nov 24, 2025

Motivation and Context

Implements business metric tracking for observability providers per SEP User Agent 2.1 specification. The metric '7' (ObservabilityOtelMetrics) must be tracked when users configure OpenTelemetry metrics providers to help AWS understand observability usage patterns.

Description

This PR adds a new ObservabilityMetricDecorator that tracks the observability metric when OpenTelemetry metrics providers are configured through the global telemetry provider.

Implementation

The decorator registers an ObservabilityFeatureTrackerInterceptor that runs during request execution. It checks the global telemetry provider and uses type downcasting to detect if an OtelMeterProvider is configured:

  • Checks global telemetry provider via aws_smithy_observability::global::get_telemetry_provider()
  • Uses downcast_ref::<OtelMeterProvider>() for reliable type detection
  • Adds as_any() method to ProvideMeter trait to enable downcasting
  • Stores metric in interceptor state when OTel provider is detected

When an OpenTelemetry metrics provider is configured, the metric is tracked in the User-Agent header.

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the smithy-rs codegen or runtime crates
  • I have updated CHANGELOG.next.toml if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates

Note: This is a draft PR for review. The implementation successfully tracks OpenTelemetry metrics provider usage, which covers the SEP requirements for metric 7.

@vcjana vcjana force-pushed the observability-metrics-implementation branch from 3325a0b to 30648d2 Compare November 24, 2025 16:57
@vcjana vcjana force-pushed the observability-metrics-implementation branch from f9f1c7e to 0c38ac5 Compare November 28, 2025 02:13
@vcjana vcjana force-pushed the observability-metrics-implementation branch from 0c38ac5 to 02e7b83 Compare November 28, 2025 02:57
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

vcjana added a commit that referenced this pull request Nov 28, 2025
This change belongs to PR #4420 (observability metrics) where it's
actually needed for testing, not in the endpoint override metric PR.
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@vcjana vcjana force-pushed the observability-metrics-implementation branch from e48ccee to 869532b Compare November 30, 2025 22:52
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

@vcjana vcjana force-pushed the observability-metrics-implementation branch 2 times, most recently from 26502b9 to 4bdc5a1 Compare December 1, 2025 17:32
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

@vcjana vcjana force-pushed the observability-metrics-implementation branch 2 times, most recently from 14ab3db to 433fbe0 Compare December 1, 2025 19:30
@vcjana vcjana force-pushed the observability-metrics-implementation branch from 433fbe0 to 1fcff09 Compare December 1, 2025 19:32
…-implementation

# Conflicts:
#	aws/rust-runtime/Cargo.lock
#	rust-runtime/Cargo.lock
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link
Contributor

@landonxjames landonxjames left a comment

Choose a reason for hiding this comment

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

Good start, couple of questions and suggestions. The biggest thing is figuring out what build issues you were encountering didn't allow you to test against the actual aws-smithy-observability-otel crate.


// Check the provider name to detect OpenTelemetry without importing the otel crate
// This avoids compilation issues with the opentelemetry dependency
if meter_provider.provider_name() == "otel" {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is ok, but this could be faked. I don't know that that is something we really need to defend against though.

If we used the as_any cast along with a downcast_ref we could guarantee that it was our implementation of Otel. What were the compilation issues we are avoiding with this strategy?

}

// Mock OTel meter provider for testing
// This mimics the real OtelMeterProvider's type name without requiring the broken opentelemetry crate
Copy link
Contributor

Choose a reason for hiding this comment

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

How is it broken? It should work, we have some testing around it. The only thing I would expect to break would be it doesn't work on some of our exotic arch tests (powerpc maybe?).

I would really like to have a test that goes against the real OTel provider.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially used a mock because I was concerned about potential build issues with the opentelemetry crate (I had seen some comments about powerpc compatibility issues in the Cargo.toml). I'll update the test to use the actual implementation instead of the mock.

/// The default implementation returns a reference to the unit type,
/// which will fail any downcast attempts. Implementations should override
/// this to return `self` for proper type inspection.
fn as_any(&self) -> &dyn std::any::Any {
Copy link
Contributor

Choose a reason for hiding this comment

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

This new method doesn't seem to be used anywhere? I think it probably should be though so we can match on the actual type instead of on a name that could be set to anything.

If we do keep this it should either be a real implementation (return &self) or not implemented so implementers of the trait have to implement it themselves. But returning an incorrect type () is not the behavior we want.

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Dec 3, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

@vcjana vcjana force-pushed the observability-metrics-implementation branch from 9ed940d to f8aa750 Compare December 3, 2025 21:24
@github-actions
Copy link

github-actions bot commented Dec 3, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Dec 3, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

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