Package brave
Class Tag<I>
- java.lang.Object
-
- brave.Tag<I>
-
- Direct Known Subclasses:
ErrorParser
public abstract class Tag<I> extends Object
This is a centralized type to parse a tag into any variant of a span. This also avoids the clutter of checking null or guarding on exceptions. Here's an example of a potentially expensive tag:{@code SUMMARY_TAG = new Tag("summary") { - Since:
- 5.11
- See Also:
Tags,SpanCustomizer.tag(String, String),MutableSpan.tag(String, String)
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Stringkey()protected Stringkey(I input)Overrides the tag key based on the inputprotected abstract StringparseValue(I input, TraceContext context)Override to change what data from the input are parsed into the span modeling it.voidtag(I input, TraceContext context, MutableSpan span)Tags the value parsed from theinput.voidtag(I input, TraceContext context, SpanCustomizer span)Tags the value parsed from theinput.voidtag(I input, ScopedSpan span)Tags the value parsed from theinput.voidtag(I input, Span span)Tags the value parsed from theinput.voidtag(I input, SpanCustomizer span)Tags the value parsed from theinput.StringtoString()protected static StringvalidateNonEmpty(String label, String value)Stringvalue(I input, TraceContext context)Returns the value that would be tagged to the span ornull.
-
-
-
Constructor Detail
-
Tag
protected Tag(String key)
- Since:
- 5.11
-
-
Method Detail
-
key
public final String key()
-
parseValue
@Nullable protected abstract String parseValue(I input, @Nullable TraceContext context)
Override to change what data from the input are parsed into the span modeling it. Any exceptions will be logged and ignored.Note: Overrides of
Tags.ERRORmust return a valid value when {@param context} isnull, even if that value is "" (empty string). Otherwise, error spans will not be marked as such.- Returns:
- The result to add as a span tag.
nullmeans no tag will be added. Note: empty string is a valid tag value! - Since:
- 5.11
-
value
@Nullable public String value(@Nullable I input, @Nullable TraceContext context)
Returns the value that would be tagged to the span ornull.- Since:
- 5.12
- See Also:
key(),parseValue(Object, TraceContext)
-
tag
public final void tag(I input, ScopedSpan span)
Tags the value parsed from theinput.- Since:
- 5.11
-
tag
public final void tag(I input, @Nullable TraceContext context, SpanCustomizer span)
Tags the value parsed from theinput.- Since:
- 5.11
-
tag
public final void tag(I input, SpanCustomizer span)
Tags the value parsed from theinput.- Since:
- 5.11
-
tag
public final void tag(I input, @Nullable TraceContext context, MutableSpan span)
Tags the value parsed from theinput.- Since:
- 5.11
- See Also:
SpanHandler.end(TraceContext, MutableSpan, SpanHandler.Cause)
-
-