-
Notifications
You must be signed in to change notification settings - Fork 170
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
Allow clients to define custom callbacks to handle telemetry #1080
base: main
Are you sure you want to change the base?
Allow clients to define custom callbacks to handle telemetry #1080
Conversation
@@ -1341,6 +1358,10 @@ impl ObjectClient for S3CrtClient { | |||
} | |||
} | |||
|
|||
pub trait OnTelemetry: std::fmt::Debug + 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've defined a trait since I find it a little more readable than raw Fn
types, let me know if you prefer differently
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 have a strong opinion, but elsewhere in this crate we do it as a type alias, so maybe we should match that idiom:
type ReviewCallback = dyn FnOnce(UploadReview) -> bool + Send; |
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.
That's fair, I can swap to a type alias
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.
Actually this is not possible
S3ClientConfig
requires that everything implements std::fmt::Debug, and type aliases can only implement auto-traits.
79131f5
to
98df814
Compare
@@ -1341,6 +1358,10 @@ impl ObjectClient for S3CrtClient { | |||
} | |||
} | |||
|
|||
pub trait OnTelemetry: std::fmt::Debug + 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 have a strong opinion, but elsewhere in this crate we do it as a type alias, so maybe we should match that idiom:
type ReviewCallback = dyn FnOnce(UploadReview) -> bool + Send; |
3000b47
to
88a2a1f
Compare
Different users of mountpoint will care about different metrics returned for each requests, so allow them to define their own custom handlers for the on_telemetry callback in addition to the default metrics that mountpoint emits. Signed-off-by: Hans Pistor <hpistor@amazon.com>
b76885d
to
4f41293
Compare
Signed-off-by: Hans Pistor <hpistor@amazon.com>
Signed-off-by: aws-hans-pistor <133711035+aws-hans-pistor@users.noreply.github.com>
Another merge conflict with mainline @vladem Can you restart the test runs again? |
Interface has changed, I will have to resolve this locally. |
Description of change
Different users of mountpoint will care about different metrics returned for each requests, so allow them to define their own custom handlers for the on_telemetry callback in addition to the default metrics that mountpoint emits.
This allows users to do things like:
Relevant issues: #1079
Does this change impact existing behavior?
No there should be no breaking changes, the only visible change is that there's a new field to the S3ClientConfig which defines the custom telemetry handler
Does this change need a changelog entry in any of the crates?
Just a note in mountpoint-s3-client letting users know this feature now exists
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and I agree to the terms of the Developer Certificate of Origin (DCO).