:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
pub const METRICS_AVRO_SCHEMA: &str = r#"
{
"type": "record",
"name": "MetricRecord",
"doc": "Schema for an OTEL metric data point.",
"fields": [
{
"name": "uuid",
"type": ["null", "string"],
"doc": "Unique identifier for the metric record."
},
{
"name": "trace_id",
"type": ["null", "bytes"],
"doc": "Identifier for the trace this metric is associated with."
},
{
"name": "span_id",
"type": ["null", "bytes"],
"doc": "Identifier for the span within the trace."
},
{
"name": "trace_flags",
"type": ["null", "int"],
"doc": "Flags associated with the trace."
},
{
"name": "timestamp",
"type": ["null", {
"type": "long",
"logicalType": "timestamp-micros"
}],
"doc": "The primary timestamp of the data point, in microseconds since epoch."
},
{
"name": "observed_timestamp",
"type": ["null", {
"type": "long",
"logicalType": "timestamp-micros"
}],
"doc": "The timestamp when the metric was ingested, in microseconds since epoch."
},
{
"name": "service_name",
"type": ["null", "string"],
"doc": "The name of the service that generated the metric."
},
{
"name": "metric_name",
"type": ["null", "string"],
"doc": "The name of the metric (e.g., 'system.cpu.utilization')."
},
{
"name": "metric_type",
"type": ["null", "string"],
"doc": "The type of metric: gauge, sum, histogram, summary, exponential_histogram."
},
{
"name": "value",
"type": ["null", "double"],
"doc": "The primary numeric value of the data point."
},
{
"name": "count",
"type": ["null", "long"],
"doc": "Count for histogram/summary data points, or 1 for simple data points."
},
{
"name": "histogram_bounds",
"type": ["null", {
"type": "array",
"items": "double"
}],
"doc": "Explicit bucket boundaries for histogram metrics."
},
{
"name": "histogram_counts",
"type": ["null", {
"type": "array",
"items": "long"
}],
"doc": "Bucket counts for histogram metrics."
},
{
"name": "unit",
"type": ["null", "string"],
"doc": "The unit of the metric (e.g., 'bytes', 'seconds', '1')."
},
{
"name": "aggregation_temporality",
"type": ["null", "string"],
"doc": "Aggregation temporality: delta or cumulative."
},
{
"name": "is_monotonic",
"type": ["null", "boolean"],
"doc": "Whether the sum is monotonic (counter vs up-down counter)."
},
{
"name": "resource_attributes",
"type": ["null", {
"type": "map",
"values": "string"
}],
"doc": "Attributes describing the resource that produced the metric."
},
{
"name": "instrumentation_scope",
"type": ["null", "string"],
"doc": "The name of the library or framework that captured the metric."
},
{
"name": "attributes",
"type": ["null", {
"type": "map",
"values": "string"
}],
"doc": "A map of custom string-valued attributes associated with the data point."
},
{
"name": "series_fingerprint",
"type": ["null", "long"],
"default": null,
"doc": "Stable per-series identity assigned at ingest (hash of metric_name, metric_type, service_name, and sorted resource/data-point attributes). Stored verbatim by ClickHouse, never recomputed. u64 bits carried as a signed long."
},
{
"name": "has_labels",
"type": "boolean",
"default": true,
"doc": "True when this record carries the series labels (attributes). ClickHouse writes the series and attribute rollups only from records with has_labels set; a record without the field counts as labelled."
},
{
"name": "retention_days",
"type": ["null", "int"],
"default": null,
"doc": "Per-row retention in days. Null when unset - ClickHouse then falls back to the batch `retention-days` header, then to its default. capture-logs always writes null; it does not evaluate team rules."
}
]
}"#;