Closed
Description
Describe your environment
No response
What happened?
When exporting a log with bytes in the body, the exporter fails with TypeError: Object of type bytes is not JSON serializable
when trying to json.dumps()
it.
Steps to Reproduce
from time import time_ns
from opentelemetry.sdk._logs.export import ConsoleLogExporter
from opentelemetry.sdk._logs import LogData, LogRecord
from opentelemetry.sdk.util.instrumentation import InstrumentationScope
exporter = ConsoleLogExporter()
exporter.export(
[
LogData(
instrumentation_scope=InstrumentationScope(name="foo"),
log_record=LogRecord(timestamp=time_ns(), body={"foo": b"bar"}),
)
]
)
Expected Result
bytes
are a valid AnyValue
so it should be encoded and exported properly. Check the specification for details.
Actual Result
TypeError: Object of type bytes is not JSON serializable
Additional context
No response
Would you like to implement a fix?
None
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done