Package codes.grow.packages.datadoglogs
Class DatadogLogClient
java.lang.Object
codes.grow.packages.datadoglogs.DatadogLogClient
- All Implemented Interfaces:
LogClient,AutoCloseable
LogClient that ships records to the Datadog logs intake through a DatadogLogExporter and a background BatchProcessor. Create it with DatadogLogsClient.logClient(Options); DatadogLogsClient.close() flushes and closes it.
DatadogLogClient logs = client.logClient();
logs.logger("checkout").info("user signed in", Map.of("user", Map.of("id", 42)));
logs.flush();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOptions ofDatadogLogsClient.logClient(Options): batching (capped at the intake limits: 1000 records, 5 000 000 bytes per batch), resource (merged over the configuredservice,version,envandhostname), redaction and intake limits. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Flushes and shuts down; idempotent.AsynchronousLogClient.close().exporter()Returns the intake exporter used by this client.voidflush()Exports everything queued now, waiting at most the export timeout.voidExports everything queued now.flushAsync(Duration timeout) AsynchronousLogClient.flush(Duration).Returns the batch processor (queue, stats).resource()Returns the resource merged into every record.voidEnqueues one record or input.voidsendBatch(Collection<? extends LogEntry> entries) Enqueues several records or inputs.stats()Current counters.
-
Method Details
-
exporter
Returns the intake exporter used by this client.- Returns:
- the exporter
-
processor
Returns the batch processor (queue, stats).- Returns:
- the processor
-
resource
Returns the resource merged into every record.- Returns:
- immutable map
-
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.
-