How to send authenticated traces to tempo cloud using OLTP exporter python?

1k Views Asked by At

Im trying to use the OTLPSpanExporter (either the http or grpc) version to send traces to tempo cloud but i wasn't able to find any documentation on how to add the authentication.

tempo cloud screenshot

I tried something like this but i get constants error saying that the headers key's are invalid if im using the grpc version and 404 using the http version. I also tried without the the /tempo path and different variations i found like '/v1/traces' but i was also getting 404 everytime.

otlp_exporter = OTLPSpanExporter(
    endpoint="https://tempo-us-central1.grafana.net", 
    headers={
        "Content-Type": "application/json",
        "Authorization": f"Basic {urllib.parse.quote_plus('XXXX')}",
    }
)

Has anyone managed to implement this?

1

There are 1 best solutions below

0
On

Grafana Data Source settings is for Grafana, not for OTLP exporter. Grafana uses different protocol (HTTP) as OTLP exporter (GRPC). So use config for Agent (agent is OTEL collector under the hood, so there is also OTLP exporter). So endpoint is tempo-us-central1.grafana.net:443.

You are using GRPC protocol, not HTTP protocol, so header "Content-Type": "application/json" doesn't make sense. (In theory it is possible to use HTTP protocol, but then you will need HTTP exporter and not GRPC + it is not clear if Grafana cloud support also HTTP protocol for trace ingestion).

Authorization header is Authorization (not Authentication as you mentioned https://community.grafana.com/t/send-traces-to-tempo-cloud-from-open-telemetry-in-python/77431). It is not clear what are you using instead of XXXX but that must be base64 of <your user id>:<your api key>. That's standard basic auth - https://en.wikipedia.org/wiki/Basic_access_authentication#Client_side