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

  1. Ensure Config is populated from parsed YAML (map[string]interface{} or yaml.Node), not arbitrary Go values
  2. Marshal the value standalone to identify the offending field
  3. 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

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


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, nil

View on GitHub (pinned to 35b8b99117)