grafana/k6 · error

invalid traces output

Error message

invalid traces output

What it means

k6's --traces-output flag currently accepts only the OpenTelemetry output, identified by the literal token 'otel' (optionally with parameters: otel=<url>,proto=<grpc|http>,header.<Name>=<value>). tracerProviderParamsFromConfigLine splits the value at '=' and returns ErrInvalidTracesOutput when the part before '=' is not 'otel', i.e. the output type itself is unrecognized.

Solutions

  1. Use --traces-output=otel for defaults (grpc to 127.0.0.1:4317, insecure)
  2. Use the parameterized form, e.g. --traces-output='otel=http://127.0.0.1:4318/v1/traces,proto=http,header.Authorization=token'
  3. Check for typos in the value before '=' — only 'otel' is recognized

Example fix

# before
k6 run --traces-output=otlp script.js
# after
k6 run --traces-output=otel script.js
Defensive patterns

Strategy: validation

Validate before calling

// Shell / wrapper: check the flag before invoking k6
line="$TRACES_OUTPUT"
if [ "$line" != "otel" ] && [ "${line%%=*}" != "otel" ]; then
  echo "--traces-output must start with 'otel'" >&2; exit 1
fi
k6 run --traces-output="$line" script.js

Type guard

function isOtelTracesLine(s) {
  return s === 'otel' || s.startsWith('otel=');
}

Prevention

When it happens

Trigger: Running k6 run --traces-output=otlp or --traces-output=zipkin or any value whose prefix is not 'otel'; also a bare unrecognized word like --traces-output=jaeger.

Common situations: Assuming k6 supports the same trace output names as the OTel collector or other tools ('otlp', 'console'); copy-pasting collector config into the k6 flag; missing that the value must literally be 'otel'.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/6de9121088da750a. Report an issue: GitHub.

Appendix: source

Thrown at internal/lib/trace/otel.go:27

	"go.opentelemetry.io/otel"
	"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
	"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
	"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
	"go.opentelemetry.io/otel/sdk/resource"
	sdktrace "go.opentelemetry.io/otel/sdk/trace"
	semconv "go.opentelemetry.io/otel/semconv/v1.20.0"
	"go.opentelemetry.io/otel/trace"
	"go.opentelemetry.io/otel/trace/noop"

	"go.k6.io/k6/v2/internal/lib/strvals"
)

const serviceName = "k6"

var (
	// ErrInvalidTracesOutput indicates that the defined traces output is not valid.
	ErrInvalidTracesOutput = errors.New("invalid traces output")
	// ErrInvalidProto indicates that the defined exporter protocol is not valid.
	ErrInvalidProto = errors.New("invalid protocol")
	// ErrInvalidURLScheme indicates that the defined exporter URL scheme is not valid.
	ErrInvalidURLScheme = errors.New("invalid URL scheme")
	// ErrInvalidGRPCWithURLPath indicates that an exporter using gRPC protocol does not support URL path.
	ErrInvalidGRPCWithURLPath = errors.New("grpc protocol does not support URL path")
)

type (
	tracerProvShutdownFunc func(ctx context.Context) error
)

// TracerProvider provides methods for tracers initialization and shutdown of the
// processing pipeline.
type TracerProvider struct {
	trace.TracerProvider
	shutdown tracerProvShutdownFunc
}

View on GitHub (pinned to 01ffac6f24)