-
Notifications
You must be signed in to change notification settings - Fork 0
feat: experimental span filter sampler #26
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
feat: experimental span filter sampler #26
Conversation
Summary of ChangesHello @abhishekg999, 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 introduces an experimental span filtering sampler and integrates it into the OpenTelemetry tracing setup. It refactors the core tracer classes to support custom samplers and introduces dedicated span processors, allowing for more granular control over which spans are recorded and processed. This enhancement provides greater flexibility in managing tracing data within the system. 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 an experimental span filter sampler, a useful feature for giving users control over which spans are exported. The implementation is well-structured, adding new span processors and integrating the sampler into the tracer classes. However, the core of the new sampler relies on internal, undocumented APIs of OpenTelemetry, which poses a significant stability risk. I've also identified a couple of areas for improvement, including a leftover debug log in an example and an opportunity to make the code more robust against undefined values.
| // @ts-expect-error - not intended to be public API but exists | ||
| const currentContext = context._currentContext as Map<symbol, unknown>; | ||
| if (!(currentContext instanceof Map)) { | ||
| return { | ||
| decision: SamplingDecision.RECORD_AND_SAMPLED, | ||
| }; | ||
| } | ||
|
|
||
| const spanKey = Array.from(currentContext.keys()).find( | ||
| (key) => key.description === SPAN_KEY_NAME, | ||
| ); |
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 implementation relies on internal, non-public properties of the OpenTelemetry JS Context object (_currentContext) and an internal mechanism for storing the span in the context (finding a symbol key by its description: SPAN_KEY_NAME). This approach is extremely fragile and is highly likely to break with any patch or minor version update of the @opentelemetry/api package. While the 'Experimental' prefix in the class name is appropriate, this poses a critical stability risk. If no public API is available to get the current span during sampling, this feature should be documented with very strong warnings about its brittleness and potential for breaking in future OpenTelemetry JS updates.
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.
no longer here
| projectName: "auto_instrumentation_example", | ||
| instrumentations: [new OpenAIInstrumentation()], | ||
| sampler: new ExperimentalSpanFilterSampler((span) => { | ||
| console.log(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.
No description provided.