mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(instrumentation): open telemetry init (#1426)
This commit is contained in:
@@ -50,28 +50,12 @@ async function initializeOpenTelemetry() {
|
||||
const { NodeSDK } = await import('@opentelemetry/sdk-node')
|
||||
const { resourceFromAttributes } = await import('@opentelemetry/resources')
|
||||
const { SemanticResourceAttributes } = await import('@opentelemetry/semantic-conventions')
|
||||
const { BatchSpanProcessor } = await import('@opentelemetry/sdk-trace-node')
|
||||
const { OTLPTraceExporter } = await import('@opentelemetry/exporter-trace-otlp-http')
|
||||
|
||||
const exporter = new OTLPTraceExporter({
|
||||
url: telemetryConfig.endpoint,
|
||||
})
|
||||
|
||||
const spanProcessor = new BatchSpanProcessor(exporter, {
|
||||
maxQueueSize:
|
||||
telemetryConfig.batchSettings?.maxQueueSize ||
|
||||
DEFAULT_TELEMETRY_CONFIG.batchSettings.maxQueueSize,
|
||||
maxExportBatchSize:
|
||||
telemetryConfig.batchSettings?.maxExportBatchSize ||
|
||||
DEFAULT_TELEMETRY_CONFIG.batchSettings.maxExportBatchSize,
|
||||
scheduledDelayMillis:
|
||||
telemetryConfig.batchSettings?.scheduledDelayMillis ||
|
||||
DEFAULT_TELEMETRY_CONFIG.batchSettings.scheduledDelayMillis,
|
||||
exportTimeoutMillis:
|
||||
telemetryConfig.batchSettings?.exportTimeoutMillis ||
|
||||
DEFAULT_TELEMETRY_CONFIG.batchSettings.exportTimeoutMillis,
|
||||
})
|
||||
|
||||
const configResource = resourceFromAttributes({
|
||||
[SemanticResourceAttributes.SERVICE_NAME]: telemetryConfig.serviceName,
|
||||
[SemanticResourceAttributes.SERVICE_VERSION]: telemetryConfig.serviceVersion,
|
||||
@@ -80,7 +64,7 @@ async function initializeOpenTelemetry() {
|
||||
|
||||
const sdk = new NodeSDK({
|
||||
resource: configResource,
|
||||
spanProcessors: [spanProcessor],
|
||||
traceExporter: exporter,
|
||||
})
|
||||
|
||||
sdk.start()
|
||||
|
||||
Reference in New Issue
Block a user