grafana/k6 · error
providing service version is required
Error message
providing service version is required
What it means
The OpenTelemetry metrics output requires a service version for the exported resource. k6 defaults it to the k6 build version, but Validate() rejects the config when ServiceVersion.String is empty — typically because K6_OTEL_SERVICE_VERSION or the JSON output config overrode the default with an empty string. The code even carries a TODO noting the requirement is arguably artificial, but it is enforced.
Solutions
- Set a real value, e.g. export K6_OTEL_SERVICE_VERSION=1.4.2
- Remove the empty K6_OTEL_SERVICE_VERSION from the environment so the k6 version default applies
- Populate the variable from the build metadata you already have (git describe, package version) in CI
Example fix
# before export K6_OTEL_SERVICE_VERSION= k6 run -o opentelemetry script.js # after export K6_OTEL_SERVICE_VERSION=$(git describe --tags --always) k6 run -o opentelemetry script.js
Defensive patterns
Strategy: validation
Validate before calling
// Shell: treat empty as unset (falls back to k6's version)
[ -z "${K6_OTEL_SERVICE_VERSION:-}" ] && unset K6_OTEL_SERVICE_VERSION
export K6_OTEL_SERVICE_VERSION="${K6_OTEL_SERVICE_VERSION:-$(git describe --tags --always 2>/dev/null || echo dev)}"
k6 run -o opentelemetry script.js Prevention
- Populate the version from build metadata you already produce (git describe, package version)
- Never export an empty K6_OTEL_SERVICE_VERSION placeholder
- Add a pre-flight env check in CI for all required OTel variables
When it happens
Trigger: export K6_OTEL_SERVICE_VERSION= (defined but empty); an output config JSON with "serviceVersion": "".
Common situations: CI placeholder variables left empty; pipelines that set the version only for release builds and leave it blank in dev jobs.
Related errors
- providing service name is required
- both K6_CLOUD_METRICS_PUSH_URL and K6_CLOUD_TEST_RUN_TOKEN…
- failed to append root certificate to the pool
- gRPC exporter endpoint is required
- grpc protocol does not support URL path
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/7bec815ad628969b.
Report an issue: GitHub.
Appendix: 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 01ffac6f24)