Package codes.grow.packages.betterstack
Class BetterStackLogExporter
java.lang.Object
codes.grow.packages.betterstack.BetterStackLogExporter
- All Implemented Interfaces:
LogExporter
LogExporter for Better Stack's HTTP ingest API (POST {url}/ on the source's
ingesting host, Authorization: Bearer <source token>).
Records are mapped with BetterStackEvents.toEvent(codes.grow.packages.betterstack.logging.LogRecord), split so that no request exceeds
maxRequestBytes (10 MiB), encoded as JSON, NDJSON or MessagePack and gzip-compressed when
the export asks for it. A record larger than maxRecordBytes is rejected with a ValidationException before anything is sent. Exports are retried like idempotent calls (429,
5xx, network errors); Better Stack does not deduplicate, so a retry after a lost answer can store
a record twice. Get one from BetterStackClient.exporter() or BetterStackClient.newExporter(BetterStackLogExporterOptions).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intBetter Stack limit for one record (uncompressed): 10 MiB.static final intBetter Stack limit for one request body (measured compressed): 10 MiB. -
Method Summary
Modifier and TypeMethodDescriptionencoding()Returns the body encoding.export(List<LogRecord> records, ExportOptions options) Sends the records in as few requests as the limits allow.intReturns the encoded size limit of one record.intReturns the uncompressed size limit of one request.voidsendEvents(List<? extends Map<String, ?>> events) Posts raw events (any JSON objects;dtmay be anInstant, an RFC 3339 string or UNIX seconds/ms/ns) as one request, gzip-compressed, in the exporter's encoding.voidsendEvents(List<? extends Map<String, ?>> events, SendEventsOptions options) Posts raw events as one request (no splitting).sendEventsAsync(List<? extends Map<String, ?>> events, SendEventsOptions options) AsynchronoussendEvents(List, SendEventsOptions).shutdown()Nothing to release; the client owns the transport.
-
Field Details
-
MAX_REQUEST_BYTES
public static final int MAX_REQUEST_BYTESBetter Stack limit for one request body (measured compressed): 10 MiB.- See Also:
-
MAX_RECORD_BYTES
public static final int MAX_RECORD_BYTESBetter Stack limit for one record (uncompressed): 10 MiB.- See Also:
-
-
Method Details
-
encoding
Returns the body encoding.- Returns:
- the encoding
-
maxRequestBytes
public int maxRequestBytes()Returns the uncompressed size limit of one request.- Returns:
- bytes
-
maxRecordBytes
public int maxRecordBytes()Returns the encoded size limit of one record.- Returns:
- bytes
-
export
Sends the records in as few requests as the limits allow. The future never fails for service errors: a failing request stops the export and its records and every later record count as rejected (ExportResult.error()holds the mapped exception).- Specified by:
exportin interfaceLogExporter- Parameters:
records- recordsoptions- gzip flag and time budget- Returns:
- the result
-
sendEvents
Posts raw events (any JSON objects;dtmay be anInstant, an RFC 3339 string or UNIX seconds/ms/ns) as one request, gzip-compressed, in the exporter's encoding.- Parameters:
events- events- Throws:
BetterStackException- mapped likeexport(java.util.List<codes.grow.packages.betterstack.logging.LogRecord>, codes.grow.packages.betterstack.logging.ExportOptions): 403 authentication, 402 quota (not retryable), 406/413 validation
-
sendEvents
Posts raw events as one request (no splitting).- Parameters:
events- eventsoptions- encoding and gzip- Throws:
ValidationException- when the body exceedsmaxRequestBytes
-
sendEventsAsync
public CompletableFuture<Void> sendEventsAsync(List<? extends Map<String, ?>> events, SendEventsOptions options) AsynchronoussendEvents(List, SendEventsOptions).- Parameters:
events- eventsoptions- encoding and gzip- Returns:
- a future completed when the service accepted the request
-
shutdown
Nothing to release; the client owns the transport.- Specified by:
shutdownin interfaceLogExporter- Returns:
- a completed future
-