Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-32927 Add a debugging option to allow slow exporters to be tested #19258

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions system/jlib/jtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,14 @@ static const char * spanKindToString(opentelemetry::trace::SpanKind spanKind)
class JLogSpanExporter final : public opentelemetry::sdk::trace::SpanExporter
{
public:
JLogSpanExporter(SpanLogFlags spanLogFlags) : logFlags(spanLogFlags), shutDown(false) {}
JLogSpanExporter(SpanLogFlags spanLogFlags, const IPropertyTree * config) :
logFlags(spanLogFlags), shutDown(false)
{
if (config)
{
debugDelayMs = config->getPropInt("debug/@delayMs", 0); // An option to allow this exporter to model slow behaviour
}
}

/**
* @return Returns a unique pointer to an empty recordable object
Expand Down Expand Up @@ -255,6 +262,11 @@ class JLogSpanExporter final : public opentelemetry::sdk::trace::SpanExporter
LOG(MCmonitorEvent, "%s",out.str());
}
}
if (debugDelayMs)
{
LOG(MCdebugInfo, "Delaying for %dms after exporting %u items", debugDelayMs, (unsigned)recordables.size());
MilliSleep(debugDelayMs);
}
return opentelemetry::sdk::common::ExportResult::kSuccess;
}
catch (IException * e)
Expand Down Expand Up @@ -416,6 +428,7 @@ class JLogSpanExporter final : public opentelemetry::sdk::trace::SpanExporter
private:
SpanLogFlags logFlags = SpanLogFlags::LogNone;
std::atomic_bool shutDown;
unsigned debugDelayMs = 0;
};

/*#ifdef _USE_CPPUNIT
Expand All @@ -436,10 +449,10 @@ class JLogSpanExporterFactory
/**
* Create a JLogSpanExporter.
*/
static std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> Create(SpanLogFlags logFlags)
static std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> Create(SpanLogFlags logFlags, const IPropertyTree * config)
{
return std::unique_ptr<opentelemetry::sdk::trace::SpanExporter>(
new JLogSpanExporter(logFlags));
new JLogSpanExporter(logFlags, config));
}
};

Expand Down Expand Up @@ -1280,9 +1293,10 @@ std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> CTraceManager::createEx
if (logFlags == SpanLogFlags::LogNone)
logFlags = DEFAULT_SPAN_LOG_FLAGS;


shouldBatch = false;
LOG(MCoperatorInfo, "Tracing exporter set to JLog: logFlags( LogAttributes LogParentInfo %s)", logFlagsStr.str());
return JLogSpanExporterFactory::Create(logFlags);
return JLogSpanExporterFactory::Create(logFlags, exportConfig);
}
else
LOG(MCoperatorWarning, "Tracing exporter type not supported: '%s'", exportType.str());
Expand Down Expand Up @@ -1362,7 +1376,7 @@ void CTraceManager::initTracerProviderAndGlobalInternals(const IPropertyTree * t
if (enableDefaultLogExporter)
{
//Simple option to create logging to the log file - primarily to aid developers.
std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> exporter = JLogSpanExporterFactory::Create(DEFAULT_SPAN_LOG_FLAGS);
std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> exporter = JLogSpanExporterFactory::Create(DEFAULT_SPAN_LOG_FLAGS, nullptr);
processors.push_back(opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create(std::move(exporter)));
}

Expand Down
Loading