Class DatadogApiClient

  • All Implemented Interfaces:
    DatadogClient

    public class DatadogApiClient
    extends Object
    implements DatadogClient
    This class is used to collect all methods that has to do with transmitting data to Datadog.
    • Field Detail

      • enableValidations

        public static boolean enableValidations
    • Method Detail

      • getInstance

        public static DatadogClient getInstance​(String url,
                                                String logIntakeUrl,
                                                String webhookIntakeUrl,
                                                Secret apiKey)
        NOTE: Use ClientFactory.getClient method to instantiate the client in the Jenkins Plugin This method is not recommended to be used because it misses some validations.
        Parameters:
        url - - target url
        logIntakeUrl - - log intake url
        apiKey - - Secret api Key
        Returns:
        an singleton instance of the DatadogHttpClient.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getUrl

        public String getUrl()
      • getLogIntakeUrl

        public String getLogIntakeUrl()
      • getWebhookIntakeUrl

        public String getWebhookIntakeUrl()
      • getApiKey

        public Secret getApiKey()
      • event

        public boolean event​(DatadogEvent event)
        Description copied from interface: DatadogClient
        Sends an event to the Datadog API, including the event payload.
        Specified by:
        event in interface DatadogClient
        Parameters:
        event - - a DatadogEvent object
        Returns:
        a boolean to signify the success or failure of the HTTP POST request.
      • serviceCheck

        public boolean serviceCheck​(String name,
                                    DatadogClient.Status status,
                                    String hostname,
                                    Map<String,​Set<String>> tags)
        Description copied from interface: DatadogClient
        Sends a service check to the Datadog API, including the check name, and status.
        Specified by:
        serviceCheck in interface DatadogClient
        Parameters:
        name - - A String with the name of the service check to record.
        status - - An Status with the status code to record for this service check.
        hostname - - A String with the hostname to submit.
        tags - - A Map containing the tags to submit.
        Returns:
        a boolean to signify the success or failure of the HTTP POST request.
      • sendLogs

        public boolean sendLogs​(String payload)
        Posts a given payload to the Datadog Logs Intake, using the user configured apiKey.
        Specified by:
        sendLogs in interface DatadogClient
        Parameters:
        payload - - A String containing a specific subset of a builds metadata.
        Returns:
        a boolean to signify the success or failure of the HTTP POST request.
      • validateDefaultIntakeConnection

        public static boolean validateDefaultIntakeConnection​(HttpClient client,
                                                              String validatedUrl,
                                                              Secret apiKey)