diff --git a/src/main/java/org/datadog/jenkins/plugins/datadog/model/BuildData.java b/src/main/java/org/datadog/jenkins/plugins/datadog/model/BuildData.java index 99503d8b..4efeb29b 100644 --- a/src/main/java/org/datadog/jenkins/plugins/datadog/model/BuildData.java +++ b/src/main/java/org/datadog/jenkins/plugins/datadog/model/BuildData.java @@ -152,7 +152,9 @@ public class BuildData implements Serializable { private Long traceId; private Long spanId; + @Nullable private String upstreamPipelineUrl; + @Nullable private Long upstreamPipelineTraceId; public BuildData(Run run, @Nullable TaskListener listener) throws IOException, InterruptedException { @@ -288,18 +290,18 @@ private void populateUpstreamPipelineData(Run run, EnvVars envVars) { String upstreamUrl = upstreamCause.getUpstreamUrl(); int upstreamBuild = upstreamCause.getUpstreamBuild(); if (hudsonUrl != null && upstreamUrl != null) { - upstreamPipelineUrl = hudsonUrl + upstreamUrl + upstreamBuild + "/"; + this.upstreamPipelineUrl = hudsonUrl + upstreamUrl + upstreamBuild + "/"; } String upstreamProject = upstreamCause.getUpstreamProject(); if (upstreamProject != null) { - upstreamBuildTag = "jenkins-" + upstreamProject.replace('/', '-') + "-" + upstreamBuild; + this.upstreamBuildTag = "jenkins-" + upstreamProject.replace('/', '-') + "-" + upstreamBuild; BuildSpanAction buildSpanAction = run.getAction(BuildSpanAction.class); if (buildSpanAction != null) { TraceSpan.TraceSpanContext upstreamSpanContext = buildSpanAction.getUpstreamSpanContext(); if (upstreamSpanContext != null) { - upstreamPipelineTraceId = upstreamSpanContext.getTraceId(); + this.upstreamPipelineTraceId = upstreamSpanContext.getTraceId(); } } } @@ -862,10 +864,12 @@ private String getUserEmailByUserId(String userId) { } } + @Nullable public String getUpstreamPipelineUrl() { return upstreamPipelineUrl; } + @Nullable public Long getUpstreamPipelineTraceId() { return upstreamPipelineTraceId; } @@ -937,11 +941,11 @@ public JSONObject addLogAttributes(){ payload.put("hostname", this.hostname); if(traceId != null){ - payload.put("dd.trace_id", Long.toUnsignedString(traceId)); + payload.put("dd.trace_id", Long.toUnsignedString(this.traceId)); } if(spanId != null) { - payload.put("dd.span_id", Long.toUnsignedString(spanId)); + payload.put("dd.span_id", Long.toUnsignedString(this.spanId)); } return payload; } catch (Exception e){ diff --git a/src/main/java/org/datadog/jenkins/plugins/datadog/traces/BuildSpanAction.java b/src/main/java/org/datadog/jenkins/plugins/datadog/traces/BuildSpanAction.java index 837482cc..ca179a11 100644 --- a/src/main/java/org/datadog/jenkins/plugins/datadog/traces/BuildSpanAction.java +++ b/src/main/java/org/datadog/jenkins/plugins/datadog/traces/BuildSpanAction.java @@ -31,7 +31,7 @@ public BuildSpanAction(final TraceSpan.TraceSpanContext buildSpanContext, @Nulla this.version = new AtomicInteger(0); } - public BuildSpanAction(TraceSpan.TraceSpanContext buildSpanContext, TraceSpan.TraceSpanContext upstreamSpanContext, int version, String buildUrl) { + public BuildSpanAction(TraceSpan.TraceSpanContext buildSpanContext, @Nullable TraceSpan.TraceSpanContext upstreamSpanContext, int version, String buildUrl) { this.buildSpanContext = buildSpanContext; this.upstreamSpanContext = upstreamSpanContext; this.version = new AtomicInteger(version);