Class BatchingLogClient
java.lang.Object
codes.grow.packages.betterstack.logging.BatchingLogClient
- All Implemented Interfaces:
LogClient,AutoCloseable
LogClient built from a LogExporter, BatchOptions, resource attributes and
a RedactionProcessor.
LogClient logs = BatchingLogClient.builder(exporter)
.resource(Map.of("service.name", "checkout"))
.build();
logs.logger("orders").info("order placed", Map.of("order.id", 42));
logs.close();
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic BatchingLogClient.Builderbuilder(LogExporter exporter) Returns a builder.voidclose()Flushes and shuts down; idempotent.AsynchronousLogClient.close().voidflush()Exports everything queued now, waiting at most the export timeout.voidExports everything queued now.flushAsync(Duration timeout) AsynchronousLogClient.flush(Duration).The underlying processor.resource()Resource attributes added to every record.voidEnqueues one record or input.voidsendBatch(Collection<? extends LogEntry> entries) Enqueues several records or inputs.stats()Current counters.
-
Method Details
-
builder
Returns a builder.- Parameters:
exporter- the service exporter- Returns:
- builder
-
processor
The underlying processor.- Returns:
- processor
-
resource
Resource attributes added to every record.- Returns:
- resource
-
send
Description copied from interface:LogClientEnqueues one record or input. Applies redaction and defaults (timestamp = now, resource from the client, trace correlation for inputs when a span is active). Never throws for a full queue or a closed client; the record is dropped and counted instead. -
sendBatch
Description copied from interface:LogClientEnqueues several records or inputs. -
flush
public void flush()Description copied from interface:LogClientExports everything queued now, waiting at most the export timeout. -
flush
Description copied from interface:LogClientExports everything queued now. -
flushAsync
Description copied from interface:LogClientAsynchronousLogClient.flush(Duration).- Specified by:
flushAsyncin interfaceLogClient- Parameters:
timeout- maximum wait- Returns:
- completes when the queued records were exported
-
close
public void close()Description copied from interface:LogClientFlushes and shuts down; idempotent.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceLogClient
-
closeAsync
Description copied from interface:LogClientAsynchronousLogClient.close().- Specified by:
closeAsyncin interfaceLogClient- Returns:
- completes when the client is closed
-
stats
Description copied from interface:LogClientCurrent counters.
-