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 libraries to suppress tracing without taking a dependency on core #4025

Closed
nordfjord opened this issue Jul 27, 2023 · 6 comments
Closed
Labels
feature-request pkg:api pkg:core stale up-for-grabs Good for taking. Extra help will be provided by maintainers

Comments

@nordfjord
Copy link
Contributor

I'm instrumenting one of my libraries with opentelemetry and am running into a scenario where I'd like to suppress instrumentation to ensure my users don't incur undue costs by using my library. In particular I have a loop that polls for new data from a database and forwards the data to a handler

while (!signal.aborted) {
  const batch = await nextBatch()
  await handler(batch.items)
  if (!batch.hasMore) await sleep(100)
}

under the hood nextBatch makes a database call and therefore creates a span.
In this case I'd be emitting a span every 100ms or so, but this span would have little to no value. What I'd like to do is some form of head sampling, only emitting one of these spans every 5 minutes

let lastSampledSpan = Date.now()
const updateTime = x => { lastSampledSpan = Date.now(); return x }
while (!signal.aborted) {
  const batch = Date.now() - lastSampledSpan > 3e5
    ? await nextBatch().then(updateTime)
    : await context.with(suppressTracing(context.active()), nextBatch)
  await handler(batch.items)
  if (!batch.hasMore) await sleep(100)
}

But this forces me to take a dependency on @opentelemetry/core rather than just the API.

Describe the solution you'd like

I'd like suppressTracing to be exposed through the api rather than the core package

@Flarna
Copy link
Member

Flarna commented Jul 30, 2023

There is an "ongoing" discussion in API spec regarding this: see open-telemetry/opentelemetry-specification#530 and open-telemetry/opentelemetry-specification#3103

I fear as long as spec part is not finished it's hard to get this into API.

@open-telemetry/javascript-maintainers Has there anything changed regarding this? Not sure but I think there were discussions regarding adding some sort of "experimental"/"unstable" area in API which would be a fit for quite some parts of core.

@legendecas
Copy link
Member

I think following the discussion here #3827 (comment) is a good path forward to merge this feature into the api package.

@pichlermarc
Copy link
Member

It looks like #3827 is not being worked on for now, so anyone who wants to pick this up would have to lay the groundwork for adding such an experimental API area (see #3827 (comment)). Having this feature in an experimental API area would be a great step forward while the spec discussion is still pending.

I'll mark this as up for grabs in case someone wants to pick this up.

@pichlermarc pichlermarc added the up-for-grabs Good for taking. Extra help will be provided by maintainers label Sep 28, 2023
Copy link

github-actions bot commented Dec 4, 2023

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 Dec 4, 2023
@pichlermarc pichlermarc removed the stale label Dec 4, 2023
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 12, 2024
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 Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request pkg:api pkg:core stale up-for-grabs Good for taking. Extra help will be provided by maintainers
Projects
None yet
Development

No branches or pull requests

4 participants