{"record":{"id":"25cc3495dd6fe47e","repo":"dagger/dagger","slug":"failed-to-create-fulltotal-metric-w","errorCode":null,"errorMessage":"failed to create fullTotal metric: %w","messagePattern":"failed to create fullTotal metric: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/engineutil/resources/cpustat.go","lineNumber":134,"sourceCode":"\t\tcpuPressureFilePath: filepath.Join(cgroupPath, cpuPressureFile),\n\t\tcommonAttrs:         commonAttrs,\n\t}\n\tvar err error\n\n\ts.someTotal, err = meter.Int64Gauge(telemetry.CPUStatPressureSomeTotal,\n\t\tmetric.WithUnit(telemetry.MicrosecondUnitName),\n\t\tmetric.WithDescription(\"The total time that any task in the container has been throttled due to CPU pressure\"),\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create someTotal metric: %w\", err)\n\t}\n\n\ts.fullTotal, err = meter.Int64Gauge(telemetry.CPUStatPressureFullTotal,\n\t\tmetric.WithUnit(telemetry.MicrosecondUnitName),\n\t\tmetric.WithDescription(\"The total time that all tasks in the container have simultaneously been throttled due to CPU pressure\"),\n\t)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create fullTotal metric: %w\", err)\n\t}\n\n\treturn s, nil\n}\n\ntype cpuPressureSample struct {\n\tsomeTotal int64GaugeSample\n\tfullTotal int64GaugeSample\n}\n\nfunc (s *cpuPressureSampler) sample(ctx context.Context) error {\n\tsample := cpuPressureSample{\n\t\tsomeTotal: newInt64GaugeSample(s.someTotal, s.commonAttrs),\n\t\tfullTotal: newInt64GaugeSample(s.fullTotal, s.commonAttrs),\n\t}\n\n\tbs, err := os.ReadFile(s.cpuPressureFilePath)\n\tswitch {","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/engine/engineutil/resources/cpustat.go#L116-L152","documentation":"This error wraps the failure of meter.Int64Gauge when creating the CPU pressure 'fullTotal' gauge (telemetry.CPUStatPressureFullTotal) in newCPUPressureSampler. The OpenTelemetry meter refuses to create the instrument, typically because the instrument name violates OTel naming rules or the meter/provider is misconfigured or shutdown. The sampler cannot be constructed, so NewSampler fails and no CPU pressure metrics are collected.","triggerScenarios":"Calling NewSampler (which builds newCPUPressureSampler) while the OTel meter fails to instantiate an Int64Gauge named per telemetry.CPUStatPressureFullTotal — e.g. a meter from a shut-down or broken MeterProvider, or an instrument name/invalid configuration rejected by the SDK.","commonSituations":"Initializing the resource sampler before otel.SetMeterProvider or after the provider was shut down; using a no-op/global meter with an SDK that enforces instrument-name conventions; duplicate instrument registration conflicts in custom SDK builds.","solutions":["Verify the OTel MeterProvider is installed and not shut down before NewSampler is called (otel.SetMeterProvider with a working SDK exporter).","Check the wrapped error (%w cause) for instrument-name validation messages; ensure telemetry.CPUStatPressureFullTotal produces a valid OTel instrument name.","Confirm the metric SDK in use supports Int64Gauge (gauge instruments require otel SDK >= v1.19/semconv support); upgrade go.opentelemetry.io/otel if needed.","Add a test that constructs NewSampler with the real MeterProvider to catch registration regressions early."],"exampleFix":"// before\nmeter := otel.Meter(\"\") // provider never set / already shut down\ns, err := resources.NewSampler(ctx, cgroupPath, meter, attrs)\n// after\notel.SetMeterProvider(sdkmetric.NewMeterProvider())\nmeter := otel.Meter(\"dagger/engine\")\ns, err := resources.NewSampler(ctx, cgroupPath, meter, attrs)","handlingStrategy":"try-catch","validationCode":"if otel.GetMeterProvider() == noop.NewMeterProvider() { return errors.New(\"no MeterProvider configured before NewSampler\") }","typeGuard":"func isOTelInitErr(err error) bool { return err != nil && strings.Contains(err.Error(), \"failed to create\") }","tryCatchPattern":"sampler, err := resources.NewSampler(ctx, cgroupPath, meter, attrs)\nif err != nil {\n    log.Warn(\"resource metrics disabled\", \"err\", err)\n    sampler = nil // fall back to running without telemetry\n}","preventionTips":["Always call otel.SetMeterProvider before constructing samplers.","Only shut down the MeterProvider after samplers are stopped.","Pin go.opentelemetry.io/otel to a version supporting Int64Gauge.","Add a CI test that constructs NewSampler with the real SDK."],"tags":["opentelemetry","metrics","instrument-creation"],"backgroundTag":"otel-instrument-creation-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}