Class DatadogLogEvent

java.lang.Object
codes.grow.packages.datadoglogs.DatadogLogEvent

public final class DatadogLogEvent extends Object
One log event returned by the Datadog search API, flattened (data[] of POST /api/v2/logs/events/search). Immutable.
  • Constructor Details

    • DatadogLogEvent

      public DatadogLogEvent(String id, Instant timestamp, String host, String service, String status, String message, List<String> tags, Map<String,Object> attributes)
      Creates an event; collections are copied.
      Parameters:
      id - Datadog log id
      timestamp - event time, may be null
      host - reserved host, may be null
      service - reserved service, may be null
      status - reserved status, may be null
      message - message text
      tags - tags such as env:test
      attributes - custom attributes (data[].attributes.attributes), nested as returned
  • Method Details

    • id

      public String id()
      Returns the Datadog log id.
      Returns:
      the id (empty string when absent)
    • timestamp

      public Optional<Instant> timestamp()
      Returns the event time.
      Returns:
      the time, or empty when Datadog sent none
    • host

      public Optional<String> host()
      Returns the reserved host.
      Returns:
      the host, or empty
    • service

      public Optional<String> service()
      Returns the reserved service.
      Returns:
      the service, or empty
    • status

      public Optional<String> status()
      Returns the reserved status.
      Returns:
      the status, or empty
    • message

      public String message()
      Returns the message text.
      Returns:
      the message
    • tags

      public List<String> tags()
      Returns the tags.
      Returns:
      immutable list
    • attributes

      public Map<String,Object> attributes()
      Returns the custom attributes as returned (nested objects, for example {"dd":{"trace_id":"…"}}).
      Returns:
      immutable map
    • toLogRecord

      public LogRecord toLogRecord()
      Returns:
      the record
    • toString

      public String toString()
      Overrides:
      toString in class Object