Skip to content

Commit 2aee3de

Browse files
authored
Docs: 3rd party log exporters (#2058)
1 parent d1e4064 commit 2aee3de

File tree

1 file changed

+79
-18
lines changed

1 file changed

+79
-18
lines changed

docs/config/config-file.mdx

Lines changed: 79 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,47 +127,108 @@ There is a [huge library of instrumentations](https://opentelemetry.io/ecosystem
127127

128128
Some ones we recommend:
129129

130-
| Package | Description |
131-
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
132-
| `@opentelemetry/instrumentation-http` | Logs all HTTP calls |
133-
| `@prisma/instrumentation` | Logs all Prisma calls, you need to [enable tracing](https://github.com/prisma/prisma/tree/main/packages/instrumentation) |
134-
| `@traceloop/instrumentation-openai` | Logs all OpenAI calls |
130+
| Package | Description |
131+
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
132+
| `@opentelemetry/instrumentation-http` | Logs all HTTP calls |
133+
| `@prisma/instrumentation` | Logs all Prisma calls, you need to [enable tracing](https://github.com/prisma/prisma/tree/main/packages/instrumentation) |
134+
| `@traceloop/instrumentation-openai` | Logs all OpenAI calls |
135135

136136
<Note>
137137
`@opentelemetry/instrumentation-fs` which logs all file system calls is currently not supported.
138138
</Note>
139139

140-
### Exporters
140+
### Telemetry Exporters
141141

142-
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):
142+
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:
143+
144+
```json package.json
145+
"dependencies": {
146+
"@opentelemetry/exporter-logs-otlp-http": "0.52.1",
147+
"@opentelemetry/exporter-trace-otlp-http": "0.52.1"
148+
}
149+
```
150+
151+
Then, configure the exporters in your `trigger.config.ts` file:
143152

144153
```ts trigger.config.ts
145154
import { defineConfig } from "@trigger.dev/sdk/v3";
146-
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-proto';
147-
148-
// Initialize OTLP trace exporter with the endpoint URL and headers
149-
const axiomExporter = new OTLPTraceExporter({
150-
url: 'https://api.axiom.co/v1/traces',
151-
headers: {
152-
'Authorization': `Bearer ${process.env.AXIOM_API_TOKEN}`,
153-
'X-Axiom-Dataset': process.env.AXIOM_DATASET
154-
},
155-
});
155+
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
156+
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
156157

158+
// Initialize OTLP trace exporter with the endpoint URL and headers;
157159
export default defineConfig({
158160
project: "<project ref>",
159161
// Your other config settings...
160162
telemetry: {
161163
instrumentations: [
162164
// Your instrumentations here
163165
],
164-
exporters: [axiomExporter],
166+
logExporters: [
167+
new OTLPLogExporter({
168+
url: "https://api.axiom.co/v1/logs",
169+
headers: {
170+
Authorization: `Bearer ${process.env.AXIOM_API_TOKEN}`,
171+
"X-Axiom-Dataset": process.env.AXIOM_DATASET,
172+
},
173+
}),
174+
],
175+
exporters: [
176+
new OTLPTraceExporter({
177+
url: "https://api.axiom.co/v1/traces",
178+
headers: {
179+
Authorization: `Bearer ${process.env.AXIOM_API_TOKEN}`,
180+
"X-Axiom-Dataset": process.env.AXIOM_DATASET,
181+
},
182+
}),
183+
],
165184
},
166185
});
167186
```
168187

169188
Make sure to set the `AXIOM_API_TOKEN` and `AXIOM_DATASET` environment variables in your project.
170189

190+
<Note>
191+
The `logExporters` option is available in the v4 beta SDK. See our [v4 upgrade
192+
guide](/upgrade-to-v4) for more information.
193+
</Note>
194+
195+
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:
196+
197+
```ts trigger.config.ts
198+
import { defineConfig } from "@trigger.dev/sdk/v3";
199+
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
200+
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
201+
202+
// Initialize OTLP trace exporter with the endpoint URL and headers;
203+
export default defineConfig({
204+
project: "<project ref>",
205+
// Your other config settings...
206+
telemetry: {
207+
instrumentations: [
208+
// Your instrumentations here
209+
],
210+
logExporters: [
211+
new OTLPLogExporter({
212+
url: "https://api.honeycomb.io/v1/logs",
213+
headers: {
214+
"x-honeycomb-team": process.env.HONEYCOMB_API_KEY,
215+
"x-honeycomb-dataset": process.env.HONEYCOMB_DATASET,
216+
},
217+
}),
218+
],
219+
exporters: [
220+
new OTLPTraceExporter({
221+
url: "https://api.honeycomb.io/v1/traces",
222+
headers: {
223+
"x-honeycomb-team": process.env.HONEYCOMB_API_KEY,
224+
"x-honeycomb-dataset": process.env.HONEYCOMB_DATASET,
225+
},
226+
}),
227+
],
228+
},
229+
});
230+
```
231+
171232
## Runtime
172233

173234
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:

0 commit comments

Comments
 (0)