opentelemetry-python-contrib icon indicating copy to clipboard operation
opentelemetry-python-contrib copied to clipboard

opentelemetry-instrumentation-redis occasionally produces unnamed spans

Open pete-layerhealth opened this issue 8 months ago • 0 comments
trafficstars

Describe your environment

OS: debian Python version: 3.10.16 Package version: 0.51b0 running in a docker container with base image python:3.10.16-slim

What happened?

i periodically get unnamed spans emitted like this

{
    "name": "",
    "context": {
        "trace_id": "0xdeacb55c16eb0739902e1725a402f3ed",
        "span_id": "0x99b9f7b1e23d6c9a",
        "trace_state": "[]"
    },
    "kind": "SpanKind.CLIENT",
    "parent_id": null,
    "start_time": "2025-03-05T17:05:36.028629Z",
    "end_time": "2025-03-05T17:05:36.028652Z",
    "status": {
        "status_code": "UNSET"
    },
    "attributes": {
        "db.statement": "",
        "db.system": "redis",
        "db.redis.database_index": 0,
        "net.peer.name": "redis",
        "net.peer.port": 6379,
        "net.transport": "ip_tcp",
        "db.redis.pipeline_length": 0
    },
    "events": [],
    "links": [],
    "resource": {
        "attributes": {
            "telemetry.sdk.language": "python",
            "telemetry.sdk.name": "opentelemetry",
            "telemetry.sdk.version": "1.30.0",
            "service.name": "my-service",
            "service.namespace": "test-namespace",
            "service.version": "0.0.1",
            "service.instance.id": "192b2cb571f4"
        },
        "schema_url": ""
    }
}

this span cannot be exported, and causes a bunch of annoying error spam downstream. how can i find out what's responsible for this nameless span?

in the meantime, i have worked around by defaulting the name like so:

    RedisInstrumentor().instrument(
        tracer_provider=tracer_provider,
        response_hook=lambda span, _instance, _response: span.update_name(
            "unknown redis operation"
        )
        if not span.name
        else None,
    )

Steps to Reproduce

i set up redis instrumentation as follows

    RedisInstrumentor().instrument(tracer_provider=tracer_provider)

and redis as follows

connection=Redis(
    host=config.REDIS_HOST,
    port=config.REDIS_PORT,
    password=config.REDIS_PASSWORD,
    ssl=config.REDIS_ENABLE_SSL,
    ssl_ca_data=config.REDIS_SSL_CA_DATA,
),

Expected Result

all spans have names

Actual Result

some spans are unnamed

Additional context

No response

Would you like to implement a fix?

None

pete-layerhealth avatar Mar 05 '25 18:03 pete-layerhealth