Skip to content
Merged
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
20 changes: 11 additions & 9 deletions src/internal/monitoring/otel-tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,22 @@ if (tracingEnabled && endpoint) {
})
}

// Create a BatchSpanProcessor using the trace exporter
const batchProcessor = traceExporter ? new BatchSpanProcessor(traceExporter) : undefined

const spanProcessors: SpanProcessor[] = []

if (tracingEnabled) {
if (tracingEnabled && traceExporter) {
spanProcessors.push(new TenantSpanProcessor())
spanProcessors.push(new BatchSpanProcessor(traceExporter))
} else if (tracingEnabled) {
logSchema.warning(
logger,
'[Otel] TRACING_ENABLED=true but no OTLP trace endpoint configured; skipping tracing SDK startup',
{
type: 'otel',
}
)
}

if (batchProcessor) {
spanProcessors.push(batchProcessor)
}

if (tracingEnabled && spanProcessors.length > 0) {
if (tracingEnabled && traceExporter && spanProcessors.length > 0) {
// Configure the OpenTelemetry Node SDK
const sdk = new NodeSDK({
resource: resourceFromAttributes({
Expand Down