You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OS: Mac and RHEL 9
Python version: python 3.12
Package version: 0.47b0
What happened?
The Opentelemetry Logging instrumentation gives an exception when logging an exception directly.
Steps to Reproduce
Provided below is a minimal example to reproduce this issue
importloggingimportsysfromopentelemetryimporttracetracer=trace.get_tracer_provider().get_tracer(__name__)
# Trace context correlationwithtracer.start_as_current_span("foo"):
# Do somethingcurrent_span=trace.get_current_span()
current_span.add_event("This is a span event")
logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
logging.getLogger().error(ValueError("Test"))
Run this using opentelemetry-instrument --traces_exporter none --logs_exporter otlp python example.py
Expected Result
No exception is raised and the log is transported successfully to the otel collector.
Actual Result
An exception is raised and the log is not transported to the collector
otel-logs-py3.12meldsza@MacBook-Pro otel-logs % opentelemetry-instrument --traces_exporter none --logs_exporter otlp python example.py
Test
Exception while exporting logs.
Traceback (most recent call last):
File "/Users/meldsza/Desktop/work/repos/otel-logs/.venv/lib/python3.12/site-packages/opentelemetry/sdk/_logs/_internal/export/__init__.py", line 311, in _export_batch
self._exporter.export(self._log_records[:idx]) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/meldsza/Desktop/work/repos/otel-logs/.venv/lib/python3.12/site-packages/opentelemetry/exporter/otlp/proto/http/_log_exporter/__init__.py", line 138, inexport
serialized_data = encode_logs(batch).SerializeToString()
^^^^^^^^^^^^^^^^^^
File "/Users/meldsza/Desktop/work/repos/otel-logs/.venv/lib/python3.12/site-packages/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py", line 38, in encode_logs
return ExportLogsServiceRequest(resource_logs=_encode_resource_logs(batch))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/meldsza/Desktop/work/repos/otel-logs/.venv/lib/python3.12/site-packages/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py", line 72, in _encode_resource_logs
pb2_log = _encode_log(sdk_log)
^^^^^^^^^^^^^^^^^^^^
File "/Users/meldsza/Desktop/work/repos/otel-logs/.venv/lib/python3.12/site-packages/opentelemetry/exporter/otlp/proto/common/_internal/_log_encoder/__init__.py", line 58, in _encode_log
body=_encode_value(log_data.log_record.body),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/meldsza/Desktop/work/repos/otel-logs/.venv/lib/python3.12/site-packages/opentelemetry/exporter/otlp/proto/common/_internal/__init__.py", line 88, in _encode_value
raise Exception(f"Invalid type {type(value)} of value {value}")
Exception: Invalid type<class 'ValueError'> of value Test
Additional context
No response
Would you like to implement a fix?
None
The text was updated successfully, but these errors were encountered:
Describe your environment
OS: Mac and RHEL 9
Python version: python 3.12
Package version: 0.47b0
What happened?
The Opentelemetry Logging instrumentation gives an exception when logging an exception directly.
Steps to Reproduce
Provided below is a minimal example to reproduce this issue
Run this using
opentelemetry-instrument --traces_exporter none --logs_exporter otlp python example.py
Expected Result
No exception is raised and the log is transported successfully to the otel collector.
Actual Result
An exception is raised and the log is not transported to the collector
Additional context
No response
Would you like to implement a fix?
None
The text was updated successfully, but these errors were encountered: