Skip to content

Attributes passed to get_tracer() do not appear in spans #4855

@mtakuma

Description

@mtakuma

Describe your environment

OS: MacOS
Python version: Python 3.11.13
SDK version: 1.39.1
API version: 1.39.1

What happened?

I find attributes parameter of TracerProvider.get_tracer() documented as

Specifies the attributes of the emitted telemetry.

I expect the attributes passed here will appear in every trace created by the tracer, but cannot see the behavior. What do I miss to do or misunderstand?

Steps to Reproduce

Based on the example https://opentelemetry.io/docs/languages/python/getting-started/#traces I added attributes parameter:

from random import randint
from flask import Flask

from opentelemetry import trace

# Acquire a tracer
tracer = trace.get_tracer("diceroller.tracer", attributes={"attr-name":"attr-value"})

app = Flask(__name__)

@app.route("/rolldice")
def roll_dice():
    return str(roll())

def roll():
    # This creates a new span that's the child of the current one
    with tracer.start_as_current_span("roll") as rollspan:
        res = randint(1, 6)
        rollspan.set_attribute("roll.value", res)
        return res

Expected Result

{"attr-name":"attr-value"} appears in the generated span

Actual Result

Cannot see {"attr-name":"attr-value"} in the generated span

Additional context

No response

Would you like to implement a fix?

No

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions