Class OpenTelemetryAppender

java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
ch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
io.opentelemetry.instrumentation.logback.mdc.v1_0.OpenTelemetryAppender
All Implemented Interfaces:
ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>, ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.ILoggingEvent>, ch.qos.logback.core.spi.ContextAware, ch.qos.logback.core.spi.FilterAttachable<ch.qos.logback.classic.spi.ILoggingEvent>, ch.qos.logback.core.spi.LifeCycle

public class OpenTelemetryAppender extends ch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent> implements ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.ILoggingEvent>
  • Field Summary

    Fields inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase

    name, started

    Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase

    context
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAppender(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> appender)
     
    protected void
    append(ch.qos.logback.classic.spi.ILoggingEvent event)
     
    void
     
    boolean
    detachAppender(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> appender)
     
    boolean
     
    ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>
     
    boolean
    isAttached(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> appender)
     
    Iterator<ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>>
     
    void
    setAddBaggage(boolean addBaggage)
    When set to true this will enable addition of all baggage entries to MDC.
    void
    setSpanIdKey(String spanIdKey)
    Customize MDC key name for the span id.
    void
    setTraceFlagsKey(String traceFlagsKey)
    Customize MDC key name for the trace flags.
    void
    setTraceIdKey(String traceIdKey)
    Customize MDC key name for the trace id.

    Methods inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase

    addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, start, stop, toString

    Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase

    addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface ch.qos.logback.core.spi.ContextAware

    addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
  • Constructor Details

    • OpenTelemetryAppender

      public OpenTelemetryAppender()
  • Method Details

    • setAddBaggage

      public void setAddBaggage(boolean addBaggage)
      When set to true this will enable addition of all baggage entries to MDC. This can be done by adding the following to the logback.xml config for this appender. <addBaggage>true</addBaggage>
      Parameters:
      addBaggage - True if baggage should be added to MDC
    • setTraceIdKey

      public void setTraceIdKey(String traceIdKey)
      Customize MDC key name for the trace id.
    • setSpanIdKey

      public void setSpanIdKey(String spanIdKey)
      Customize MDC key name for the span id.
    • setTraceFlagsKey

      public void setTraceFlagsKey(String traceFlagsKey)
      Customize MDC key name for the trace flags.
    • append

      protected void append(ch.qos.logback.classic.spi.ILoggingEvent event)
      Specified by:
      append in class ch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
    • addAppender

      public void addAppender(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> appender)
      Specified by:
      addAppender in interface ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.ILoggingEvent>
    • iteratorForAppenders

      public Iterator<ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>> iteratorForAppenders()
      Specified by:
      iteratorForAppenders in interface ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.ILoggingEvent>
    • getAppender

      public ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> getAppender(String name)
      Specified by:
      getAppender in interface ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.ILoggingEvent>
    • isAttached

      public boolean isAttached(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> appender)
      Specified by:
      isAttached in interface ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.ILoggingEvent>
    • detachAndStopAllAppenders

      public void detachAndStopAllAppenders()
      Specified by:
      detachAndStopAllAppenders in interface ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.ILoggingEvent>
    • detachAppender

      public boolean detachAppender(ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent> appender)
      Specified by:
      detachAppender in interface ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.ILoggingEvent>
    • detachAppender

      public boolean detachAppender(String name)
      Specified by:
      detachAppender in interface ch.qos.logback.core.spi.AppenderAttachable<ch.qos.logback.classic.spi.ILoggingEvent>