grafana/k6 · error
providing service version is required
Error message
providing service version is required
What it means
Thrown by Config.Validate() for the OpenTelemetry output when the service version is empty. Alongside service.name, k6 requires service.version for the resource attributes it exports; the code notes it is 'not actually required' by OTLP but is enforced as a mandatory setting (see the TODO in the source).
Source
Thrown at internal/output/opentelemetry/config.go:215
cfg.HTTPUsername = v.HTTPUsername
}
if v.HTTPPassword.Valid {
cfg.HTTPPassword = v.HTTPPassword
}
return cfg
}
// Validate validates the config
func (cfg Config) Validate() error {
if cfg.ServiceName.String == "" {
return errors.New("providing service name is required")
}
// TODO: it's not actually required, but we should probably have a default
// check if it works without it
if cfg.ServiceVersion.String == "" {
return errors.New("providing service version is required")
}
if err := cfg.validateExporterProtocol(); err != nil {
return err
}
return nil
}
func (cfg Config) validateExporterProtocol() error {
if cfg.ExporterProtocol.String != "" {
if cfg.ExporterProtocol.String != grpcExporterProtocol && cfg.ExporterProtocol.String != httpExporterProtocol {
return fmt.Errorf(
"unsupported exporter protocol %q, only %q and %q are supported",
cfg.ExporterProtocol.String,
grpcExporterProtocol,
httpExporterProtocol,
)
}
switch cfg.ExporterProtocol.String {View on GitHub (pinned to 93accf6570)
Solutions
- Set K6_OTEL_SERVICE_VERSION, typically to the k6 script/application version, e.g. K6_OTEL_SERVICE_VERSION=1.0.0
- Or include it in the output argument: -o experimental-opentelemetry="serviceName=myservice,serviceVersion=1.0.0"
- If automating, default it to the k6 binary version in your wrapper script
Example fix
# before export K6_OTEL_SERVICE_NAME=my-service # K6_OTEL_SERVICE_VERSION missing -> error # after export K6_OTEL_SERVICE_NAME=my-service export K6_OTEL_SERVICE_VERSION=1.0.0
Defensive patterns
Strategy: validation
Validate before calling
: "${K6_OTEL_SERVICE_NAME:?required}" : "${K6_OTEL_SERVICE_VERSION:?required}" Prevention
- Set name and version in the same env block so one is never missing
- Default the version to the script's git SHA or semver in CI
- Add a smoke run (k6 inspect or a 1s test) in CI to catch output config errors early
When it happens
Trigger: Running -o experimental-opentelemetry with K6_OTEL_SERVICE_NAME set but K6_OTEL_SERVICE_VERSION empty or unset; empty-string serviceVersion in the JSON config; whitespace-only value via env var.
Common situations: Users who set only the service name because upstream OTel collectors don't demand a version; CI that passes the k6 version dynamically and the variable expands to empty; copied configs from older k6 versions where version was optional.
Related errors
- providing service name is required
- gRPC exporter endpoint is required
- HTTP exporter endpoint is required
- HTTP exporter endpoint must only be host and port, no scheme
- unsupported exporter protocol %s
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/7bec815ad628969b.
Report an issue: GitHub.