Skip to content

[enrichments] Add enrichment logic for user_agent.* #172

@lahsivjar

Description

@lahsivjar

These sets of attributes are not always set by the OTel SDKs but are required by the UI. The below OTTL statements can be used as an algorithm for populating these fields based on stable OTel semconv:

transform/user_agent:
    trace_statements:
      - merge_maps(span.cache, UserAgent(span.attributes["user_agent.original"]), "upsert") where span.attributes["user_agent.original"] != nil
      - set(span.attributes["user_agent.name"], span.cache["user_agent.name"])
      - set(span.attributes["user_agent.version"], span.cache["user_agent.version"])
      - set(span.attributes["url.full"], Concat([span.attributes["url.scheme"], "://", span.attributes["server.address"]], ""))
      - set(span.attributes["url.full"], Concat([span.attributes["url.full"], span.attributes["server.port"]], ":")) where span.attributes["server.port"] != nil
      - set(span.attributes["url.full"], Concat([span.attributes["url.full"], span.attributes["url.path"]], "")) where span.attributes["url.path"] != nil
      - set(span.attributes["url.full"], Concat([span.attributes["url.full"], span.attributes["url.query"]], "?")) where span.attributes["url.query"] != nil

In the above OTTL statements, the UserAgent converter func uses https://github.com/ua-parser/uap-go which can be used by this library to do the same enrichment.

Based on recent developments, the url.full will be built in the UI so we only need to do the user_agent bit in the opentelemetry lib.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions