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

Allow clients to define custom callbacks to handle telemetry #1080

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

aws-hans-pistor
Copy link

@aws-hans-pistor aws-hans-pistor commented Oct 23, 2024

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:

  • emit extended request ids ("x-amz-id-2")
  • When some criteria is met, log out additional information

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

@@ -1341,6 +1358,10 @@ impl ObjectClient for S3CrtClient {
}
}

pub trait OnTelemetry: std::fmt::Debug + Send + Sync {
Copy link
Author

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

Copy link
Member

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;

Copy link
Author

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

Copy link
Author

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.

@@ -1341,6 +1358,10 @@ impl ObjectClient for S3CrtClient {
}
}

pub trait OnTelemetry: std::fmt::Debug + Send + Sync {
Copy link
Member

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;

mountpoint-s3-client/src/s3_crt_client.rs Outdated Show resolved Hide resolved
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>
Signed-off-by: Hans Pistor <hpistor@amazon.com>
Signed-off-by: aws-hans-pistor <133711035+aws-hans-pistor@users.noreply.github.com>
@aws-hans-pistor
Copy link
Author

Another merge conflict with mainline

@vladem Can you restart the test runs again?

@aws-hans-pistor
Copy link
Author

Interface has changed, I will have to resolve this locally.

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