[go: nahoru, domu]

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

[instrumentation-document-load] option to ignore resource spans #2284

Closed
longility opened this issue Jun 18, 2024 · 4 comments
Closed

[instrumentation-document-load] option to ignore resource spans #2284

longility opened this issue Jun 18, 2024 · 4 comments

Comments

@longility
Copy link
Contributor

If this is acceptable, I can do a PR to expedite our needs and contribute for others to leverage as well.

Is your feature request related to a problem? Please describe

I would like to minimize the number of spans created that may not be important to us, specifically resource spans.

image

Describe the solution you'd like to see

For this line,

to be similar to this:
https://github.com/open-telemetry/opentelemetry-js-contrib/blob/2dc2f72e5a86aa9e1220a26f78878070acde8424/plugins/web/opentelemetry-instrumentation-document-load/src/instrumentation.ts#L160C7-L162C8

to where the end result may look something like this:

      if (!this._getConfig().ignoreResourceSpans) {
        this._addResourcesSpans(rootSpan);
      }

Describe alternatives you've considered

None.

Additional context

None.

@scheler
Copy link
scheler commented Jun 28, 2024

We are working on a new set of instrumentations using the new Events API, one of which is to emit ResourceTiming events for the resources loaded (#2152), and another to emit PageView event (open-telemetry/opentelemetry-sandbox-web-js#81). As part of this effort, I envision an instrumentation to emit a standalone documentFetch span. We have not created an issue yet to track this as this hasn't been discussed much in the Client SIG.

For your use-case does it work if you configure a custom sampler to drop these spans?

@longility
Copy link
Contributor Author

We are working on a new set of instrumentations using the new Events API, one of which is to emit ResourceTiming events for the resources loaded (#2152), and another to emit PageView event (open-telemetry/opentelemetry-sandbox-web-js#81). As part of this effort, I envision an instrumentation to emit a standalone documentFetch span. We have not created an issue yet to track this as this hasn't been discussed much in the Client SIG.

For your use-case does it work if you configure a custom sampler to drop these spans?

@scheler thanks for the status update and a workaround! I think that could be sufficient. Do you know of a sampler that could be a good starting point? I have not done one of those before.

@scheler
Copy link
scheler commented Jun 30, 2024

@longility something like this -

const provider = new WebTracerProvider({
  resource,
  sampler: {
    shouldSample: (context, traceId, spanName, spanKind, attributes, links) => {
      return spanName == 'resourceFetch' ? SamplingDecision.NOT_RECORD : SamplingDecision.RECORD_AND_SAMPLED;
    }
  }
});

@scheler
Copy link
scheler commented Jul 10, 2024

@longility can you close this issue if the workaround works for you?

@longility longility closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2024
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