-
Notifications
You must be signed in to change notification settings - Fork 190
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
#3912
base: main
Are you sure you want to change the base?
Conversation
aws-smithy-observability
and aws-smithy-observability-otel
crates
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start but I have some questions and concerns to be discussed.
/// Provides named instances of [Meter]. | ||
pub trait MeterProvider { | ||
/// Get or create a named [Meter]. | ||
fn get_meter(&self, scope: &'static str, attributes: Option<&Attributes>) -> Box<dyn Meter>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discuss Should this be -> impl Meter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that would work. Returning impl Meter
would make MeterProvider
not object safe and so we couldn't pass it around as a dyn
everywhere.
From docs:
- All associated functions must either be dispatchable from a trait object or be explicitly non-dispatchable:
- Dispatchable functions must:
- Not have an opaque return type; that is,
- Not have a return position impl Trait type (fn example(&self) -> impl Trait).
- Not have an opaque return type; that is,
- Dispatchable functions must:
callback: Box<dyn Fn(&dyn AsyncMeasurement<Value = f64>) + Send + Sync>, | ||
units: Option<String>, | ||
description: Option<String>, | ||
) -> Box<dyn AsyncMeasurement<Value = f64>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question should these be Box<T>
or should they be impl -> T
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See response above, using impl T
would make these not object safe
#3912 (comment)
#[allow(clippy::type_complexity)] | ||
fn create_gauge( | ||
&self, | ||
name: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should probably be more flexible like impl Into<String>
or impl Into<Cow<'static, str>>
, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that, but once again it makes the Meter
trait no longer object safe
} | ||
|
||
/// Get the set [MeterProvider] | ||
pub fn meter_provider(&self) -> &(dyn MeterProvider + Send + Sync) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this return impl MeterProvider + Send + Sync
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you can return a reference to an impl Trait
, and I didn't want to hand ownership of the MeterProvider
to the caller, so settled for the &dyn
that is there now.
//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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several of these modules probably should be private and just re-export their type instead.
use aws_smithy_observability::Error;
use aws_smithy_observability::Attributes`
vs
use aws_smithy_observability::error::Error;
use aws_smithy_observability::attributes::Attributes`
In other words consider how you'd like the API to be exposed and consumed.
Also missing docs on public modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some pub use
s for these types in 0559e8b
The public modules are already documented, but the docs are in the module file instead of in lib.rs
. I prefer keeping them there because I think it is cleaner than putting them all in lib.rs
, but will move them if that is a consensus.
} | ||
|
||
/// Collects a set of events with an event count and sum for all events. | ||
pub trait Histogram { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to consider whether we want to force (or need) instrument types to implement Clone
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sized
is a supertrait of Clone
and Sized
supertraits break object safety
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work! Will circle back, leaving initial comments...
A new generated diff is ready to view.
A new doc preview is ready to view. |
I see that the design specifies an async API such as |
71cd2ef
to
0559e8b
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
The |
A new generated diff is ready to view.
A new doc preview is ready to view. |
fbba9b4
to
88c9f4c
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
88c9f4c
to
f1f5be2
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the great work! Left the final round of comments.
A new generated diff is ready to view.
A new doc preview is ready to view. |
9f0df17
to
4e11e53
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
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
Co-authored-by: Zelda Hessler <zhessler@amazon.com>
Aligns with standard introduced in #3065 Update doc comments External types updates
Remove non-public type from docs
b964231
to
05bb688
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
Motivation and Context
We would like to have a consistent way to measure the performance of the SDK going forward so we can evaluate how updates change the performance over time. The changes in this PR are a first step towards that, adding the interfaces (and one implementation) that we will use to instrument our runtime crates.
Description
Add two new crates
aws-smithy-observability
- contains traits for our observability solution and aglobal
module for managing the global telemetry provideraws-smithy-observability-otel
- contains an OpenTelemetry based implementation of the traitsTesting
Added new tests in both crates
Checklist
Note: leaving out a changelog entry for now since these crates are somewhat useless 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.