Skip to main content

GetSdkConfiguration

Creates a configuration object for the OpenTelemetry Node SDK. This is used to set up a custom preload script which must be run before the main Vendure server is loaded by means of the Node.js --require flag.

Example

Ts
// instrumentation.tsimport { OTLPLogExporter } from '@opentelemetry/exporter-logs-otlp-proto';import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';import { BatchLogRecordProcessor } from '@opentelemetry/sdk-logs';import { NodeSDK } from '@opentelemetry/sdk-node';import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';import { getSdkConfiguration } from '@vendure/telemetry-plugin/preload';process.env.OTEL_EXPORTER_OTLP_ENDPOINT = 'http://localhost:3100/otlp';process.env.OTEL_LOGS_EXPORTER = 'otlp';process.env.OTEL_RESOURCE_ATTRIBUTES = 'service.name=vendure-dev-server';const traceExporter = new OTLPTraceExporter({    url: 'http://localhost:4318/v1/traces',});const logExporter = new OTLPLogExporter();const config = getSdkConfiguration({    config: {        spanProcessors: [new BatchSpanProcessor(traceExporter)],        logRecordProcessors: [new BatchLogRecordProcessor(logExporter)],    },});const sdk = new NodeSDK(config);sdk.start();

This would them be run as:

Bash
node --require ./dist/instrumentation.js ./dist/server.js
Signature
function getSdkConfiguration(options?: SdkConfigurationOptions): Partial<NodeSDKConfiguration>

Parameters

options

Options for configuring the OpenTelemetry Node SDK.

Signature
interface SdkConfigurationOptions {    logToConsole?: boolean;    config: Partial<NodeSDKConfiguration>;}

logToConsole

propertyboolean
Default:false

When set to true, the SDK will log spans to the console instead of sending them to an exporter. This should just be used for debugging purposes.

config

propertyPartial<NodeSDKConfiguration>

The configuration object for the OpenTelemetry Node SDK.

Was this chapter helpful?
Report Issue
Edited Feb 2, 2026·Edit this page