GoogleContainerTools/skaffold · warning

failed to marshal metricdata

Error message

failed to marshal metricdata

What it means

buildProtoStr converts the collected metricdata into a log-entry proto via the firelog Marshal function. If marshaling fails it returns the fixed error "failed to marshal metricdata" (note: it drops the underlying error). The data point cannot be sent because the payload could not be encoded.

Source

Thrown at pkg/skaffold/instrumentation/firelog/exporter.go:168

		LogEvent: LogEvent{
			EventTimeMS:                  startTimeMS,
			SourceExtensionJSONProto3Str: proto,
		},
		RequestTimeMS: startTimeMS,
	}
}

func buildProtoStr(name string, kvs EventMetadata) (string, error) {
	proto3 := SourceExtensionJSONProto3{
		ConsoleType:     "SKAFFOLD",
		ClientInstallID: GetClientInstallID(),
		EventName:       name,
		EventMetadata:   kvs,
	}

	b, err := Marshal(proto3)
	if err != nil {
		return "", fmt.Errorf("failed to marshal metricdata")
	}
	return string(b), nil
}

func toEventMetadata(attributes attribute.Set) EventMetadata {
	kvs := EventMetadata{}
	iterator := attributes.Iter()
	for iterator.Next() {
		attr := iterator.Attribute()
		kv := KeyValue{
			Key:   string(attr.Key),
			Value: attr.Value.Emit(),
		}
		kvs = append(kvs, kv)
	}
	return kvs
}

View on GitHub (pinned to a1189de023)

Solutions

  1. Disable metrics collection to skip export entirely: `skaffold config set --global collect-metrics false`.
  2. Upgrade skaffold — this indicates an internal encoding issue fixed in newer releases.
  3. Report the issue with the skaffold version and command being run, since the underlying marshal error is swallowed.
Defensive patterns

Strategy: try-catch

Try / catch

if err := exportMetrics(ctx, path, meter); err != nil {
    if strings.Contains(err.Error(), "failed to marshal metricdata") {
        // log and skip this data point; do not fail the command
    }
}

Prevention

When it happens

Trigger: Metrics export where proto3 marshaling of the constructed log entry (EventName, EventMetadata from the attribute set) fails — e.g. unexpected field types or values in metric attributes.

Common situations: Metric attributes containing values that cannot be encoded into the firelog proto; internal incompatibility between the collected metric schema and the encoder.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/099f7c3f2a182319. Report an issue: GitHub.