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 String
key()
protected String
key(I input)
Overrides the tag key based on the inputprotected abstract String
parseValue(I input, TraceContext context)
Override to change what data from the input are parsed into the span modeling it.void
tag(I input, TraceContext context, MutableSpan span)
Tags the value parsed from theinput
.void
tag(I input, TraceContext context, SpanCustomizer span)
Tags the value parsed from theinput
.void
tag(I input, ScopedSpan span)
Tags the value parsed from theinput
.void
tag(I input, Span span)
Tags the value parsed from theinput
.void
tag(I input, SpanCustomizer span)
Tags the value parsed from theinput
.String
toString()
protected static String
validateNonEmpty(String label, String value)
String
value(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.ERROR
must 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.
null
means 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
-