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

Add aws-smithy-observability and aws-smithy-observability-otel crates #3986

Closed
wants to merge 40 commits into from

Conversation

landonxjames
Copy link
Contributor

@landonxjames landonxjames commented Jan 24, 2025

Motivation and Context

This PR is an updated version of #3912 featuring an Associated Type based implementation of of the SRA metrics interfaces instead of the previous dyn Trait based implementations.

Description

Add two new crates

  • aws-smithy-observability - contains traits for our observability solution and a global module for managing the global telemetry provider
  • aws-smithy-observability-otel - contains an OpenTelemetry based implementation of the traits

Testing

Various unit tests in both new crates.

Checklist

Note: leaving out a changelog entry for now since these crates won't offer much value until we instrument our runtime crates


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

landonxjames and others added 30 commits December 3, 2024 12:07
Also fix all warnings in both observability crates
The updates caused CI to fail since it depended on the newly added
crates, but those were not yet present in the main lockfile that is
copied around for tests
* Update some clippy style issues
* Config the aws-smithy-observability-otel crate to not compile on powerpc
* Run tests for global module serially so they don't poison the RwLock
Pin version of value-bag in otel crate

Powerpc dep updates

Pin more transitive deps
Aligns with standard introduced in #3065

Update doc comments

External types updates
Remove non-public type from docs
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@landonxjames landonxjames marked this pull request as ready for review January 27, 2025 03:40
@landonxjames landonxjames requested review from a team as code owners January 27, 2025 03:40
Copy link
Contributor

@aajtodd aajtodd left a comment

Choose a reason for hiding this comment

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

Questions on feasibility re: instrumentation and global provider.

// TODO(smithyobservability): once we have finalized everything and integrated metrics with our runtime
// libraries update this with detailed usage docs and examples

pub mod attributes;
Copy link
Contributor

Choose a reason for hiding this comment

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

if you have a pub use for the things inside do we need the module itself public?

pub fn set_telemetry_provider<PM: ProvideMeter + 'static>(
new_provider: TelemetryProvider<PM>,
) -> Result<(), ObservabilityError> {
if let Ok(mut old_provider) = GLOBAL_TELEMETRY_PROVIDER.try_write() {
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Why try_write? Why not just lock and block the thread?


/// Delineates a logical scope that has some beginning and end
/// (e.g. a function or block of code).
pub trait Scope: Send + Sync + Debug {
Copy link
Contributor

Choose a reason for hiding this comment

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

probably move these traits (context, scope, context manager) either into lib.rs directly or a context module.

}

/// Get an owned [Iterator] of ([String], [AttributeValue]).
pub fn into_attributes(self) -> impl Iterator<Item = (String, AttributeValue)> {
Copy link
Contributor

Choose a reason for hiding this comment

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

implementing into_iter would probably be more idiomatic but I question why we need this?

Copy link
Contributor

Choose a reason for hiding this comment

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

It was added to make call sites more ergonomic, otherwise they would have to clone String unnecessarily even though they have an owned Attributes passed to them (discussion)


/// Get an [Arc] reference to the current global [TelemetryProvider]. Will return an [Err] if the
/// [RwLock] holding the global [TelemetryProvider] is locked or poisoned.
pub fn get_telemetry_provider<PM: ProvideMeter + 'static>(
Copy link
Contributor

Choose a reason for hiding this comment

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

question/correctness: How are we going to instrument the runtime if we have to know the concrete type of PM here? The runtime can't possibly know the type so I'm not sure how instrumentation is going to work with this.

Comment on lines +192 to +204
type Context = ContextWrap;
type Gauge = GaugeWrap;
type UpDownCounter = UpDownCounterWrap;
type AsyncUDC = AsyncUpDownCounterWrap;
type MonotonicCounter = MonotonicCounterWrap;
type AsyncMC = AsyncMonotonicCounterWrap;
type Histogram = HistogramWrap;
type GaugeCallback<'a> = fn(&Self::GaugeCallbackInput<'_>);
type GaugeCallbackInput<'a> = AsyncInstrumentWrap<'a, f64>;
type AsyncUDCCallback<'a> = fn(&Self::AsyncUDCCallbackInput<'_>);
type AsyncUDCCallbackInput<'a> = AsyncInstrumentWrap<'a, i64>;
type AsyncMCCallback<'a> = fn(&Self::AsyncMCCallbackInput<'_>);
type AsyncMCCallbackInput<'a> = AsyncInstrumentWrap<'a, u64>;
Copy link
Contributor

Choose a reason for hiding this comment

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

These are a quite a few of associated types 🤔

Copy link
Contributor

@ysaito1001 ysaito1001 left a comment

Choose a reason for hiding this comment

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

Other than pending comments, given I approved #3912, this looks good. We probably just need to settle on either dyn trait or associated types.

@landonxjames
Copy link
Contributor Author

Overtaken by #4003

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.

3 participants