Skip to content

OTTL int to hex conversion function #31929

Closed
@krokwen

Description

@krokwen

Component(s)

pkg/ottl

Is your feature request related to a problem? Please describe.

I'm unable to convert uint64 trace/span id to proper hex value during logs parsing

Describe the solution you'd like

Function name "Hex" that will accept two arguments:

  1. Int value
  2. total length in bytes

second parameter is required to prepend the string with zeros to get the hex string of fixed length (trace_id.string and span_id.string accept only 32 char hex string, i'e 16-bytes)

Example:

# attributes['dd_trace_id']="13498527101626869733"
processors:
  transform:
    error_mode: ignore
    log_statements:
      - context: log
        statements:
          - set(trace_id.string, Hex(Int(attributes["dd_trace_id"]), 16))
# trace_id.string now is "0000000000000000bb5466e17373e7e5"

Describe alternatives you've considered

  1. I tried to convert trace id to hex on the PHP-side
    It's not possible due to PHP is using signed int64, and in result a lot of trace ids become '7fffffffffffffff' when I trying to dechex((int) $ddTraceId)

  2. The newer DDTrace (0.94+ or 0.96+) provides a method to acquire hex trace id (without leading zeros), but the newer extension breaks up my whole app for no reason (broken read from .env file...)

Additional context

Our laravel-based project uses DDTrace PHP-extension (0.88.1) for tracing purposes.
I can get traces easily using receiver/datadogreceiver (it processes trace_id internally by it's own)
But when I trying to parse application logs I have an issue with parsing of the datadog trace id which comes as uint64 that I unable to convert to hex value and write it as trace_id.string.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions