diff --git a/system/jlib/jtrace.cpp b/system/jlib/jtrace.cpp index bed8ce5faf1..17a2c53cd68 100644 --- a/system/jlib/jtrace.cpp +++ b/system/jlib/jtrace.cpp @@ -485,7 +485,7 @@ class CServerSpan : public CSpan void setSpanContext(StringArray & httpHeaders, const char kvDelineator = ':') { - Owned contextProps = createProperties(); + Owned contextProps = createProperties(true); ForEachItemIn(currentHeaderIndex, httpHeaders) { const char* httpHeader = httpHeaders.item(currentHeaderIndex); @@ -516,11 +516,15 @@ class CServerSpan : public CSpan if (httpHeaders->hasProp(kGlobalIdHttpHeaderName)) hpccGlobalId.set(httpHeaders->queryProp(kGlobalIdHttpHeaderName)); + else if (httpHeaders->hasProp(kLegacyGlobalIdHttpHeaderName)) + hpccGlobalId.set(httpHeaders->queryProp(kLegacyGlobalIdHttpHeaderName)); else DBGLOG("ServerSpan: HPCCGlobalID not found in http headers"); if (httpHeaders->hasProp(kCallerIdHttpHeaderName)) hpccCallerId.set(httpHeaders->queryProp(kCallerIdHttpHeaderName)); + else if (httpHeaders->hasProp(kLegacyCallerIdHttpHeaderName)) + hpccCallerId.set(httpHeaders->queryProp(kLegacyCallerIdHttpHeaderName)); else { DBGLOG("ServerSpan: HPCCCallerID not provied"); diff --git a/system/jlib/jtrace.hpp b/system/jlib/jtrace.hpp index 7a2740c3163..a85996ec3f2 100644 --- a/system/jlib/jtrace.hpp +++ b/system/jlib/jtrace.hpp @@ -25,6 +25,8 @@ */ static constexpr const char *kGlobalIdHttpHeaderName = "global-id"; static constexpr const char *kCallerIdHttpHeaderName = "caller-id"; +static constexpr const char *kLegacyGlobalIdHttpHeaderName = "hpcc-global-id"; +static constexpr const char *kLegacyCallerIdHttpHeaderName = "hpcc-caller-id"; class jlib_decl LogTrace { diff --git a/testing/unittests/jlibtests.cpp b/testing/unittests/jlibtests.cpp index 4d22649eaf5..9106924e6dd 100644 --- a/testing/unittests/jlibtests.cpp +++ b/testing/unittests/jlibtests.cpp @@ -122,12 +122,12 @@ class JlibTraceTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected getSpanContext failure detected", true, getSpanCtxSuccess); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected GlobalID detected", 0, - strcmp("IncomingUGID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName))); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected CallerID detected", 0, - strcmp("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName))); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected Declared Parent SpanID detected", 0, - strcmp("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID"))); + CPPUNIT_ASSERT_MESSAGE("Unexpected GlobalID detected", + strsame("IncomingUGID", retrievedSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName))); + CPPUNIT_ASSERT_MESSAGE("Unexpected CallerID detected", + strsame("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName))); + CPPUNIT_ASSERT_MESSAGE("Unexpected Declared Parent SpanID detected", + strsame("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID"))); CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected empty TraceID detected", false, isEmptyString(retrievedSpanCtxAttributes->queryProp("traceID"))); CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected empty SpanID detected", false, isEmptyString(retrievedSpanCtxAttributes->queryProp("spanID"))); @@ -178,14 +178,14 @@ class JlibTraceTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected missing localParentSpanID detected", true, retrievedSpanCtxAttributes->hasProp("localParentSpanID")); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Mismatched localParentSpanID detected", 0, - strcmp(serverSpanID, retrievedSpanCtxAttributes->queryProp("localParentSpanID"))); + CPPUNIT_ASSERT_MESSAGE("Mismatched localParentSpanID detected", + strsame(serverSpanID, retrievedSpanCtxAttributes->queryProp("localParentSpanID"))); CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected missing remoteParentID detected", true, retrievedSpanCtxAttributes->hasProp("remoteParentID")); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected CallerID detected", 0, - strcmp(serverTraceID, retrievedSpanCtxAttributes->queryProp("remoteParentID"))); + CPPUNIT_ASSERT_MESSAGE("Unexpected CallerID detected", + strsame(serverTraceID, retrievedSpanCtxAttributes->queryProp("remoteParentID"))); CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected GlobalID detected", false, retrievedSpanCtxAttributes->hasProp(kGlobalIdHttpHeaderName)); @@ -227,8 +227,8 @@ class JlibTraceTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected missing localParentSpanID detected", true, retrievedSpanCtxAttributes->hasProp("localParentSpanID")); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Mismatched localParentSpanID detected", 0, - strcmp(serverSpanID, retrievedSpanCtxAttributes->queryProp("localParentSpanID"))); + CPPUNIT_ASSERT_MESSAGE("Mismatched localParentSpanID detected", + strsame(serverSpanID, retrievedSpanCtxAttributes->queryProp("localParentSpanID"))); CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected remoteParentSpanID detected", false, retrievedSpanCtxAttributes->hasProp("remoteParentSpanID")); @@ -323,13 +323,13 @@ class JlibTraceTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected getSpanContext failure detected", true, getSpanCtxSuccess); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected GlobalID detected", 0, - strcmp("IncomingUGID", retrievedSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName))); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected CallerID detected", 0, - strcmp("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName))); + CPPUNIT_ASSERT_MESSAGE("Unexpected GlobalID detected", + strsame("IncomingUGID", retrievedSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName))); + CPPUNIT_ASSERT_MESSAGE("Unexpected CallerID detected", + strsame("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName))); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected Declared Parent SpanID detected", 0, - strcmp("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID"))); + CPPUNIT_ASSERT_MESSAGE("Unexpected Declared Parent SpanID detected", + strsame("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID"))); } void testPropegatedServerSpan() @@ -348,13 +348,13 @@ class JlibTraceTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected getSpanContext failure detected", true, getSpanCtxSuccess); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected GlobalID detected", 0, - strcmp("IncomingUGID", retrievedSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName))); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected CallerID detected", 0, - strcmp("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName))); + CPPUNIT_ASSERT_MESSAGE("Unexpected GlobalID detected", + strsame("IncomingUGID", retrievedSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName))); + CPPUNIT_ASSERT_MESSAGE("Unexpected CallerID detected", + strsame("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName))); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected Declared Parent SpanID detected", 0, - strcmp("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID"))); + CPPUNIT_ASSERT_MESSAGE("Unexpected Declared Parent SpanID detected", + strsame("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID"))); CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected empty TraceID detected", false, isEmptyString(retrievedSpanCtxAttributes->queryProp("traceID"))); CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected empty SpanID detected", false, isEmptyString(retrievedSpanCtxAttributes->queryProp("spanID"))); @@ -394,13 +394,13 @@ class JlibTraceTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected getSpanContext failure detected", true, getSpanCtxSuccess); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected GlobalID detected", 0, - strcmp("someGlobalID", retrievedSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName))); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected CallerID detected", 0, - strcmp("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName))); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected GlobalID detected", true, + strsame("someGlobalID", retrievedSpanCtxAttributes->queryProp(kGlobalIdHttpHeaderName))); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected CallerID detected", true, + strsame("IncomingCID", retrievedSpanCtxAttributes->queryProp(kCallerIdHttpHeaderName))); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected Declared Parent SpanID detected", 0, - strcmp("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID"))); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Unexpected Declared Parent SpanID detected", true, + strsame("4b960b3e4647da3f", retrievedSpanCtxAttributes->queryProp("remoteParentSpanID"))); } } };