Skip to content

sdk: a bytes attribute crashes the console span exporter #623

@mauriciovasquezbernal

Description

@mauriciovasquezbernal

The current logic to check attributes' types admits the bytes in, it creates problem in the exporters that don't perform type check.

Reproducer:

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
    SimpleExportSpanProcessor,
    ConsoleSpanExporter,
)

trace.set_tracer_provider(TracerProvider())
trace.get_tracer_provider().add_span_processor(
  SimpleExportSpanProcessor(ConsoleSpanExporter())
)

tracer = trace.get_tracer(__name__)

with tracer.start_as_current_span("foo") as foo:
  foo.set_attribute("willcrash", b"hi")
  print("Hello world from OpenTelemetry Python!")

I did a quick look and it happens because bytes is a Sequence, and each element inside is an integer.

I don't know if the we should update the logic to reject that kind of attributes or update the exporters to be able to accept them.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingsdkAffects the SDK package.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions