grafana/k6 · error
invalid protocol
Error message
invalid protocol
What it means
Within the --traces-output=otel=... configuration line, the proto= option selects the exporter transport and accepts exactly 'http' or 'grpc' (default 'grpc'). params.parseProto returns ErrInvalidProto wrapped as "couldn't parse the otel proto" for any other value. Note this is k6's own parameter name — OTel SDK spellings like 'http/protobuf' are not accepted here.
Solutions
- Use proto=http or proto=grpc exactly (lowercase)
- Omit proto= entirely to get the default grpc transport
- If you only need an HTTP endpoint, pass the URL form: otel=http://host:4318/v1/traces (this implies proto=http)
Example fix
# before k6 run --traces-output='otel=127.0.0.1:4318/v1/traces,proto=http/protobuf' script.js # after k6 run --traces-output='otel=http://127.0.0.1:4318/v1/traces,proto=http' script.js
Defensive patterns
Strategy: validation
Validate before calling
// Shell proto="$(echo "$TRACES_OUTPUT" | tr ',' '\n' | grep '^proto=' | cut -d= -f2)" if [ -n "$proto" ] && [ "$proto" != "http" ] && [ "$proto" != "grpc" ]; then echo "proto= must be http or grpc" >&2; exit 1 fi
Type guard
function isValidTraceProto(p) {
return p === '' || p === 'http' || p === 'grpc';
} Prevention
- Use only lowercase http or grpc for the proto option in --traces-output
- Do not paste OTEL_EXPORTER_OTLP_PROTOCOL values (http/protobuf, http/json) into this k6 flag
- Omit proto= when unsure — the grpc default is usually right for a local collector
When it happens
Trigger: Passing --traces-output='otel=...,proto=http/protobuf' (OTel SDK convention instead of k6's 'http'); proto=grpc-web, proto=h2, or any typo such as proto=GRPC (case-sensitive).
Common situations: Copying values from OTEL_EXPORTER_OTLP_PROTOCOL docs or collector configs into k6's traces flag; assuming protocol names are case-insensitive.
Related errors
- grpc protocol does not support URL path
- invalid traces output
- invalid URL scheme
- unsupported exporter protocol
- failed to append root certificate to the pool
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/f16b59a45efced3c.
Report an issue: GitHub.
Appendix: source
Thrown at internal/lib/trace/otel.go:29
"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
}
type tracerProviderParams struct {View on GitHub (pinned to 01ffac6f24)