Logs¶
Logs go to OAP's native HTTP log API (POST /v3/logs, a JSON array of LogData) and come back
through the GraphQL queryLogs. The shared logging layer (batching, back-pressure, redaction,
logger facade, framework adapters — see Logging) sits on top.
logClient / createLogClient¶
A batching LogClient over the native exporter (SkyWalkingLogExporter, Go NativeLogExporter).
Mapping: resource service.name → service (default unknown_service), service.instance.id →
serviceInstance, body → text body, severity → the level tag, attributes → tags (non-string
values JSON-encoded), and the active OpenTelemetry trace/span id → traceContext so that
relatedTrace and trace_id= searches find the log. Logs are sent uncompressed. The native
API is used instead of OTLP logs because OAP drops the top-level trace and span ids of OTLP log
records.
client.logClient(...) is owned by the client (close() flushes it); createLogClient builds a
standalone client with its own connections.
use grow_apache_skywalking::logging::{attrs, LogClient};
use grow_apache_skywalking::SkyWalkingLogClientOptions;
let logs = client.log_client(SkyWalkingLogClientOptions::service("checkout"))?;
logs.logger(Some("api"), attrs! {}).info("order accepted", attrs! { "orderId" => 42 });
logs.flush(None).await?;
search (LogQueryClient)¶
client.logs implements the category LogQueryClient (search, tail, listStreams,
listLabels, waitForLog). The query string is a list of terms:
| Term | Becomes |
|---|---|
service=<name> |
GraphQL condition serviceId |
instance=<name> |
serviceInstanceId (needs service=) |
endpoint=<name> |
endpointId (needs service=) |
trace_id=<id> |
relatedTrace.traceId (native or 32-hex id) |
any other key=value |
tag filter (key must be in SW_SEARCHABLE_LOGS_TAG_KEYS) |
free text ("quoted words" allowed) |
client-side, case-insensitive substring match over content and tag values |
Free text is always filtered on the client: OAP with BanyanDB ignores keywordsOfContent. The
SDK scans raw pages of 1 000 logs (at most 10 pages, maxScanPages) until limit matches are found.
Results are SPEC LogRecords (OpenTelemetry trace ids restored from the trace context, the level
tag → severity). The cursor is "page:offset:size"; the default window is the last hour.
tail / waitForLog / listStreams / listLabels¶
tail polls search (default every second) and delivers new records once; waitForLog polls until
a record matches (test helper, TIMEOUT otherwise). listStreams returns the service names that
have logs; listLabels the log tag keys (queryLogTagAutocompleteKeys).