Skip to content

Commit

Permalink
Merge branch 'master' into nikita-tkachenko/update-include-exclude-de…
Browse files Browse the repository at this point in the history
…scription
  • Loading branch information
nikita-tkachenko-datadog committed Feb 1, 2024
2 parents 6d1a500 + 860021a commit 71adb72
Show file tree
Hide file tree
Showing 116 changed files with 4,873 additions and 5,170 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
Changes
=======
## 6.0.0 / 2024-01-31
https://github.com/jenkinsci/datadog-plugin/compare/datadog-5.6.2...datadog-6.0.0

Reworking CI Visibility logic: changing how the plugin's internal state is stored, and how pipeline steps are submitted to Datadog.

* [Fixed] Update job name calculation logic to correctly set names for builds that live inside folders. See [#383](https://github.com/jenkinsci/datadog-plugin/pull/383).
* [Fixed] Optimise memory consumption, CPU usage and disk writes. See [#381](https://github.com/jenkinsci/datadog-plugin/pull/381).
* [Fixed] Rework CI Visibility spans batching. See [#379](https://github.com/jenkinsci/datadog-plugin/pull/379).

## 5.6.2 / 2024-01-08
### Details
https://github.com/jenkinsci/datadog-plugin/compare/datadog-5.6.1...datadog-5.6.2
Expand Down
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<url>https://github.com/jenkinsci/datadog-plugin</url>
<groupId>org.datadog.jenkins.plugins</groupId>
<artifactId>datadog</artifactId>
<version>5.6.3-SNAPSHOT</version>
<version>6.0.1-SNAPSHOT</version>
<packaging>hpi</packaging>

<properties>
Expand Down Expand Up @@ -152,10 +152,20 @@
<artifactId>workflow-basic-steps</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
</dependency>
<!-- needed because pipeline name extraction logic is special for matrix project builds -->
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
</dependency>
<dependency>
<groupId>org.jenkinsci.plugins</groupId>
<artifactId>pipeline-model-definition</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,29 @@ of this software and associated documentation files (the "Software"), to deal
package org.datadog.jenkins.plugins.datadog;

import com.timgroup.statsd.ServiceCheck;
import hudson.model.Run;
import hudson.util.Secret;
import java.util.Map;
import java.util.Set;
import org.datadog.jenkins.plugins.datadog.clients.Metrics;
import org.datadog.jenkins.plugins.datadog.model.BuildData;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.datadog.jenkins.plugins.datadog.traces.write.TraceWriteStrategy;

public interface DatadogClient {

public static enum ClientType {
enum ClientType {
HTTP,
DSD;

private ClientType() { }
ClientType() { }
}

public static enum Status {
enum Status {
OK(0),
WARNING(1),
CRITICAL(2),
UNKNOWN(3);

private final int val;

private Status(int val) {
Status(int val) {
this.val = val;
}

Expand All @@ -64,39 +61,13 @@ public ServiceCheck.Status toServiceCheckStatus(){
}
}

public void setUrl(String url);

public void setLogIntakeUrl(String logIntakeUrl);

public void setWebhookIntakeUrl(String webhookIntakeUrl);

public void setApiKey(Secret apiKey);

public void setHostname(String hostname);

public void setPort(Integer port);

public void setLogCollectionPort(Integer logCollectionPort);

public boolean isDefaultIntakeConnectionBroken();

public void setDefaultIntakeConnectionBroken(boolean defaultIntakeConnectionBroken);

public boolean isLogIntakeConnectionBroken();

public boolean isWebhookIntakeConnectionBroken();

public void setLogIntakeConnectionBroken(boolean logIntakeConnectionBroken);

public void setWebhookIntakeConnectionBroken(boolean webhookIntakeConnectionBroken);

/**
* Sends an event to the Datadog API, including the event payload.
*
* @param event - a DatadogEvent object
* @return a boolean to signify the success or failure of the HTTP POST request.
*/
public boolean event(DatadogEvent event);
boolean event(DatadogEvent event);

/**
* Increment a counter for the given metrics.
Expand All @@ -107,14 +78,14 @@ public ServiceCheck.Status toServiceCheckStatus(){
* @param tags - metric tags
* @return a boolean to signify the success or failure of increment submission.
*/
public boolean incrementCounter(String name, String hostname, Map<String, Set<String>> tags);
boolean incrementCounter(String name, String hostname, Map<String, Set<String>> tags);

/**
* Submit all your counters as rate with 10 seconds intervals.
*/
public void flushCounters();
void flushCounters();

public Metrics metrics();
Metrics metrics();

/**
* Sends a service check to the Datadog API, including the check name, and status.
Expand All @@ -125,45 +96,15 @@ public ServiceCheck.Status toServiceCheckStatus(){
* @param tags - A Map containing the tags to submit.
* @return a boolean to signify the success or failure of the HTTP POST request.
*/
public boolean serviceCheck(String name, Status status, String hostname, Map<String, Set<String>> tags);
boolean serviceCheck(String name, Status status, String hostname, Map<String, Set<String>> tags);

/**
* Send log message.
* @param payload log payload to submit JSON object as String
* @return a boolean to signify the success or failure of the request.
*/
public boolean sendLogs(String payload);
boolean sendLogs(String payload);

/**
* Send a webhook payload to the webhooks intake.
*
* @param payload - A webhooks payload.
* @return a boolean to signify the success or failure of the HTTP POST request.
*/
public boolean postWebhook(String payload);

/**
* Start the trace of a certain Jenkins build.
* @param buildData build data to use in the pipeline trace
* @param run a particular execution of a Jenkins build
* @return a boolean to signify the success or failure of the request.
*/
boolean startBuildTrace(BuildData buildData, Run<?, ?> run);

/**
* Finish the trace of a certain Jenkins build.
* @param buildData build data to use in the pipeline trace
* @param run the run to create a pipeline trace for
* @return a boolean to signify the success or failure of the request.
*/
boolean finishBuildTrace(BuildData buildData, Run<?, ?> run);

/**
* Send all traces related to a certain Jenkins pipeline.
* @param run a particular execution of a Jenkins build
* @param flowNode current flowNode
* @return a boolean to signify the success or failure of the request.
*/
boolean sendPipelineTrace(Run<?, ?> run, FlowNode flowNode);
TraceWriteStrategy createTraceWriteStrategy();

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ of this software and associated documentation files (the "Software"), to deal
import com.cloudbees.plugins.credentials.common.StandardListBoxModel;
import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder;
import org.datadog.jenkins.plugins.datadog.clients.HttpClient;
import org.datadog.jenkins.plugins.datadog.traces.write.TraceWriterFactory;
import org.jenkinsci.plugins.plaincredentials.StringCredentials;

import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.datadog.jenkins.plugins.datadog.clients.ClientFactory;
import org.datadog.jenkins.plugins.datadog.clients.DatadogHttpClient;
import org.datadog.jenkins.plugins.datadog.clients.DatadogApiClient;
import org.datadog.jenkins.plugins.datadog.clients.DatadogAgentClient;
import org.datadog.jenkins.plugins.datadog.util.SuppressFBWarnings;
import org.datadog.jenkins.plugins.datadog.util.config.DatadogAgentConfiguration;
Expand Down Expand Up @@ -445,7 +446,7 @@ public FormValidation doTestConnection(
throws IOException, ServletException {
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
final Secret secret = findSecret(targetApiKey, targetCredentialsApiKey);
if (DatadogHttpClient.validateDefaultIntakeConnection(new HttpClient(60_000), targetApiURL, secret)) {
if (DatadogApiClient.validateDefaultIntakeConnection(new HttpClient(60_000), targetApiURL, secret)) {
return FormValidation.ok("Great! Your API key is valid.");
} else {
return FormValidation.error("Hmmm, your API key seems to be invalid.");
Expand Down Expand Up @@ -839,9 +840,9 @@ public boolean configure(final StaplerRequest req, final JSONObject formData) th
if(client == null) {
return false;
}
client.setDefaultIntakeConnectionBroken(false);
client.setLogIntakeConnectionBroken(false);
client.setWebhookIntakeConnectionBroken(false);

TraceWriterFactory.onDatadogClientUpdate(client);

// Persist global configuration information
save();
return true;
Expand Down
Loading

0 comments on commit 71adb72

Please sign in to comment.