{"record":{"id":"7bec815ad628969b","repo":"grafana/k6","slug":"providing-service-version-is-required","errorCode":null,"errorMessage":"providing service version is required","messagePattern":"providing service version is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/output/opentelemetry/config.go","lineNumber":215,"sourceCode":"\t\tcfg.HTTPUsername = v.HTTPUsername\n\t}\n\n\tif v.HTTPPassword.Valid {\n\t\tcfg.HTTPPassword = v.HTTPPassword\n\t}\n\n\treturn cfg\n}\n\n// Validate validates the config\nfunc (cfg Config) Validate() error {\n\tif cfg.ServiceName.String == \"\" {\n\t\treturn errors.New(\"providing service name is required\")\n\t}\n\t// TODO: it's not actually required, but we should probably have a default\n\t// check if it works without it\n\tif cfg.ServiceVersion.String == \"\" {\n\t\treturn errors.New(\"providing service version is required\")\n\t}\n\tif err := cfg.validateExporterProtocol(); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc (cfg Config) validateExporterProtocol() error {\n\tif cfg.ExporterProtocol.String != \"\" {\n\t\tif cfg.ExporterProtocol.String != grpcExporterProtocol && cfg.ExporterProtocol.String != httpExporterProtocol {\n\t\t\treturn fmt.Errorf(\n\t\t\t\t\"unsupported exporter protocol %q, only %q and %q are supported\",\n\t\t\t\tcfg.ExporterProtocol.String,\n\t\t\t\tgrpcExporterProtocol,\n\t\t\t\thttpExporterProtocol,\n\t\t\t)\n\t\t}\n\t\tswitch cfg.ExporterProtocol.String {","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/output/opentelemetry/config.go#L197-L233","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nexport K6_OTEL_SERVICE_NAME=my-service\n# K6_OTEL_SERVICE_VERSION missing -> error\n\n# after\nexport K6_OTEL_SERVICE_NAME=my-service\nexport K6_OTEL_SERVICE_VERSION=1.0.0","handlingStrategy":"validation","validationCode":": \"${K6_OTEL_SERVICE_NAME:?required}\" : \"${K6_OTEL_SERVICE_VERSION:?required}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["k6","opentelemetry","otlp","config","service-version"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}