***

title: "GetSdkConfiguration"
generated: true
---------------

## getSdkConfiguration

<GenerationInfo sourceFile="packages/telemetry-plugin/src/instrumentation.ts" sourceLine="140" packageName="@vendure/telemetry-plugin" />

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.

The default `instrumentations` array covers the libraries Vendure itself uses: HTTP, Express,
NestJS, GraphQL, the PostgreSQL and MySQL2 database drivers, ioredis, plus Node.js runtime
metrics (event-loop lag, GC pause, heap, CPU). SQLite (`better-sqlite3`) has no OpenTelemetry
instrumentation available upstream and is therefore not covered. To capture spans from other
libraries used in your own plugins (for example `kafkajs`, `mongoose`, `winston`), install the
specific `@opentelemetry/instrumentation-*` package you need and extend the defaults via
`getDefaultInstrumentations()`:

```ts
import { getDefaultInstrumentations, getSdkConfiguration } from '@vendure/telemetry-plugin/preload';
import { KafkaJsInstrumentation } from '@opentelemetry/instrumentation-kafkajs';

const config = getSdkConfiguration({
    config: {
        instrumentations: [...getDefaultInstrumentations(), new KafkaJsInstrumentation()],
    },
});
```

Passing your own `instrumentations` via `config.instrumentations` replaces the curated default
entirely.

*Example*

```ts
// instrumentation.ts
import { 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
```

```ts title="Signature"
function getSdkConfiguration(options?: SdkConfigurationOptions): Partial<NodeSDKConfiguration>
```

Parameters

### options

\<MemberInfo kind="parameter" type={`<a href='/current/core/reference/core-plugins/telemetry-plugin/get-sdk-configuration#sdkconfigurationoptions'>SdkConfigurationOptions</a>`} />

## getDefaultInstrumentations

<GenerationInfo sourceFile="packages/telemetry-plugin/src/instrumentation.ts" sourceLine="36" packageName="@vendure/telemetry-plugin" />

Returns a fresh array of the OpenTelemetry instrumentations Vendure enables by default. Callers
can spread this into their own `instrumentations` array to add extra integrations without
losing the curated set.

```ts title="Signature"
function getDefaultInstrumentations(): NonNullable<NodeSDKConfiguration['instrumentations']>
```

## SdkConfigurationOptions

<GenerationInfo sourceFile="packages/telemetry-plugin/src/instrumentation.ts" sourceLine="56" packageName="@vendure/telemetry-plugin" />

Options for configuring the OpenTelemetry Node SDK.

```ts title="Signature"
interface SdkConfigurationOptions {
    logToConsole?: boolean;
    config: Partial<NodeSDKConfiguration>;
}
```

<div className="members-wrapper">

### logToConsole

\<MemberInfo kind="property" type={`boolean`} 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

\<MemberInfo kind="property" type={`Partial<NodeSDKConfiguration>`}   />

The configuration object for the OpenTelemetry Node SDK.

</div>
