Elastic APM does not support the Otel Span Events. is there an alternative?

I want to use span events to attach my logs to my span,
Elastic Apm ignore opentelemetry exported span events.

is there an alternative ?

OpenTelemetry Span Events: opentelemetry-specification/api.md at main · open-telemetry/opentelemetry-specification · GitHub

Hello Ayada,

It's correct that we don't support span events at the moment.
Regarding logs integration, we recommend an alternate pattern injecting the trace_id and span_id in the logs and then ingest the logs as a separate stream in Elastic Observability.

  1. Use the capability in Otel APM Agents to inject span_id and trace_id in the logging framework such as Log4j2 or Logback/SLF4J in Java.
  2. Export you logs as JSON. In Java with Logback, you can use the library logback-json-classic
  3. Use a log collector like Elastic Filebeat to collect the logs and ship them in Elastic complying with the Elastic Common Schema to get the trace_id and schema_id recognized
  4. When looking at traces in Elastic Observability, use the logs tab to view the logs associated with your trace.

Example log message emitted by Logback with logback-json-classic

   "message":"checkOrder(totalPrice: 005, shippingCountry: US, customerIpAddress: fraudScore: -52, rejected: false, expectedSleep: 53ms, actualSleep: 181ms, delta:241%",

Logback configuration

Maven pom.xml


Elastic Filebeat Configuration

  - type: log
    enabled: true
    json.keys_under_root: true
    json.overwrite_keys: true
      - /usr/local/var/log/my-shopping-cart/anti-fraud.log
      service.name: frontend
    fields_under_root: true

  - add_host_metadata: ~
  - add_cloud_metadata: ~
  - add_docker_metadata: ~
  - add_kubernetes_metadata: ~
  - timestamp:
      field: "timestamp"
        - "UNIX_MS"
      ignore_missing: true
        - "1615986552269"
  - rename:
        - from: "level"
          to: "log.level"
        - from: "thread"
          to: "process.thread.name"
        - from: "mdc.trace_id"
          to: "trace.id"
        - from: "mdc.span_id"
          to: "span.id"
        - from: "logger"
          to: "log.logger"
      ignore_missing: true
      fail_on_error: true
1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.