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 to not record a span without a parent for automatic XMLHttpRequest and Fetch Instrumentations #3482

Closed
dukesilverr opened this issue Dec 11, 2022 · 3 comments

Comments

@dukesilverr
Copy link

Is your feature request related to a problem? Please describe.

About our current application setup: both client (NextJS+ReactJS) and a gateway/proxy for BE APIs are running on the same node/domain.

In our project we are using manual browser tracing as well as automatic instrumentations, which track the outgoing requests: Fetch and XmlHttpRequest. In order to avoid spamming the export with unnecessary data, we would like to ignore the automatically created spans which are parentless: requests not originating from manual browser traces, which cover specific UI actions, should be ignored/not recorded.

Describe the solution you'd like

Improve Fetch and XmlHttpRequest automatic instrumentations by adding a configuration option which when set to true would allow to not record the spans that were initiated without having a parent span in the context.

1  /**
2   * Flag identifying whether the parent span is required to record a span for XMLHttpRequest requests.
3   */
4  requireParentSpan?: boolean;

Ignoring/not recording a span could be implemented in a similar manner as for Http instrumentation: opentelemetry-js/http.ts at main · open-telemetry/opentelemetry-js or ignoreUrls functionality.

Describe alternatives you've considered

ignoreUrls configuration is used to partially cover our project needs: ignore some blacklisted URL paths and all outgoing requests which do not originate from the same application domain. Nevertheless, some of the HTTP requests depending on an application flow can be children of manual browser traces and standalone (these should be ignored). This also increases the cost of maintaining all of the URLs, newly added outgoing calls, and just does not cover the idea of tracking only specific UI actions.

We have also extended xml http instrumentation to ignore parentless spans on our side, although the implementation was impacted by limited extension points.
Nevertheless, fetch instrumentation implementation was not customized: in order to fulfill this requirement on project side it would require to reimplement/copy/maintain whole functionality of the instrumentation.

Additional context

Related spec discussion: open-telemetry/opentelemetry-specification#530.
I would like to make a PR for this feature if accepted.

@t2t2
Copy link
Contributor

t2t2 commented Dec 14, 2022

How about suppressTracing (already used by exporters to avoid creating spans for exporting - see example) or doing the logic in a sampler?

@github-actions
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Feb 13, 2023
@github-actions
Copy link

This issue was closed because it has been stale for 14 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants