Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise memory consumption, CPU usage and disk writes #381

Merged
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7edec11
Rework CI Visibility spans batching
nikita-tkachenko-datadog Jan 19, 2024
5c3ffb3
Submit pipeline stages and steps without waiting until the pipeline f…
nikita-tkachenko-datadog Jan 23, 2024
36d59f5
Preserve node-name population logic
nikita-tkachenko-datadog Jan 24, 2024
1419368
Fix webhook tests
nikita-tkachenko-datadog Jan 24, 2024
ddfef46
Address review comments
nikita-tkachenko-datadog Jan 24, 2024
7bf5c20
Fix SpotBugs warning
nikita-tkachenko-datadog Jan 24, 2024
7eefea6
Fix integration tests
nikita-tkachenko-datadog Jan 25, 2024
c751e83
Properly convert Windows path to URL
nikita-tkachenko-datadog Jan 25, 2024
ae44b1d
Fix git repo URL asserts in integration tests
nikita-tkachenko-datadog Jan 25, 2024
e7566bd
Replace custom shutdown hook with Jenkins @Terminator mechanism
nikita-tkachenko-datadog Jan 25, 2024
5668099
Merge branch 'nikita-tkachenko/ci-visibility-batching' into nikita-tk…
nikita-tkachenko-datadog Jan 25, 2024
52371d7
Fix integration tests on Windows
nikita-tkachenko-datadog Jan 26, 2024
c793cf8
Address review comments
nikita-tkachenko-datadog Jan 26, 2024
eeeb4c2
Fix NPE
nikita-tkachenko-datadog Jan 26, 2024
1756c79
Renamed some classes and methods
nikita-tkachenko-datadog Jan 26, 2024
d18d872
Merge branch 'nikita-tkachenko/ci-visibility-batching' into nikita-tk…
nikita-tkachenko-datadog Jan 26, 2024
9f40662
Address review comments
nikita-tkachenko-datadog Jan 30, 2024
8a654da
Merge branch 'master' into nikita-tkachenko/memory-consumption-optimi…
nikita-tkachenko-datadog Jan 30, 2024
88b5e10
Add max payload size check for webhook requests
nikita-tkachenko-datadog Jan 29, 2024
d511656
Fix SpotBugs warnings
nikita-tkachenko-datadog Jan 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@
<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>
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
Loading