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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It turns out the 'static bound needed to be on the trait itself rather than just the method. This was causing all the build failures.

And we still can't use the as_any() + downcast_ref() in meter_provider as it is a trait object(&dyn ProvideMeter). The as_any() method has a where Self: Sized constraint, which trait objects don't satisfy by design.

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 we could still use the as_any. If there isn't a default impl of as_any it doesn't need the Sized bound and something like this should work: 95fa386

@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.

@github-actions
Copy link

github-actions bot commented Dec 5, 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 28c9a75 to 20f6231 Compare December 5, 2025 00:42
@github-actions
Copy link

github-actions bot commented Dec 5, 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 5, 2025

A new generated diff is ready to view.

A new doc preview is ready to view.

@vcjana vcjana marked this pull request as ready for review December 5, 2025 19:20
@vcjana vcjana requested review from a team as code owners December 5, 2025 19:20
landonxjames added a commit that referenced this pull request Dec 5, 2025
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