Closed
Description
Describe your environment
OS: Ubuntu
Python version: 3.12
SDK version: 1.25.0
API version: 1.25.0
What happened?
We are recording invalid links when adding links during span creation.
Steps to Reproduce
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
SimpleSpanProcessor,
ConsoleSpanExporter,
)
trace.set_tracer_provider(TracerProvider())
trace.get_tracer_provider().add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))
tracer = trace.get_tracer("my.tracer")
with tracer.start_as_current_span("root", links=[trace.Link(trace.INVALID_SPAN_CONTEXT)]) as root:
pass
Expected Result
"links": []
Since this is the preferred method to add links, I suppose we should also validate links at span creation
Actual Result
"links": [
{
"context": {
"trace_id": "0x00000000000000000000000000000000",
"span_id": "0x0000000000000000",
"trace_state": "[]"
},
"attributes": {}
}
],
Additional context
No response
Would you like to implement a fix?
Yes