Skip to content

Commit

Permalink
HPCC-30405 Code review 1
Browse files Browse the repository at this point in the history
- Adds default global.tracing.disable
- Exposes getNullSpan jlib function
- Remove superfluous semicolons

Signed-off-by: Rodrigo Pastrana <[email protected]>
  • Loading branch information
rpastrana committed Oct 23, 2023
1 parent 0d7e62a commit 8f27049
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
4 changes: 4 additions & 0 deletions helm/hpcc/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ global:
logging:
detail: 80

#
tracing:
disable: false

## resource settings for stub components
#stubInstanceResources:
# memory: "200Mi"
Expand Down
49 changes: 27 additions & 22 deletions system/jlib/jtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,40 +536,33 @@ class CSpan : public CInterfaceOf<ISpan>
CSpan * localParentSpan = nullptr;
};

static Owned<ISpan> nullSpan;
class CNullSpan : public CInterfaceOf<ISpan>
{
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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -964,7 +962,7 @@ class CTraceManager : implements ITraceManager, public CInterface

ISpan * createNullSpan() const override
{
return CNullSpan::getNullSpan();
return getNullSpan();
}

const char * getTracedComponentName() const override
Expand Down Expand Up @@ -995,6 +993,13 @@ MODULE_EXIT()
theTraceManager.destroy();
}

static Owned<ISpan> 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); });
Expand Down
1 change: 1 addition & 0 deletions system/jlib/jtrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 8f27049

Please sign in to comment.