Skip to main content

TelemetryPluginOptions

TelemetryPluginOptions

Configuration options for the TelemetryPlugin.

Signature
interface TelemetryPluginOptions {
loggerOptions?: OtelLoggerOptions;
methodHooks?: Array<MethodHookConfig<any>>;
}

loggerOptions

The options for the OtelLogger.

For example, to also include logging to the console, you can use the following:

import { LogLevel } from '@vendure/core';
import { TelemetryPlugin } from '@vendure/telemetry-plugin';

TelemetryPlugin.init({
loggerOptions: {
console: LogLevel.Verbose,
},
});

methodHooks

property
experimental
Array<MethodHookConfig<any>>

Status: Developer Preview

This API may change in a future release.

Method hooks allow you to add extra telemetry actions to specific methods. To define hooks on a method, use the registerMethodHooks function.

Example

import { TelemetryPlugin, registerMethodHooks } from '@vendure/telemetry-plugin';

TelemetryPlugin.init({
methodHooks: [
registerMethodHooks(ProductService, {

// Define some hooks for the `findOne` method
findOne: {
// This will be called before the method is executed
pre: ({ args: [ctx, productId], span }) => {
span.setAttribute('productId', productId);
},
// This will be called after the method is executed
post: ({ result, span }) => {
span.setAttribute('found', !!result);
},
},
}),
],
});