Skip to content

Conversation

@abhishekg999
Copy link
Contributor

No description provided.

@linear
Copy link

linear bot commented Nov 18, 2025

@gemini-code-assist
Copy link

Summary of Changes

Hello @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

  • Experimental Span Filter Sampler: Introduced a new ExperimentalSpanFilterSampler that allows users to define a custom function to filter spans based on their attributes, providing fine-grained control over which spans are recorded and processed.
  • Custom Span Processors: Implemented JudgmentSpanProcessor and NoOpSpanProcessor to manage how spans are processed before being exported, enhancing the flexibility and extensibility of the tracing pipeline.
  • Tracer Configuration Updates: Refactored BaseTracer, BrowserTracer, and NodeTracer to accept and integrate custom Sampler instances and utilize the new JudgmentSpanProcessor, allowing for more advanced tracing configurations.
  • Version Bump: The package version has been updated from 0.7.2 to 0.7.3.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

Comment on lines 31 to 41
// @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,
);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

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.

Copy link
Contributor Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This console.log(span) appears to be for debugging purposes. It should be removed from the example code to avoid polluting the console output for users.

@abhishekg999 abhishekg999 merged commit f081fc8 into main Nov 19, 2025
1 check passed
@abhishekg999 abhishekg999 deleted the abhishek/jud-2944-support-filtering-spans-for-the-otel-exporters branch November 19, 2025 05:02
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.

2 participants