Skip to content

Commit

Permalink
OpenTelemetry trace id for logstash in hex format (#32)
Browse files Browse the repository at this point in the history
* OpenTelemetry trace id for logstash in hex format
  • Loading branch information
andmat900 authored Jun 10, 2024
1 parent 4b16b52 commit 69ffa77
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/etos_lib/logging/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ def get_current_otel_trace_id() -> str:
The OpenTelemetry trace id is a big integer by default, which is out of range
of the type 'long' in Elastic. For this reason the trace id is returned as string.
If OpenTelemetry is not enabled, this function will return "0".
If OpenTelemetry is not enabled, this function will return "00000000000000000000000000000000".
"""
current_span = trace.get_current_span()
return str(current_span.get_span_context().trace_id)
trace_id = current_span.get_span_context().trace_id
return trace.format_trace_id(trace_id)


class EtosFilter(logging.Filter): # pylint:disable=too-few-public-methods
Expand Down

0 comments on commit 69ffa77

Please sign in to comment.