Skip to content

Commit

Permalink
Enable traces batching by default
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-tkachenko-datadog committed Nov 21, 2024
1 parent 68b6501 commit 73a30d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ of this software and associated documentation files (the "Software"), to deal

package org.datadog.jenkins.plugins.datadog.clients;

import static org.datadog.jenkins.plugins.datadog.traces.write.TraceWriteStrategy.ENABLE_TRACES_BATCHING_ENV_VAR;

import com.timgroup.statsd.Event;
import com.timgroup.statsd.NonBlockingStatsDClient;
Expand Down Expand Up @@ -374,20 +373,11 @@ public TraceWriteStrategy createTraceWriteStrategy() {
String urlParameters = datadogGlobalDescriptor != null ? "?service=" + datadogGlobalDescriptor.getCiInstanceName() : "";
String url = String.format("http://%s:%d/evp_proxy/v1/api/v2/webhook/%s", hostname, traceCollectionPort, urlParameters);

// TODO use CompressedBatchSender unconditionally in the next release
JsonPayloadSender<Payload> payloadSender;
if (DatadogUtilities.envVar(ENABLE_TRACES_BATCHING_ENV_VAR, false)) {
Map<String, String> headers = Map.of(
"X-Datadog-EVP-Subdomain", "webhook-intake",
"DD-CI-PROVIDER-NAME", "jenkins",
"Content-Encoding", "gzip");
payloadSender = new CompressedBatchSender<>(client, url, headers, PAYLOAD_SIZE_LIMIT, p -> p.getJson());
} else {
Map<String, String> headers = Map.of(
"X-Datadog-EVP-Subdomain", "webhook-intake",
"DD-CI-PROVIDER-NAME", "jenkins");
payloadSender = new SimpleSender<>(client, url, headers, p -> p.getJson());
}
Map<String, String> headers = Map.of(
"X-Datadog-EVP-Subdomain", "webhook-intake",
"DD-CI-PROVIDER-NAME", "jenkins",
"Content-Encoding", "gzip");
JsonPayloadSender<Payload> payloadSender = new CompressedBatchSender<>(client, url, headers, PAYLOAD_SIZE_LIMIT, p -> p.getJson());

TraceWriteStrategyImpl evpStrategy = new TraceWriteStrategyImpl(Track.WEBHOOK, payloadSender::send);
TraceWriteStrategyImpl apmStrategy = new TraceWriteStrategyImpl(Track.APM, this::sendSpansToApm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ of this software and associated documentation files (the "Software"), to deal

package org.datadog.jenkins.plugins.datadog.clients;

import static org.datadog.jenkins.plugins.datadog.traces.write.TraceWriteStrategy.ENABLE_TRACES_BATCHING_ENV_VAR;

import hudson.util.Secret;
import java.io.IOException;
Expand Down Expand Up @@ -363,20 +362,11 @@ public TraceWriteStrategy createTraceWriteStrategy() {
String urlParameters = datadogGlobalDescriptor != null ? "?service=" + datadogGlobalDescriptor.getCiInstanceName() : "";
String url = webhookIntakeUrl + urlParameters;

// TODO use CompressedBatchSender unconditionally in the next release
JsonPayloadSender<Payload> payloadSender;
if (DatadogUtilities.envVar(ENABLE_TRACES_BATCHING_ENV_VAR, false)) {
Map<String, String> headers = Map.of(
"DD-API-KEY", Secret.toString(apiKey),
"DD-CI-PROVIDER-NAME", "jenkins",
"Content-Encoding", "gzip");
payloadSender = new CompressedBatchSender<>(httpClient, url, headers, PAYLOAD_SIZE_LIMIT, p -> p.getJson());
} else {
Map<String, String> headers = Map.of(
"DD-API-KEY", Secret.toString(apiKey),
"DD-CI-PROVIDER-NAME", "jenkins");
payloadSender = new SimpleSender<>(httpClient, url, headers, p -> p.getJson());
}
Map<String, String> headers = Map.of(
"DD-API-KEY", Secret.toString(apiKey),
"DD-CI-PROVIDER-NAME", "jenkins",
"Content-Encoding", "gzip");
JsonPayloadSender<Payload> payloadSender = new CompressedBatchSender<>(httpClient, url, headers, PAYLOAD_SIZE_LIMIT, p -> p.getJson());

return new TraceWriteStrategyImpl(Track.WEBHOOK, payloadSender::send);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

public interface TraceWriteStrategy {

String ENABLE_TRACES_BATCHING_ENV_VAR = "DD_JENKINS_ENABLE_TRACES_BATCHING";

@Nullable
Payload serialize(BuildData buildData, Run<?, ?> run);

Expand Down

0 comments on commit 73a30d1

Please sign in to comment.