Package codes.grow.packages.skywalking
Record Class ZipkinSpan
java.lang.Object
java.lang.Record
codes.grow.packages.skywalking.ZipkinSpan
- Record Components:
traceId- trace id (hex)id- span id (hex)parentId- parent span id,""for rootskind-CLIENT,SERVER,PRODUCER,CONSUMERor""(internal)name- span name (lower-cased by OAP)timestamp- start in epoch microsecondsduration- duration in microsecondslocalServiceName-localEndpoint.serviceNameannotations- events (name|attributesJSON|droppedCount)- tags
public record ZipkinSpan(String traceId, String id, String parentId, String kind, String name, long timestamp, long duration, String localServiceName, List<ZipkinSpan.Annotation> annotations, Map<String,String> tags)
extends Record
A span as OAP's Zipkin query API returns it (
:9412/zipkin/api/v2): the stored form of
spans exported over OTLP. OAP lower-cases span names on ingest and stores attribute values as
strings.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theannotationsrecord component.longduration()Returns the value of thedurationrecord component.final booleanIndicates whether some other object is "equal to" this one.static Optional<ZipkinSpan> fromJson(com.fasterxml.jackson.databind.JsonNode s) Decodes a span; empty whentraceIdoridis missing.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.static booleanisBookkeepingTag(String key) Whether a tag is OAP bookkeeping (otel.*,error,w3c.tracestate); such tags become status fields or are dropped from the attributes.static booleanisHexTraceId(String id) Whetheridis a 16- or 32-character hex id (OTLP/Zipkin), as opposed to a native SkyWalking id.kind()Returns the value of thekindrecord component.static List<ZipkinSpan> listFrom(com.fasterxml.jackson.databind.JsonNode body) Decodes the well-formed spans of a[span...]body.Returns the value of thelocalServiceNamerecord component.name()Returns the value of thenamerecord component.parentId()Returns the value of theparentIdrecord component.tags()Returns the value of thetagsrecord component.longReturns the value of thetimestamprecord component.static Span.EventDecodes an OAP annotation into an event:name|{"k":"v"}|0(split on the first and last|) → name and attributes; any other value is the event name without attributes.toSpan()Converts to the SPEC model: ids lower-case (trace id padded to 32), kind lower-case (absent → internal, unknown → unspecified), service =localEndpoint.serviceName, status fromotel.status_code(STATUS_CODE_ERROR→ error withotel.status_description,STATUS_CODE_OK→ ok, anerrortag alone → error), attributes = tags without the bookkeeping tags, annotations → events.final StringtoString()Returns a string representation of this record class.toTrace(List<ZipkinSpan> spans) Converts the spans of one Zipkin trace into a SPEC trace (spans sorted).traceId()Returns the value of thetraceIdrecord component.static StringzipkinTraceId(String id, String operation) Lower-cases and validates a Zipkin trace id.
-
Constructor Details
-
ZipkinSpan
public ZipkinSpan(String traceId, String id, String parentId, String kind, String name, long timestamp, long duration, String localServiceName, List<ZipkinSpan.Annotation> annotations, Map<String, String> tags) Copies collections and normalises nulls.- Parameters:
traceId- trace idid- span idparentId- parent idkind- kindname- nametimestamp- startduration- durationlocalServiceName- serviceannotations- annotationstags- tags
-
-
Method Details
-
isHexTraceId
Whetheridis a 16- or 32-character hex id (OTLP/Zipkin), as opposed to a native SkyWalking id.- Parameters:
id- trace id- Returns:
- true for hex ids
-
zipkinTraceId
Lower-cases and validates a Zipkin trace id.- Parameters:
id- trace idoperation- operation name for the error- Returns:
- the lower-case id
- Throws:
ValidationException- unless the id is 16 or 32 hex characters, not all zero
-
fromJson
Decodes a span; empty whentraceIdoridis missing.- Parameters:
s- JSON object- Returns:
- the span, or empty
-
listFrom
Decodes the well-formed spans of a[span...]body.- Parameters:
body- JSON array- Returns:
- the spans
-
isBookkeepingTag
Whether a tag is OAP bookkeeping (otel.*,error,w3c.tracestate); such tags become status fields or are dropped from the attributes.- Parameters:
key- tag key- Returns:
- true for bookkeeping tags
-
toEvent
Decodes an OAP annotation into an event:name|{"k":"v"}|0(split on the first and last|) → name and attributes; any other value is the event name without attributes.- Parameters:
a- annotation- Returns:
- the event
-
toSpan
Converts to the SPEC model: ids lower-case (trace id padded to 32), kind lower-case (absent → internal, unknown → unspecified), service =localEndpoint.serviceName, status fromotel.status_code(STATUS_CODE_ERROR→ error withotel.status_description,STATUS_CODE_OK→ ok, anerrortag alone → error), attributes = tags without the bookkeeping tags, annotations → events.- Returns:
- the span
-
toTrace
Converts the spans of one Zipkin trace into a SPEC trace (spans sorted).- Parameters:
spans- spans of one trace- Returns:
- the trace, or empty when there are no spans
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
traceId
Returns the value of thetraceIdrecord component.- Returns:
- the value of the
traceIdrecord component
-
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
parentId
Returns the value of theparentIdrecord component.- Returns:
- the value of the
parentIdrecord component
-
kind
Returns the value of thekindrecord component.- Returns:
- the value of the
kindrecord component
-
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
timestamp
public long timestamp()Returns the value of thetimestamprecord component.- Returns:
- the value of the
timestamprecord component
-
duration
public long duration()Returns the value of thedurationrecord component.- Returns:
- the value of the
durationrecord component
-
localServiceName
Returns the value of thelocalServiceNamerecord component.- Returns:
- the value of the
localServiceNamerecord component
-
annotations
Returns the value of theannotationsrecord component.- Returns:
- the value of the
annotationsrecord component
-
tags
Returns the value of thetagsrecord component.- Returns:
- the value of the
tagsrecord component
-