Class SpanDataModifier

  • All Implemented Interfaces:

    
    public final class SpanDataModifier
    
                        

    A utility that can be used to create a SpanExporter that allows filtering and modification of span data before it is sent to Allows modification of span data before it is sent to a delegate exporter. Spans can be rejected entirely based on their name or attribute content, or their attributes may be modified.

    • Constructor Detail

    • Method Detail

      • rejectSpansByName

         SpanDataModifier rejectSpansByName(Predicate<String> spanNamePredicate)

        Remove matching spans from the exporter pipeline.

        Spans with names that match the spanNamePredicate will not be exported.

        Parameters:
        spanNamePredicate - A function that returns true if a span with passed name should be rejected.
        Returns:

        this.

      • rejectSpansByAttributeValue

         <T> SpanDataModifier rejectSpansByAttributeValue(AttributeKey<T> attributeKey, Predicate<in T> attributeValuePredicate)

        Remove matching spans from the exporter pipeline.

        Any span that contains an attribute with key attributeKey and value matching the attributeValuePredicate will not be exported.

        Parameters:
        attributeKey - An attribute key to match.
        attributeValuePredicate - A function that returns true if a span containing an attribute with matching value should be rejected.
        Returns:

        this.

      • removeSpanAttribute

         <T> SpanDataModifier removeSpanAttribute(AttributeKey<T> attributeKey)

        Modify span data before it enters the exporter pipeline.

        Any attribute with key attributeKey and will be removed from the span before it is exported.

        Parameters:
        attributeKey - An attribute key to match.
        Returns:

        this.

      • removeSpanAttribute

         <T> SpanDataModifier removeSpanAttribute(AttributeKey<T> attributeKey, Predicate<in T> attributeValuePredicate)

        Modify span data before it enters the exporter pipeline.

        Any attribute with key attributeKey and value matching the attributeValuePredicate will be removed from the span before it is exported.

        Parameters:
        attributeKey - An attribute key to match.
        attributeValuePredicate - A function that returns true if an attribute with matching value should be removed from the span.
        Returns:

        this.

      • replaceSpanAttribute

         <T> SpanDataModifier replaceSpanAttribute(AttributeKey<T> attributeKey, Function<in T, out T> attributeValueModifier)

        Modify span data before it enters the exporter pipeline.

        The value of any attribute with key attributeKey will be passed to the attributeValueModifier function. The value returned by the function will replace the original value. When the modifier function returns null the attribute will be removed from the span.

        Parameters:
        attributeKey - An attribute key to match.
        attributeValueModifier - A function that receives the old attribute value and returns the new one.
        Returns:

        this.

      • build

         SpanExporter build()