diff --git a/modules/core/src/main/java/org/apache/synapse/aspects/flow/statistics/tracing/opentelemetry/management/handling/span/SpanHandler.java b/modules/core/src/main/java/org/apache/synapse/aspects/flow/statistics/tracing/opentelemetry/management/handling/span/SpanHandler.java index 90f8eb4188..7e53367d38 100644 --- a/modules/core/src/main/java/org/apache/synapse/aspects/flow/statistics/tracing/opentelemetry/management/handling/span/SpanHandler.java +++ b/modules/core/src/main/java/org/apache/synapse/aspects/flow/statistics/tracing/opentelemetry/management/handling/span/SpanHandler.java @@ -208,7 +208,10 @@ private void startSpan(StatisticDataUnit statisticDataUnit, MessageContext synCt Object statusCode = ((Axis2MessageContext) synCtx).getAxis2MessageContext().getProperty("HTTP_SC"); Object statusDescription = ((Axis2MessageContext) synCtx).getAxis2MessageContext().getProperty("HTTP_DESC"); // We only need to extract span context from headers when there are trp headers available - if (isOuterLevelSpan(statisticDataUnit, spanStore) && headersMap != null) { + if (headersMap == null) { + headersMap = new HashMap(); + } + if (isOuterLevelSpan(statisticDataUnit, spanStore)) { // Extract span context from headers context = extract(headersMap); } else { @@ -274,9 +277,10 @@ private void bufferSequenceContinuationState(StatisticDataUnit statisticDataUnit * @return Whether the given statistic data unit denotes an outer level span. */ private boolean isOuterLevelSpan(StatisticDataUnit statisticDataUnit, SpanStore spanStore) { - return spanStore.getOuterLevelSpanWrapper() == null && - (statisticDataUnit.getComponentType() == ComponentType.PROXYSERVICE || - statisticDataUnit.getComponentType() == ComponentType.API); + return spanStore.getOuterLevelSpanWrapper() == null + && (statisticDataUnit.getComponentType() == ComponentType.PROXYSERVICE + || statisticDataUnit.getComponentType() == ComponentType.API + || statisticDataUnit.getComponentType() == ComponentType.INBOUNDENDPOINT); } @Override