-
Notifications
You must be signed in to change notification settings - Fork 25
feat(opentelemetry): do not trace prometheus requests by default #1653
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
Conversation
Summary of ChangesHello @EmrysMyrddin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the OpenTelemetry plugin by implementing a default mechanism to prevent tracing of Prometheus metrics scraping requests. This change aims to streamline observability data by focusing on more relevant application traffic, thereby improving the signal-to-noise ratio in tracing logs. The implementation includes careful handling of existing configuration to ensure the default filter is only applied when no explicit HTTP span filtering is already in place. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces a default filter to exclude Prometheus scraping requests from OpenTelemetry tracing, which is a sensible default. The configuration types for traces have been nicely refactored for better readability and structure.
I've found a critical issue in the implementation logic for applying the default filter. The current code could lead to a runtime TypeError and also incorrectly overwrites existing user configurations for spans. I've provided a detailed comment with a suggested fix to address this.
Other than that, the changes look good and the new filter function is implemented correctly.
cf76cf9 to
438fd6e
Compare
|
|
||
| export const defaultHttpFilter: SpansConfig['http'] = ({ request }) => { | ||
| // Ignore Prometheus requests | ||
| if (request.url.endsWith('/metrics')) { |
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.
This assumes that prometheus metrics are always at /metrics. But it is configurable in Prometheus plugin, no?
Maybe we can have a shared flag to decide if the request is prom request?
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.
Humm difficult to do, because this will be executed before even the onRequest hook.
Or the prometheus plugin have to also implement instrument.request to mark the request (which is a possibility of course)
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.
It's not very simple to do, because you end up again with plugin order issues ^^'
So it's more fragile in programmatic usage where we don't control the plugin order. And it also means that this little bit of code will not be inside the span.
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 refactored, let me know what you think :-)
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.
Looks better!
🚀 Snapshot Release (
|
| Package | Version | Info |
|---|---|---|
@graphql-hive/gateway |
2.1.14-alpha-92fb9e27adca3c259f49fa971532a994c6882f81 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/nestjs |
2.0.19-alpha-92fb9e27adca3c259f49fa971532a994c6882f81 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/plugin-aws-sigv4 |
2.0.14-alpha-92fb9e27adca3c259f49fa971532a994c6882f81 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/plugin-deduplicate-request |
2.0.6-alpha-92fb9e27adca3c259f49fa971532a994c6882f81 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/plugin-opentelemetry |
1.1.0-alpha-92fb9e27adca3c259f49fa971532a994c6882f81 |
npm ↗︎ unpkg ↗︎ |
@graphql-mesh/plugin-prometheus |
2.1.0-alpha-92fb9e27adca3c259f49fa971532a994c6882f81 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/gateway-runtime |
2.3.2-alpha-92fb9e27adca3c259f49fa971532a994c6882f81 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/gateway-testing |
2.0.2-alpha-92fb9e27adca3c259f49fa971532a994c6882f81 |
npm ↗︎ unpkg ↗︎ |
@graphql-mesh/transport-http |
1.0.10-alpha-92fb9e27adca3c259f49fa971532a994c6882f81 |
npm ↗︎ unpkg ↗︎ |
🚀 Snapshot Release (Bun Docker Image)The latest changes of this PR are available as image on GitHub Container Registry (based on the declared |
🚀 Snapshot Release (Node Docker Image)The latest changes of this PR are available as image on GitHub Container Registry (based on the declared |
|
There is a security check fail because of a CVE in a deps of npm. |
ee0794b to
c376a64
Compare
c376a64 to
92fb9e2
Compare
Description
This PR adds a default filter for HTTP spans to ignore prometheus metrics scraping requests.
Those request are not interesting to trace or monitor.
Details
The logic can look a bit complex for such a simple option. I have to set this default filter only if the configuration doesn't already contain a filter function for http spans. But TypeScript makes it difficult because it is not happy about accessing field or doing spreading on boolean (which would actually work but hey, that would be too easy it suppose).
Related to GW-482