From a0319213e6f867dd0d93ce68e41473328639430b Mon Sep 17 00:00:00 2001 From: Rodrigo Pastrana Date: Tue, 31 Oct 2023 14:07:28 -0400 Subject: [PATCH] HPCC-30697 Track passthrough data as attributes - Creates new setContextAttributes function - Utilizes new setContextAttributes - Defines otel attribute names for globalid, and callerid - No unittest since no exporter available to test locally Signed-off-by: Rodrigo Pastrana --- system/jlib/jtrace.cpp | 10 ++++++++++ system/jlib/jtrace.hpp | 2 ++ 2 files changed, 12 insertions(+) diff --git a/system/jlib/jtrace.cpp b/system/jlib/jtrace.cpp index 88ccae0ec6b..dea2ced7a4f 100644 --- a/system/jlib/jtrace.cpp +++ b/system/jlib/jtrace.cpp @@ -655,6 +655,15 @@ class CServerSpan : public CSpan return success; } + void setContextAttributes() + { + if (!isEmptyString(hpccGlobalId)) + setSpanAttribute(kGlobalIdOtelAttributeName, hpccGlobalId.get()); + + if (!isEmptyString(hpccCallerId)) + setSpanAttribute(kCallerIdOtelAttributeName, hpccCallerId.get()); + } + public: CServerSpan(const char * spanName, const char * tracerName_, const IProperties * httpHeaders, SpanFlags flags) : CSpan(spanName, tracerName_) @@ -662,6 +671,7 @@ class CServerSpan : public CSpan opts.kind = opentelemetry::trace::SpanKind::kServer; setSpanContext(httpHeaders, flags); init(); + setContextAttributes(); } void toLog(StringBuffer & out) const override diff --git a/system/jlib/jtrace.hpp b/system/jlib/jtrace.hpp index a9ec14becca..9e9d58dd8fc 100644 --- a/system/jlib/jtrace.hpp +++ b/system/jlib/jtrace.hpp @@ -27,6 +27,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"; +static constexpr const char *kGlobalIdOtelAttributeName = "hpcc.globalid"; +static constexpr const char *kCallerIdOtelAttributeName = "hpcc.callerid"; enum class SpanFlags : unsigned {