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

Prisma Client always receive engine spans even when not tracing #14842

Closed
millsp opened this issue Aug 17, 2022 · 2 comments · Fixed by #14910
Closed

Prisma Client always receive engine spans even when not tracing #14842

millsp opened this issue Aug 17, 2022 · 2 comments · Fixed by #14910
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: tracing
Milestone

Comments

@millsp
Copy link
Member

millsp commented Aug 17, 2022

It looks like the engine always emits spans regardless of whether we send it a traceparent for an operation or not. I think this could cause performance issues if we always emit spans even for users that are not actually using otel?

On the client side, we receive a parent_span_id of 000000000000 when we land in this situation. This came up while testing sampling for the documentation section. An easy way to reproduce this is to use a sampler but set to sample nothing, then see how engine spans are still being emitted. Might be useful to add it as a regression test:

  const provider = new BasicTracerProvider({
    sampler: new TraceIdRatioBasedSampler(0),
    resource: new Resource({
      // we can define some metadata about the trace resource
      [SemanticResourceAttributes.SERVICE_NAME]: "basic-service",
      [SemanticResourceAttributes.SERVICE_VERSION]: "1.0.0",
    }),
  });

_Originally posted by @millsp in https://github.com/prisma/team-orm/issues/150

Potential Solution:
Stop passing undefined as traceId

@millsp millsp added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. tech/typescript Issue for tech TypeScript. team/client Issue for team Client. topic: tracing priority/high labels Aug 17, 2022
@millsp millsp changed the title Prisma Client always received engine spans even when not tracing Prisma Client always receive engine spans even when not tracing Aug 17, 2022
@garrensmith
Copy link
Contributor

The engine will obey the traceflags settings that are passed to it in the traceparent.
So if the final two fields are 00 it will not emit the spans.
We need something like this:

if (span?.traceFlags === 0 /** if we are tracing */) {
    return `00-${span.traceId}-${span.spanId}-00`
  }

in the getParentSpan.ts file

@millsp
Copy link
Member Author

millsp commented Aug 17, 2022

Thanks, I forgot to update my original comment 🤦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/typescript Issue for tech TypeScript. topic: tracing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants