From 47bef1422671969533659b164b606054a6582471 Mon Sep 17 00:00:00 2001 From: Nishchay Malhotra Date: Wed, 27 Mar 2024 11:16:55 +0530 Subject: [PATCH] Adding fix for span creation npe Signed-off-by: Nishchay Malhotra --- .../org/opensearch/telemetry/tracing/OTelTracingTelemetry.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelTracingTelemetry.java b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelTracingTelemetry.java index 91056cfd95fe3..90f471bbb8a13 100644 --- a/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelTracingTelemetry.java +++ b/plugins/telemetry-otel/src/main/java/org/opensearch/telemetry/tracing/OTelTracingTelemetry.java @@ -74,7 +74,8 @@ private Span createOtelSpan(SpanCreationContext spanCreationContext, Span parent private void addInferredAttribute(Span newSpan, SpanCreationContext spanCreationContext) { // If the current context has this attribute we need to add the same to the span as well. if (Baggage.current().getEntryValue(TracerContextStorage.INFERRED_SAMPLER) != null - || spanCreationContext.getAttributes().getAttributesMap().containsKey(TracerContextStorage.INFERRED_SAMPLER)) { + || (spanCreationContext.getAttributes() != null + && spanCreationContext.getAttributes().getAttributesMap().containsKey(TracerContextStorage.INFERRED_SAMPLER))) { newSpan.addAttribute(TracerContextStorage.INFERRED_SAMPLER, true); } }