From 8f2704973642dc500944d0c02b808129087df135 Mon Sep 17 00:00:00 2001 From: Rodrigo Pastrana Date: Mon, 23 Oct 2023 17:25:38 -0400 Subject: [PATCH] HPCC-30405 Code review 1 - Adds default global.tracing.disable - Exposes getNullSpan jlib function - Remove superfluous semicolons Signed-off-by: Rodrigo Pastrana --- helm/hpcc/values.yaml | 4 ++++ system/jlib/jtrace.cpp | 49 +++++++++++++++++++++++------------------- system/jlib/jtrace.hpp | 1 + 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/helm/hpcc/values.yaml b/helm/hpcc/values.yaml index 33143fa08b7..f10112bf2fb 100644 --- a/helm/hpcc/values.yaml +++ b/helm/hpcc/values.yaml @@ -25,6 +25,10 @@ global: logging: detail: 80 + # + tracing: + disable: false + ## resource settings for stub components #stubInstanceResources: # memory: "200Mi" diff --git a/system/jlib/jtrace.cpp b/system/jlib/jtrace.cpp index c835f76ee91..8188fa84e29 100644 --- a/system/jlib/jtrace.cpp +++ b/system/jlib/jtrace.cpp @@ -536,40 +536,33 @@ class CSpan : public CInterfaceOf CSpan * localParentSpan = nullptr; }; -static Owned nullSpan; class CNullSpan : public CInterfaceOf { public: - virtual void setSpanAttribute(const char * key, const char * val) override {}; - virtual void setSpanAttributes(const IProperties * attributes) override {}; - virtual void addSpanEvent(const char * eventName) override {}; - virtual bool getSpanContext(IProperties * ctxProps, bool otelFormatted) const override { return false; }; - - virtual void toString(StringBuffer & out) const override {}; - virtual void toLog(StringBuffer & out) const override {}; - virtual void getLogPrefix(StringBuffer & out) const override {}; + CNullSpan() = default; - virtual const char* queryGlobalId() const override { return nullptr; }; - virtual const char* queryCallerId() const override { return nullptr; }; - virtual const char* queryLocalId() const override { return nullptr; }; + virtual void setSpanAttribute(const char * key, const char * val) override {} + virtual void setSpanAttributes(const IProperties * attributes) override {} + virtual void addSpanEvent(const char * eventName) override {} + virtual bool getSpanContext(IProperties * ctxProps, bool otelFormatted) const override { return false; } - virtual ISpan * createClientSpan(const char * name) override { return getNullSpan(); }; - virtual ISpan * createInternalSpan(const char * name) override { return getNullSpan(); }; + virtual void toString(StringBuffer & out) const override {} + virtual void toLog(StringBuffer & out) const override {} + virtual void getLogPrefix(StringBuffer & out) const override {} - static ISpan * getNullSpan() - { - if(!nullSpan) - nullSpan.setown(new CNullSpan()); + virtual const char* queryGlobalId() const override { return nullptr; } + virtual const char* queryCallerId() const override { return nullptr; } + virtual const char* queryLocalId() const override { return nullptr; } - return nullSpan.getLink(); - } + virtual ISpan * createClientSpan(const char * name) override { return getNullSpan(); } + virtual ISpan * createInternalSpan(const char * name) override { return getNullSpan(); } private: - CNullSpan() = default; CNullSpan(const CNullSpan&) = delete; CNullSpan& operator=(const CNullSpan&) = delete; }; + class CInternalSpan : public CSpan { public: @@ -885,7 +878,12 @@ class CTraceManager : implements ITraceManager, public CInterface toXML(traceConfig, xml); DBGLOG("traceConfig tree: %s", xml.str()); #endif + StringBuffer xml; + toXML(traceConfig, xml); + DBGLOG("^^traceConfig tree: %s", xml.str()); + bool disableTracing = traceConfig && traceConfig->getPropBool("@disable", false); + disableTracing = true; using namespace opentelemetry::trace; if (disableTracing) @@ -964,7 +962,7 @@ class CTraceManager : implements ITraceManager, public CInterface ISpan * createNullSpan() const override { - return CNullSpan::getNullSpan(); + return getNullSpan(); } const char * getTracedComponentName() const override @@ -995,6 +993,13 @@ MODULE_EXIT() theTraceManager.destroy(); } +static Owned nullSpan = new CNullSpan(); + +ISpan * getNullSpan() +{ + return nullSpan.getLink(); +} + void initTraceManager(const char * componentName, const IPropertyTree * componentConfig, const IPropertyTree * globalConfig) { theTraceManager.query([=] () { return new CTraceManager(componentName, componentConfig, globalConfig); }); diff --git a/system/jlib/jtrace.hpp b/system/jlib/jtrace.hpp index 694f9bcca91..2e0ae261437 100644 --- a/system/jlib/jtrace.hpp +++ b/system/jlib/jtrace.hpp @@ -66,6 +66,7 @@ interface ITraceManager : extends IInterface virtual const char * getTracedComponentName() const = 0; }; +extern jlib_decl ISpan * getNullSpan(); extern jlib_decl void initTraceManager(const char * componentName, const IPropertyTree * componentConfig, const IPropertyTree * globalConfig); extern jlib_decl ITraceManager & queryTraceManager();