A Go library for converting OpenTelemetry Protocol (OTLP) metric and attribute names to Prometheus-compliant formats. This is an internal library for both Prometheus and Open Telemetry, without any stability guarantees for external usage.
Metric Name and Label Translation: Convert OTLP metric names and attributes to Prometheus-compliant format
Unit Handling: Translate OTLP units to Prometheus unit conventions, using spec-correct UCUM mappings by default with an opt-out (LegacyUnitMapping) for callers pinned to pre-correction names
Type-Aware Suffixes: Optionally append _total, _ratio based on metric type
This library now uses the spec-correct UCUM unit suffixes by default. Two mappings changed compared to earlier releases:
TiBy → tebibytes (previously tibibytes — tebi- is the IEC binary prefix; the older spelling was a misspelling).
kBy → kilobytes is newly recognised (previously not mapped). KBy continues to map to kilobytes as before, for backwards compatibility.
Behavior change for existing consumers: dashboards, alerts, and recording rules that reference *_tibibytes will silently stop receiving new datapoints once your Prometheus / OTel Collector deployment picks up this library version.
To preserve the pre-correction names while you migrate, opt in to the legacy mapping (combine with UTF8Allowed: true if your callers use UTF-8 metric names):
OTLP Prometheus Translator
A Go library for converting OpenTelemetry Protocol (OTLP) metric and attribute names to Prometheus-compliant formats. This is an internal library for both Prometheus and Open Telemetry, without any stability guarantees for external usage.
Part of the Prometheus ecosystem, following the OpenTelemetry to Prometheus compatibility specification.
Features
LegacyUnitMapping) for callers pinned to pre-correction names_total,_ratiobased on metric type[a-zA-Z0-9:_]) or untranslated metric/label namesInstallation
Quick Start
Usage Examples
Metric Name Translation
Label Translation
Unit Translation
Migration: Pre-correction unit suffixes
This library now uses the spec-correct UCUM unit suffixes by default. Two mappings changed compared to earlier releases:
TiBy→tebibytes(previouslytibibytes—tebi-is the IEC binary prefix; the older spelling was a misspelling).kBy→kilobytesis newly recognised (previously not mapped).KBycontinues to map tokilobytesas before, for backwards compatibility.Behavior change for existing consumers: dashboards, alerts, and recording rules that reference
*_tibibyteswill silently stop receiving new datapoints once your Prometheus / OTel Collector deployment picks up this library version. To preserve the pre-correction names while you migrate, opt in to the legacy mapping (combine withUTF8Allowed: trueif your callers use UTF-8 metric names):Configuration Options
License
Licensed under the Apache License 2.0 - see the LICENSE file for details.