Search code examples
pythonjaegeropen-telemetry

How to add tags into process for Jaeger span


I am using Python3.8 with opentelemetry libraries and I am able to create some basic spans. I need to add tags for the backend processor pick them. For E.G something like "hostname".

For this to happen I need to somehow add tags to the process. I am unable to figure out how to do this.

My trace looks like this

    "process": {
        "serviceName": "xxxxx"
    },
    "spans": [
        {```
I need something like
```{
    "process": {
        "serviceName": "xxxxx",
        "tags": [
            {
                "key": "jaeger.version",
                "vType": "STRING",
                "vStr": "Go-2.29.1"
            },
            {
                "key": "hostname",
                "vType": "STRING",
                "vStr": "xxxxxx"            

This is how I am initializing my tracer and exporter

                TracerProvider(
                    resource=Resource.create({SERVICE_NAME: "xxxx","service.instance.id":"1","host.name":"xxxx"})
                    )
                )
        trace.set_attribute("hostname","018.zeus.run")

        tracer = trace.get_tracer(__name__)

        jaeger_exporter = JaegerExporter(
        agent_host_name='xxxxx',
        agent_port=6831,
        collector_endpoint='http://xxxxx:14268/api/traces?format=jaeger.thrift'
        )

Can someone please let me know how can I add tags to the process?


Solution

  • I believe this is a bug with the exporter lib you are using. Ideally, thrift-exporter should translate the resource attributes to process tags as mentioned in the spec. Here is the source where Process is instantiated with serviceName and it doesn't map the remaining resource attributes as tags, but jaeger-proto-grpc exporter correctly maps them. Please create an issue here https://github.com/open-telemetry/opentelemetry-python.