Package codes.grow.packages.skywalking
Class SkyWalkingLogExporter
java.lang.Object
codes.grow.packages.skywalking.SkyWalkingLogExporter
- All Implemented Interfaces:
LogExporter
LogExporter that posts batches to OAP's native log API (POST /v3/logs, JSON
array, port 12800). Native logs carry the trace context, register the service and are queryable a
few seconds later. The body is sent uncompressed (gzip is not verified on OAP's HTTP receiver).
Mapping of a SPEC LogRecord to native LogData:
resource["service.name"] → service, service.instance.id →
serviceInstance, body → body.text.text, severityText → tag level,
attributes (stringified, nested values as JSON) → tags, traceId →
traceContext.traceId (enables relatedTrace queries), spanId → tag
span_id.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringService name used when a record has noservice.nameresource attribute. -
Constructor Summary
ConstructorsConstructorDescriptionSkyWalkingLogExporter(HttpTransport transport, String serviceName, boolean ownsTransport) Creates an exporter on a transport whose base URL is the OAP REST URL. -
Method Summary
Modifier and TypeMethodDescriptionexport(List<LogRecord> records, ExportOptions options) Posts one batch; transport errors fail the future (the batch processor retries retryable ones).shutdown()Idempotent; closes the transport when the exporter owns it.static StringConverts an attribute value to SkyWalking's string tag form (JSON for lists and maps).Maps a record to the nativeLogDataJSON object (see the class description).static LogRecordMaps a stored log back to a SPEC record: taglevel→ severity and severity text (default INFO), a 16-hexspan_idtag →spanId, a 32-hextraceId→traceId(native trace ids go to attributesw.trace_id), other tags → attributes (strings), service/instance → resourceservice.name/service.instance.id, endpoint → resourcesw.endpoint.
-
Field Details
-
DEFAULT_SERVICE_NAME
Service name used when a record has noservice.nameresource attribute.- See Also:
-
-
Constructor Details
-
SkyWalkingLogExporter
Creates an exporter on a transport whose base URL is the OAP REST URL.- Parameters:
transport- transport (for exampleSkyWalkingClient.transport())serviceName- service name for records withoutservice.name(null = "unknown_service")ownsTransport- close the transport onshutdown()
-
-
Method Details
-
tagText
Converts an attribute value to SkyWalking's string tag form (JSON for lists and maps).- Parameters:
value- attribute value- Returns:
- the text
-
toLogData
Maps a record to the nativeLogDataJSON object (see the class description).- Parameters:
record- recorddefaultService- service name for records withoutservice.name- Returns:
- the
LogDatamap
-
toRecord
Maps a stored log back to a SPEC record: taglevel→ severity and severity text (default INFO), a 16-hexspan_idtag →spanId, a 32-hextraceId→traceId(native trace ids go to attributesw.trace_id), other tags → attributes (strings), service/instance → resourceservice.name/service.instance.id, endpoint → resourcesw.endpoint.- Parameters:
log- stored log- Returns:
- the record
-
export
Posts one batch; transport errors fail the future (the batch processor retries retryable ones).- Specified by:
exportin interfaceLogExporter- Parameters:
records- recordsoptions- export options (gzip is ignored: OAP's HTTP receiver gets plain JSON)- Returns:
- a future with the result
-
shutdown
Idempotent; closes the transport when the exporter owns it.- Specified by:
shutdownin interfaceLogExporter- Returns:
- a completed future
-