thanos-io/thanos · error
marshal content of tracing configuration
Error message
marshal content of tracing configuration
What it means
After strict-unmarshalling TracingConfig, NewTracer re-marshals the nested tracingConf.Config (the backend-specific settings) back to YAML to feed the vendor tracer constructor. This error wraps a yaml.Marshal failure of that config value. It is rare and indicates the parsed config cannot be serialized (e.g. an unsupported value type was programmatically injected).
Solutions
- Ensure Config is populated from parsed YAML (map[string]interface{} or yaml.Node), not arbitrary Go values
- Marshal the value standalone to identify the offending field
- Upgrade Thanos; marshal failures on plain YAML-loaded maps are library bugs
Defensive patterns
Strategy: try-catch
Validate before calling
// Only construct TracingConfig from parsed YAML; never inject raw Go values into Config
if tracingConf.Config != nil {
if _, err := yaml.Marshal(tracingConf.Config); err != nil {
return fmt.Errorf("tracing Config value not YAML-marshalable: %w", err)
}
} Try / catch
tracer, closer, err := tracing.NewTracer(ctx, logger, reg, cfgYaml)
if err != nil && strings.Contains(err.Error(), "marshal content of tracing configuration") {
logger.Error(err, "tracing Config contains non-marshalable values; load it from YAML")
return err
} Prevention
- Populate TracingConfig only via yaml.Unmarshal, not by hand-built structs with exotic types
- Avoid embedding funcs/channels/custom non-marshalable types in Config
- If this fires from plain YAML, report as a library bug and upgrade Thanos
When it happens
Trigger: tracingConf.Config is non-nil but contains values yaml.Marshal cannot represent (custom types, channels, funcs) — typically only when TracingConfig is constructed in code rather than parsed from YAML.
Common situations: Embedding Thanos tracing config programmatically with non-marshalable Go values inside Config; usually not hit via normal YAML-flag loading.
Understand the failure class
Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.
Related errors
- parsing config tracing YAML
- error while parsing config for request logging
- error while parsing tsdb selector configuration
- parse limit configuration
- error while parsing config for request logging
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/a9c342aebe84660a.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/tracing/client/factory.go:55
type TracingConfig struct {
Type TracingProvider `yaml:"type"`
Config any `yaml:"config"`
}
func NewTracer(ctx context.Context, logger log.Logger, metrics *prometheus.Registry, confContentYaml []byte) (opentracing.Tracer, io.Closer, error) {
level.Info(logger).Log("msg", "loading tracing configuration")
tracingConf := &TracingConfig{}
if err := yaml.UnmarshalStrict(confContentYaml, tracingConf); err != nil {
return nil, nil, errors.Wrap(err, "parsing config tracing YAML")
}
var config []byte
var err error
if tracingConf.Config != nil {
config, err = yaml.Marshal(tracingConf.Config)
if err != nil {
return nil, nil, errors.Wrap(err, "marshal content of tracing configuration")
}
}
switch strings.ToUpper(string(tracingConf.Type)) {
case string(Stackdriver), string(GoogleCloud):
tracerProvider, err := google_cloud.NewTracerProvider(ctx, logger, config)
if err != nil {
return nil, nil, err
}
tracer, closerFunc := migration.Bridge(tracerProvider, logger)
return tracer, closerFunc, nil
case string(Jaeger):
tracerProvider, err := jaeger.NewTracerProvider(ctx, logger, config)
if err != nil {
return nil, nil, errors.Wrap(err, "new tracer provider err")
}
tracer, closerFunc := migration.Bridge(tracerProvider, logger)
return tracer, closerFunc, nilView on GitHub (pinned to 35b8b99117)