diff --git a/docs/config/config-file.mdx b/docs/config/config-file.mdx index 0a8e3ba66a..62da85593e 100644 --- a/docs/config/config-file.mdx +++ b/docs/config/config-file.mdx @@ -127,33 +127,35 @@ There is a [huge library of instrumentations](https://opentelemetry.io/ecosystem Some ones we recommend: -| Package | Description | -| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | -| `@opentelemetry/instrumentation-http` | Logs all HTTP calls | -| `@prisma/instrumentation` | Logs all Prisma calls, you need to [enable tracing](https://github.com/prisma/prisma/tree/main/packages/instrumentation) | -| `@traceloop/instrumentation-openai` | Logs all OpenAI calls | +| Package | Description | +| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | +| `@opentelemetry/instrumentation-http` | Logs all HTTP calls | +| `@prisma/instrumentation` | Logs all Prisma calls, you need to [enable tracing](https://github.com/prisma/prisma/tree/main/packages/instrumentation) | +| `@traceloop/instrumentation-openai` | Logs all OpenAI calls | `@opentelemetry/instrumentation-fs` which logs all file system calls is currently not supported. -### Exporters +### Telemetry Exporters -You can also configure custom exporters to send your telemetry data to other services. For example, you can send your logs to [Axiom](https://axiom.co/docs/guides/opentelemetry-nodejs#exporter-instrumentation-ts): +You can also configure custom telemetry exporters to send your traces and logs to other external services. For example, you can send your logs to [Axiom](https://axiom.co/docs/guides/opentelemetry-nodejs#exporter-instrumentation-ts). First, add the opentelemetry exporter packages to your package.json file: + +```json package.json +"dependencies": { + "@opentelemetry/exporter-logs-otlp-http": "0.52.1", + "@opentelemetry/exporter-trace-otlp-http": "0.52.1" +} +``` + +Then, configure the exporters in your `trigger.config.ts` file: ```ts trigger.config.ts import { defineConfig } from "@trigger.dev/sdk/v3"; -import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto'; - -// Initialize OTLP trace exporter with the endpoint URL and headers -const axiomExporter = new OTLPTraceExporter({ - url: 'https://api.axiom.co/v1/traces', - headers: { - 'Authorization': `Bearer ${process.env.AXIOM_API_TOKEN}`, - 'X-Axiom-Dataset': process.env.AXIOM_DATASET - }, -}); +import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http"; +import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http"; +// Initialize OTLP trace exporter with the endpoint URL and headers; export default defineConfig({ project: "", // Your other config settings... @@ -161,13 +163,72 @@ export default defineConfig({ instrumentations: [ // Your instrumentations here ], - exporters: [axiomExporter], + logExporters: [ + new OTLPLogExporter({ + url: "https://api.axiom.co/v1/logs", + headers: { + Authorization: `Bearer ${process.env.AXIOM_API_TOKEN}`, + "X-Axiom-Dataset": process.env.AXIOM_DATASET, + }, + }), + ], + exporters: [ + new OTLPTraceExporter({ + url: "https://api.axiom.co/v1/traces", + headers: { + Authorization: `Bearer ${process.env.AXIOM_API_TOKEN}`, + "X-Axiom-Dataset": process.env.AXIOM_DATASET, + }, + }), + ], }, }); ``` Make sure to set the `AXIOM_API_TOKEN` and `AXIOM_DATASET` environment variables in your project. + + The `logExporters` option is available in the v4 beta SDK. See our [v4 upgrade + guide](/upgrade-to-v4) for more information. + + +It's important to note that you cannot configure exporters using `OTEL_*` environment variables, as they would conflict with our internal telemetry. Instead you should configure the exporters via passing in arguments to the `OTLPTraceExporter` and `OTLPLogExporter` constructors. For example, here is how you can configure exporting to Honeycomb: + +```ts trigger.config.ts +import { defineConfig } from "@trigger.dev/sdk/v3"; +import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http"; +import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http"; + +// Initialize OTLP trace exporter with the endpoint URL and headers; +export default defineConfig({ + project: "", + // Your other config settings... + telemetry: { + instrumentations: [ + // Your instrumentations here + ], + logExporters: [ + new OTLPLogExporter({ + url: "https://api.honeycomb.io/v1/logs", + headers: { + "x-honeycomb-team": process.env.HONEYCOMB_API_KEY, + "x-honeycomb-dataset": process.env.HONEYCOMB_DATASET, + }, + }), + ], + exporters: [ + new OTLPTraceExporter({ + url: "https://api.honeycomb.io/v1/traces", + headers: { + "x-honeycomb-team": process.env.HONEYCOMB_API_KEY, + "x-honeycomb-dataset": process.env.HONEYCOMB_DATASET, + }, + }), + ], + }, +}); +``` + ## Runtime We currently only officially support the `node` runtime, but you can try our experimental `bun` runtime by setting the `runtime` option in your config file: