opentelemetry-specification icon indicating copy to clipboard operation
opentelemetry-specification copied to clipboard

Prometheus translation with UTF-8 and `__`

Open zeitlinger opened this issue 4 months ago • 5 comments

zeitlinger avatar Aug 19 '25 11:08 zeitlinger

Was last discussed in https://github.com/open-telemetry/opentelemetry-specification/pull/4533

zeitlinger avatar Aug 19 '25 11:08 zeitlinger

Well, the spec says SHOULD, not MUST. So technically, an SDK is still compliant even if multiple underscores are kept between words. However, for SHOULD, usually folks provide an explanation why they are intentionally not complying. If java decides to not comply, it would be nice to have some sort of docs with the explanation

If you want to implement this, maybe our Go implementation can inspire you? We do a string split to later join with a single _ character

ArthurSens avatar Aug 19 '25 14:08 ArthurSens

If you want to implement this, maybe our Go implementation can inspire you? We do a string split to later join with a single _ character

This doesn't work for Java and I'm not sure why it does for Go:

  • we pass the chars to the prom client as unicode, so there's no escaping hat that point
  • at scrape time, escaping can occur, but this is done it the client, so after the otel 2 prom conversion

zeitlinger avatar Aug 20 '25 09:08 zeitlinger

For Go, we do the escaping before registering the metric, so it's not during scrape time.

ArthurSens avatar Aug 20 '25 20:08 ArthurSens

Takeaway from meeting:

Users usually want to control translation on the ingestion side rather than at scrape time, so it's good to keep a "utf8 support" setting in OTel SDKs.

zeitlinger avatar Aug 27 '25 15:08 zeitlinger