Class EventToSpanEventBridge

java.lang.Object
io.opentelemetry.sdk.extension.incubator.logs.EventToSpanEventBridge
All Implemented Interfaces:
io.opentelemetry.sdk.logs.LogRecordProcessor, Closeable, AutoCloseable

public final class EventToSpanEventBridge extends Object implements io.opentelemetry.sdk.logs.LogRecordProcessor
A LogRecordProcessor which bridges events (i.e. log records with a non-empty event.name) as span events on the current span.

A log record is bridged to a span event if and only if all of the following conditions are met:

  • The log record has a non-empty event name.
  • The log record has a valid trace ID and span ID.
  • The resolved context contains a current span whose Span.isRecording() is true.
  • The log record's trace ID and span ID equal those of the current span in the resolved context.

When bridged, a span event is added with:

  • Name set to the log record's event name.
  • Timestamp set to the log record's timestamp if set; otherwise, the observed timestamp.
  • All log record attributes copied to the span event attributes.

Bridging does NOT prevent the log record from continuing through the normal log processing pipeline.

  • Method Details

    • create

      public static EventToSpanEventBridge create()
      Create a new instance.
    • onEmit

      public void onEmit(io.opentelemetry.context.Context context, io.opentelemetry.sdk.logs.ReadWriteLogRecord logRecord)
      Specified by:
      onEmit in interface io.opentelemetry.sdk.logs.LogRecordProcessor
    • toString

      public String toString()
      Overrides:
      toString in class Object