Skip to content

Commit

Permalink
Merge pull request #17856 from ghalliday/issue30376a
Browse files Browse the repository at this point in the history
HPCC-30376 Allow the open telemetry tracing to be configured

Reviewed-By: Rodrigo Pastrana <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Oct 5, 2023
2 parents 1dd6f81 + 42050e8 commit 5b3d394
Show file tree
Hide file tree
Showing 15 changed files with 136 additions and 12 deletions.
40 changes: 40 additions & 0 deletions helm/hpcc/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@
"logging": {
"$ref": "#/definitions/logging"
},
"tracing": {
"$ref": "#/definitions/tracing"
},
"logAccess": {
"$ref": "#/definitions/logAccess"
},
Expand Down Expand Up @@ -1093,6 +1096,16 @@
},
"additionalProperties": { "type": ["integer", "string", "boolean"] }
},
"tracing": {
"type": "object",
"properties": {
"alwaysCreateGlobalIds": {
"type": "boolean",
"description": "If true, allocate global ids to any requests that do not supply one"
}
},
"additionalProperties": { "type": ["integer", "string", "boolean"] }
},
"compileOption": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1243,6 +1256,9 @@
"logging": {
"$ref": "#/definitions/logging"
},
"tracing": {
"$ref": "#/definitions/tracing"
},
"auth": {
"$ref": "#/definitions/auth"
},
Expand Down Expand Up @@ -1323,6 +1339,9 @@
"logging": {
"$ref": "#/definitions/logging"
},
"tracing": {
"$ref": "#/definitions/tracing"
},
"annotations": {
"type": "object",
"additionalProperties": { "type": "string" }
Expand Down Expand Up @@ -1379,6 +1398,9 @@
"logging": {
"$ref": "#/definitions/logging"
},
"tracing": {
"$ref": "#/definitions/tracing"
},
"annotations": {
"type": "object",
"additionalProperties": { "type": "string" }
Expand Down Expand Up @@ -1413,6 +1435,9 @@
"logging": {
"$ref": "#/definitions/logging"
},
"tracing": {
"$ref": "#/definitions/tracing"
},
"resources": {
"$ref": "#/definitions/resources"
},
Expand Down Expand Up @@ -1500,6 +1525,9 @@
"logging": {
"$ref": "#/definitions/logging"
},
"tracing": {
"$ref": "#/definitions/tracing"
},
"dataPlane": {
"description": "The default storage plane to write data files to",
"type": "string"
Expand Down Expand Up @@ -1585,6 +1613,9 @@
"logging": {
"$ref": "#/definitions/logging"
},
"tracing": {
"$ref": "#/definitions/tracing"
},
"preload": {
"description": "Preloaded plugins",
"type": "array",
Expand Down Expand Up @@ -2275,6 +2306,9 @@
"logging": {
"$ref": "#/definitions/logging"
},
"tracing": {
"$ref": "#/definitions/tracing"
},
"annotations": {
"type": "object",
"additionalProperties": { "type": "string" }
Expand Down Expand Up @@ -2428,6 +2462,9 @@
"logging": {
"$ref": "#/definitions/logging"
},
"tracing": {
"$ref": "#/definitions/tracing"
},
"dataPlane": {
"description": "The default storage plane to write data files to",
"type": "string"
Expand Down Expand Up @@ -2805,6 +2842,9 @@
"logging": {
"$ref": "#/definitions/logging"
},
"tracing": {
"$ref": "#/definitions/tracing"
},
"resources": {
"$ref": "#/definitions/resources"
},
Expand Down
8 changes: 8 additions & 0 deletions initfiles/componentfiles/configxml/RoxieTopology.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@
</xsl:attribute>
<xsl:copy-of select="/Environment/Software/vaults"/>
<xsl:copy-of select="/Environment/Software/Directories"/>
<xsl:choose>
<xsl:when test="tracing">
<xsl:copy-of select="./tracing"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="/Environment/Software/tracing"/>
</xsl:otherwise>
</xsl:choose>
<!--
# Generated for configuration info. accessed by getGlobalConfig()
-->
Expand Down
8 changes: 8 additions & 0 deletions initfiles/componentfiles/configxml/agentexec.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@
<xsl:copy-of select="analyzerOptions"/>
<xsl:copy-of select="/Environment/Software/vaults"/>
<xsl:copy-of select="/Environment/Software/Directories"/>
<xsl:choose>
<xsl:when test="tracing">
<xsl:copy-of select="./tracing"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="/Environment/Software/tracing"/>
</xsl:otherwise>
</xsl:choose>
<!--
# Generated for configuration info. accessed by getGlobalConfig()
-->
Expand Down
8 changes: 8 additions & 0 deletions initfiles/componentfiles/configxml/dali.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@
</xsl:attribute>
</xsl:if>
<xsl:copy-of select="/Environment/Software/Directories"/>
<xsl:choose>
<xsl:when test="tracing">
<xsl:copy-of select="./tracing"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="/Environment/Software/tracing"/>
</xsl:otherwise>
</xsl:choose>
<!--
# Generated for configuration info. accessed by getGlobalConfig()
-->
Expand Down
8 changes: 8 additions & 0 deletions initfiles/componentfiles/configxml/dfuserver.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@
</xsl:attribute>

<xsl:copy-of select="/Environment/Software/Directories"/>
<xsl:choose>
<xsl:when test="tracing">
<xsl:copy-of select="./tracing"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="/Environment/Software/tracing"/>
</xsl:otherwise>
</xsl:choose>

<!--
# Generated for configuration info. accessed by getGlobalConfig()
Expand Down
8 changes: 8 additions & 0 deletions initfiles/componentfiles/configxml/eclccserver.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@

<xsl:copy-of select="/Environment/Software/vaults"/>

<xsl:choose>
<xsl:when test="tracing">
<xsl:copy-of select="./tracing"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="/Environment/Software/tracing"/>
</xsl:otherwise>
</xsl:choose>
<!--
# Generated for configuration info. accessed by getGlobalConfig()
-->
Expand Down
8 changes: 8 additions & 0 deletions initfiles/componentfiles/configxml/eclscheduler.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@
<EclSchedulerProcess>
<xsl:apply-templates select="@*[string(.) != '']"/>
<xsl:copy-of select="/Environment/Software/Directories"/>
<xsl:choose>
<xsl:when test="tracing">
<xsl:copy-of select="./tracing"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="/Environment/Software/tracing"/>
</xsl:otherwise>
</xsl:choose>
<!--
# Generated for configuration info. accessed by getGlobalConfig()
-->
Expand Down
8 changes: 8 additions & 0 deletions initfiles/componentfiles/configxml/esp.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@
<!--
# Generated for configuration info. accessed by getGlobalConfig()
-->
<xsl:choose>
<xsl:when test="tracing">
<xsl:copy-of select="./tracing"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="/Environment/Software/tracing"/>
</xsl:otherwise>
</xsl:choose>
<global>
<expert>
<xsl:copy-of select="/Environment/Software/Globals/@* | /Environment/Software/Globals/*"/>
Expand Down
8 changes: 8 additions & 0 deletions initfiles/componentfiles/configxml/sasha.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@
</xsl:attribute>

<xsl:copy-of select="/Environment/Software/Directories"/>
<xsl:choose>
<xsl:when test="tracing">
<xsl:copy-of select="./tracing"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="/Environment/Software/tracing"/>
</xsl:otherwise>
</xsl:choose>

<!--
# Generated for configuration info. accessed by getGlobalConfig()
Expand Down
8 changes: 8 additions & 0 deletions initfiles/componentfiles/configxml/thor.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@

<xsl:copy-of select="/Environment/Software/vaults"/>
<xsl:copy-of select="/Environment/Software/Directories"/>
<xsl:choose>
<xsl:when test="tracing">
<xsl:copy-of select="./tracing"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="/Environment/Software/tracing"/>
</xsl:otherwise>
</xsl:choose>
<!--
# Generated for configuration info. accessed by getGlobalConfig()
-->
Expand Down
8 changes: 8 additions & 0 deletions initfiles/componentfiles/configxml/toposerver.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@
<TopoServerProcess>
<xsl:apply-templates select="@*[string(.) != '']"/>
<xsl:copy-of select="/Environment/Software/Directories"/>
<xsl:choose>
<xsl:when test="tracing">
<xsl:copy-of select="./tracing"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="/Environment/Software/tracing"/>
</xsl:otherwise>
</xsl:choose>
<!--
# Generated for configuration info. accessed by getGlobalConfig()
-->
Expand Down
2 changes: 1 addition & 1 deletion system/jlib/jptree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9067,7 +9067,7 @@ jlib_decl IPropertyTree * loadConfiguration(IPropertyTree *componentDefault, con
if (monitor)
configFileUpdater->startMonitoring();

initTraceManager(componentTag, componentConfiguration.get());
initTraceManager(componentTag, componentConfiguration.get(), globalConfiguration.get());
return componentConfiguration.getLink();
}

Expand Down
16 changes: 10 additions & 6 deletions system/jlib/jtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ class CTraceManager : implements ITraceManager, public CInterface
//and an exporter which is responsible for exporting the processed spans.
//By default, an InMemorySpan exporter is used in the absence of a proper noop exporter.
//Also, a SimpleSpanProcessor is used in the absence of a configuration directive to process spans in batches
void initTracerProviderAndGlobalInternals(IPropertyTree * traceConfig)
void initTracerProviderAndGlobalInternals(const IPropertyTree * traceConfig)
{
//Currently using InMemorySpanExporter as default, until a noop exporter is available
std::shared_ptr<opentelemetry::exporter::memory::InMemorySpanData> data;
Expand Down Expand Up @@ -767,13 +767,13 @@ class CTraceManager : implements ITraceManager, public CInterface
processor: #optional - Controls span processing style
type: batch #simple|batch (default: simple)
*/
void initTracer(IPropertyTree * traceConfig)
void initTracer(const IPropertyTree * traceConfig)
{
try
{
#ifdef TRACECONFIGDEBUG
Owned<IPropertyTree> testTree;
if (!traceConfig || !traceConfig->hasProp("tracing"))
if (!traceConfig)
{
const char * simulatedGlobalYaml = R"!!(global:
tracing:
Expand Down Expand Up @@ -842,9 +842,13 @@ class CTraceManager : implements ITraceManager, public CInterface

public:
IMPLEMENT_IINTERFACE;
CTraceManager(const char * componentName, IPropertyTree * traceConfig)
CTraceManager(const char * componentName, const IPropertyTree * componentConfig, const IPropertyTree * globalConfig)
{
assertex(componentConfig);
moduleName.set(componentName);
const IPropertyTree * traceConfig = componentConfig->queryPropTree("tracing");
if (!traceConfig && globalConfig)
traceConfig = globalConfig->queryPropTree("tracing");
initTracer(traceConfig);

auto provider = opentelemetry::trace::Provider::GetTracerProvider();
Expand Down Expand Up @@ -895,9 +899,9 @@ MODULE_EXIT()
theTraceManager.destroy();
}

void initTraceManager(const char * componentName, IPropertyTree * config)
void initTraceManager(const char * componentName, const IPropertyTree * componentConfig, const IPropertyTree * globalConfig)
{
theTraceManager.query([=] () { return new CTraceManager(componentName, config); });
theTraceManager.query([=] () { return new CTraceManager(componentName, componentConfig, globalConfig); });
}

ITraceManager & queryTraceManager()
Expand Down
2 changes: 1 addition & 1 deletion system/jlib/jtrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ interface ITraceManager : extends IInterface
virtual const char * getTracedComponentName() const = 0;
};

extern jlib_decl void initTraceManager(const char * componentName, IPropertyTree * traceConfig);
extern jlib_decl void initTraceManager(const char * componentName, const IPropertyTree * componentConfig, const IPropertyTree * globalConfig);
extern jlib_decl ITraceManager & queryTraceManager();

/*
Expand Down
8 changes: 4 additions & 4 deletions testing/unittests/jlibtests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ class JlibTraceTest : public CppUnit::TestFixture
void testTraceDisableConfig()
{
Owned<IPropertyTree> testTree = createPTreeFromYAMLString(disableTracingYaml, ipt_none, ptr_ignoreWhiteSpace, nullptr);
Owned<IPropertyTree> traceConfig = testTree->getPropTree("global/tracing");
Owned<IPropertyTree> traceConfig = testTree->getPropTree("global");

//Not valid, due to tracemanager initialized at component load time
initTraceManager("somecomponent", traceConfig);
initTraceManager("somecomponent", traceConfig, nullptr);
}

void testIDPropegation()
Expand Down Expand Up @@ -148,9 +148,9 @@ class JlibTraceTest : public CppUnit::TestFixture
void testTraceConfig()
{
Owned<IPropertyTree> testTree = createPTreeFromYAMLString(simulatedGlobalYaml, ipt_none, ptr_ignoreWhiteSpace, nullptr);
Owned<IPropertyTree> traceConfig = testTree->getPropTree("global/tracing");
Owned<IPropertyTree> traceConfig = testTree->getPropTree("global");

initTraceManager("somecomponent", traceConfig);
initTraceManager("somecomponent", traceConfig, nullptr);
}

void testClientSpan()
Expand Down

0 comments on commit 5b3d394

Please sign in to comment.