Class MessagingTelemetrySuppression

java.lang.Object
io.opentelemetry.javaagent.bootstrap.messaging.MessagingTelemetrySuppression

public final class MessagingTelemetrySuppression extends Object
The MessagingTelemetrySignals suppressed by an instrumentation for the current thread.

This is what a layer reaches for when it has to reach an inner instrumentation it cannot name. Spring Rabbit, for example, knows its listener container will create the process span, but the object that would otherwise create one is a RabbitMQ consumer it never sees. Suppressing the process span for the duration of the registration call tells RabbitMQ to stay out of the way.

One instance per coordinating stack

Suppressed signals are held per instance, not globally. A stack that coordinates with the instrumentations below it keeps a separate instance in a bootstrap module, which makes that holder's class identity the coordination key: opaque, unforgeable, and the same object for every class loader, without names or a registry.

Threads are shared by whatever happens to run on them, so a Kafka poll loop that suppresses the process span must not silence an unrelated RabbitMQ delivery that lands on the same thread. Signals suppressed through one instance are invisible to every other instance.

Restoring

Suppression nests. Keep what suppress(MessagingOperationType, MessagingTelemetrySignal) returns and hand it back to restore(MessagingTelemetrySignals) when the call returns, including when it throws, so the thread ends up exactly where it started:

MessagingTelemetrySignals previous = suppression.suppress(PROCESS, SPAN);
try {
  ...
} finally {
  suppression.restore(previous);
}
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a new suppression set for one coordinating instrumentation stack to hold.
    io.opentelemetry.instrumentation.api.incubator.semconv.messaging.internal.MessagingTelemetrySignals
    Returns the signals this stack suppresses for the current thread.
    boolean
    isSuppressed(io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingOperationType operation, io.opentelemetry.instrumentation.api.incubator.semconv.messaging.internal.MessagingTelemetrySignal signal)
     
    void
    restore(io.opentelemetry.instrumentation.api.incubator.semconv.messaging.internal.MessagingTelemetrySignals previous)
    Restores the signals this stack suppresses for the current thread.
    io.opentelemetry.instrumentation.api.incubator.semconv.messaging.internal.MessagingTelemetrySignals
    suppress(io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingOperationType operation, io.opentelemetry.instrumentation.api.incubator.semconv.messaging.internal.MessagingTelemetrySignal signal)
    Suppresses a signal for the current thread and returns the previous suppressed signals, to hand back to restore(MessagingTelemetrySignals) once the suppression no longer applies.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • create

      public static MessagingTelemetrySuppression create()
      Returns a new suppression set for one coordinating instrumentation stack to hold.
    • current

      public io.opentelemetry.instrumentation.api.incubator.semconv.messaging.internal.MessagingTelemetrySignals current()
      Returns the signals this stack suppresses for the current thread.
    • suppress

      public io.opentelemetry.instrumentation.api.incubator.semconv.messaging.internal.MessagingTelemetrySignals suppress(io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingOperationType operation, io.opentelemetry.instrumentation.api.incubator.semconv.messaging.internal.MessagingTelemetrySignal signal)
      Suppresses a signal for the current thread and returns the previous suppressed signals, to hand back to restore(MessagingTelemetrySignals) once the suppression no longer applies.
    • restore

      public void restore(io.opentelemetry.instrumentation.api.incubator.semconv.messaging.internal.MessagingTelemetrySignals previous)
      Restores the signals this stack suppresses for the current thread.
    • isSuppressed

      public boolean isSuppressed(io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingOperationType operation, io.opentelemetry.instrumentation.api.incubator.semconv.messaging.internal.MessagingTelemetrySignal signal)