Package codes.grow.packages.betterstack
Class OtlpLogs
java.lang.Object
codes.grow.packages.betterstack.OtlpLogs
OTLP logs encoding without dependencies:
ExportLogsServiceRequest as protobuf (field
numbers of opentelemetry-proto collector/logs/v1 and logs/v1) or as OTLP/JSON,
and partial_success parsing of the response.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordPartial success reported by an OTLP response. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringInstrumentation scope name of exported records. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]Encodes one OTLPLogRecordmessage.static byte[]encodeProtobuf(List<LogRecord> records, String scopeName) Encodes anExportLogsServiceRequestas protobuf: oneResourceLogsper distinct resource with oneScopeLogs(scopeName, SDK version).jsonRequest(List<LogRecord> records, String scopeName) Builds the OTLP/JSONExportLogsServiceRequestobject.static Optional<OtlpLogs.PartialSuccess> parsePartialSuccess(byte[] body) Readspartial_successfrom a protobufExportLogsServiceResponse.static Optional<OtlpLogs.PartialSuccess> parsePartialSuccessJson(byte[] body) ReadspartialSuccessfrom an OTLP/JSON response body.
-
Field Details
-
DEFAULT_SCOPE_NAME
Instrumentation scope name of exported records.- See Also:
-
-
Method Details
-
encodeLogRecord
Encodes one OTLPLogRecordmessage.- Parameters:
r- record- Returns:
- protobuf bytes
-
encodeProtobuf
Encodes anExportLogsServiceRequestas protobuf: oneResourceLogsper distinct resource with oneScopeLogs(scopeName, SDK version).- Parameters:
records- recordsscopeName- instrumentation scope name- Returns:
- protobuf bytes
-
jsonRequest
Builds the OTLP/JSONExportLogsServiceRequestobject.- Parameters:
records- recordsscopeName- instrumentation scope name- Returns:
- the request as nested maps and lists
-
parsePartialSuccess
Readspartial_successfrom a protobufExportLogsServiceResponse.- Parameters:
body- response bytes- Returns:
- the partial success when records were rejected; empty otherwise or when unreadable
-
parsePartialSuccessJson
ReadspartialSuccessfrom an OTLP/JSON response body.- Parameters:
body- response bytes (may be empty)- Returns:
- the partial success when records were rejected; empty otherwise or when unreadable
-