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)
-
Constructor Summary
-
Method Summary
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 Details
-
Tag
- Since:
- 5.11
-
-
Method Details
-
key
-
parseValue
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
Returns the value that would be tagged to the span ornull.- Since:
- 5.12
- See Also:
key(),parseValue(Object, TraceContext)
-
key
Overrides the tag key based on the input -
tag
Tags the value parsed from theinput.- Since:
- 5.11
-
tag
Tags the value parsed from theinput.- Since:
- 5.11
-
tag
Tags the value parsed from theinput.- Since:
- 5.11
-
tag
Tags the value parsed from theinput.- Since:
- 5.11
-
tag
Tags the value parsed from theinput.- Since:
- 5.11
- See Also:
SpanHandler.end(TraceContext, MutableSpan, SpanHandler.Cause)
-
toString
-
validateNonEmpty
-