Skip to content

How to make a custom SamplingDecision for a started span? #1379

Closed

Description

@un000

Hi!

I have a service that starts tracing with a given ratio:

	jaeger.WithSDK(&trace.Config{DefaultSampler: trace.TraceIDRatioBased(0.001)}),

So I want to override this Sampler with a trace.AwlaysSampler like I did it with opencensus.

		opts := []trace.SpanOption{trace.WithNewRoot(), trace.WithSpanKind(trace.SpanKindServer)}
		forceTrace := len(reqCtx.Request.Header.Peek("X-Force-Trace")) > 0
		if forceTrace {
			opts = append(opts, trace.WithRecord())
		}

		tr := otel.Tracer(tracer.DefaultInstrumentationName)
		ctxWithSpan, span := tr.Start(ctx, name, opts...)

trace.WithRecord() enables recording but doesn't affect the sampling decision.

How to achieve 100% sampling by a flag?

Activity

  1. locked and limited conversation to collaborators on Apr 6, 2021
  2. added this to the untracked milestone on Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions