Package 

Class GlobalAttributesSpanAppender

  • All Implemented Interfaces:
    io.opentelemetry.sdk.trace.SpanProcessor , java.io.Closeable , java.lang.AutoCloseable

    
    public final class GlobalAttributesSpanAppender
     implements SpanProcessor
                        

    A SpanProcessor implementation that appends a set of attributes to every span that is exported. The attributes are supplied via Supplier. This Supplier may alter its results and return different attributes over time. collection is mutable, and can be updated by calling update.

    This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.

    • Method Summary

      Modifier and Type Method Description
      static GlobalAttributesSpanAppender create(Attributes initialState) Returns a new GlobalAttributesSpanAppender with a given initial attributes.
      static GlobalAttributesSpanAppender create(Supplier<Attributes> attributeSupplier) Returns a new GlobalAttributesSpanAppender which calls the given supplier to populatethe global attributes;
      void onStart(Context parentContext, ReadWriteSpan span)
      boolean isStartRequired()
      void onEnd(ReadableSpan span)
      boolean isEndRequired()
      void update(Consumer<AttributesBuilder> attributesUpdater) Update the global set of attributes to be appended to every span.
      void update(Supplier<Attributes> attributesSupplier) Replaces the currently configured attributes Supplier with a new one.
      • Methods inherited from class io.opentelemetry.sdk.trace.SpanProcessor

        close, composite, forceFlush, isEndRequired, isStartRequired, onEnd, onStart, shutdown
      • Methods inherited from class java.lang.Object

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

      • onStart

         void onStart(Context parentContext, ReadWriteSpan span)
      • onEnd

         void onEnd(ReadableSpan span)
      • update

         void update(Consumer<AttributesBuilder> attributesUpdater)

        Update the global set of attributes to be appended to every span.

        Note: Calling this method invalidates the Supplier originally passed to this and any other previously updated Supplier.

        Parameters:
        attributesUpdater - A function which will update the current set of attributes, byoperating on a AttributesBuilder from the current set.
      • update

         void update(Supplier<Attributes> attributesSupplier)

        Replaces the currently configured attributes Supplier with a new one.

        Parameters:
        attributesSupplier - Supplier to call to obtain Attributes for every span.