Skip to content

Commit

Permalink
HPCC-32131 Jtrace exporters batch config support
Browse files Browse the repository at this point in the history
- Enables span batch export mode by default
- Exposes batch configuration options
- Updates sample otel export values files to include batch config
- Updates helm schema to expose batch confi

Signed-off-by: Rodrigo Pastrana <[email protected]>
  • Loading branch information
rpastrana committed Jun 25, 2024
1 parent ee7c3bf commit d474e06
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 14 deletions.
5 changes: 5 additions & 0 deletions helm/examples/tracing/otlp-grpc-collector-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ global:
- type: OTLP-GRPC
endpoint: "localhost:4317"
useSslCredentials: false
batch:
enabled: true
maxQueueSize: 4096
scheduledDelayMillis: 6000
maxExportBatchSize: 512
5 changes: 5 additions & 0 deletions helm/examples/tracing/otlp-grpc-collector-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ global:
- type: OTLP-GRPC
endpoint: "http://myotelcollector-opentelemetry-collector.default.svc.cluster.local:4317"
useSslCredentials: false
batch:
enabled: true
maxQueueSize: 4096
scheduledDelayMillis: 6000
maxExportBatchSize: 512
7 changes: 6 additions & 1 deletion helm/examples/tracing/otlp-http-collector-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ global:
exporters:
- type: OTLP-HTTP
endpoint: "localhost:4318/v1/traces"
consoleDebug: true
consoleDebug: true
batch:
enabled: true
maxQueueSize: 4096
scheduledDelayMillis: 6000
maxExportBatchSize: 512
5 changes: 5 additions & 0 deletions helm/examples/tracing/otlp-http-collector-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ global:
- type: OTLP-HTTP
endpoint: "http://myotelcollector-opentelemetry-collector.default.svc.cluster.local:4318/v1/traces"
consoleDebug: true
batch:
enabled: true
maxQueueSize: 4096
scheduledDelayMillis: 6000
maxExportBatchSize: 512
12 changes: 12 additions & 0 deletions helm/hpcc/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,18 @@
"enabled": {
"type": "boolean",
"description": "If true, trace data is processed in a batch, if false, trace data is processed immediately"
},
"maxQueueSize": {
"type": "number",
"description": "The maximum buffer/queue size. After the size is reached, spans are dropped."
},
"scheduledDelayMillis": {
"type": "number",
"description": "The time interval between two consecutive exports."
},
"maxExportBatchSize": {
"type": "number",
"description": " The maximum batch size of every export. It must be smaller or equal to max_queue_size."
}
},
"additionalProperties": { "type": ["integer", "string", "boolean"] }
Expand Down
36 changes: 23 additions & 13 deletions system/jlib/jtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1285,16 +1285,26 @@ std::unique_ptr<opentelemetry::sdk::trace::SpanProcessor> CTraceManager::createP
if (!exporter)
return nullptr;

if (exportConfig->getPropBool("batch/@enabled", false))
if (exportConfig->getPropBool("batch/@enabled", true))
{
//Groups several spans together, before sending them to an exporter.
//MORE: These options should be configurable from batch/@option
opentelemetry::v1::sdk::trace::BatchSpanProcessorOptions options; //size_t max_queue_size = 2048;
//The time interval between two consecutive exports
//std::chrono::milliseconds(5000);
//The maximum batch size of every export. It must be smaller or
//equal to max_queue_size.
//size_t max_export_batch_size = 512
opentelemetry::v1::sdk::trace::BatchSpanProcessorOptions options;
/**
* The maximum buffer/queue size. After the size is reached, spans are
* dropped.
*/
options.max_queue_size = exportConfig->getPropInt("batch/@maxQueueSize", 2048);

/* The time interval between two consecutive exports. */
options.schedule_delay_millis = std::chrono::milliseconds(exportConfig->getPropInt("batch/@scheduledDelayMillis", 5000));

/**
* The maximum batch size of every export. It must be smaller or
* equal to max_queue_size.
*/
options.max_export_batch_size = exportConfig->getPropInt("batch/@maxExportBatchSize", 512);

DBGLOG("Tracing exporter set to batch mode");
return opentelemetry::sdk::trace::BatchSpanProcessorFactory::Create(std::move(exporter), options);
}

Expand Down Expand Up @@ -1323,12 +1333,12 @@ void CTraceManager::initTracerProviderAndGlobalInternals(const IPropertyTree * t
enableDefaultLogExporter = traceConfig->getPropBool("enableDefaultLogExporter", enableDefaultLogExporter);
}

if (enableDefaultLogExporter)
{
//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);
processors.push_back(opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create(std::move(exporter)));
}
// std::unique_ptr<opentelemetry::sdk::trace::SpanExporter> exporter = JLogSpanExporterFactory::Create(DEFAULT_SPAN_LOG_FLAGS);
// processors.push_back(opentelemetry::sdk::trace::SimpleSpanProcessorFactory::Create(std::move(exporter)));
//}

opentelemetry::sdk::resource::ResourceAttributes resourceAtts =
{
Expand Down

0 comments on commit d474e06

Please sign in to comment.