79562333

Date: 2025-04-08 14:31:42
Score: 2.5
Natty:
Report link

I have the same problem trying to extract the trace_id and span_id from a field called contextMap which is of type Map. No matter what I did, it wouldn't get the data from the fields.

So I ended up copying the context of the map to log.cache(a temporary space where you can do some heavy lifting in) where I could then directly access the fields

- merge_maps(log.cache, log.cache["contextMap"], "upsert") where IsMap(log.cache["contextMap"])
- set(log.attributes["span_id"], log.cache["span_id"]) where IsString(log.cache["span_id"])
- set(log.attributes["trace_id"], log.cache["trace_id"]) where IsString(log.cache["trace_id"])

(FYI: the contextMap is already in log.cache since we send our logs as JSON and have otel parse it into log.cache)

Reasons:
  • Blacklisted phrase (1): I have the same problem
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): I have the same problem
Posted by: Phillip