Skip to content

Commit 8651e16

Browse files
committed
docs: custom metrics exporters for otel metrics
1 parent 59b6eb9 commit 8651e16

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

docs/config/config-file.mdx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,13 @@ Some ones we recommend:
154154

155155
### Telemetry Exporters
156156

157-
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:
157+
You can also configure custom telemetry exporters to send your traces, logs, and metrics 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:
158158

159159
```json package.json
160160
"dependencies": {
161161
"@opentelemetry/exporter-logs-otlp-http": "0.52.1",
162-
"@opentelemetry/exporter-trace-otlp-http": "0.52.1"
162+
"@opentelemetry/exporter-trace-otlp-http": "0.52.1",
163+
"@opentelemetry/exporter-metrics-otlp-http": "0.52.1"
163164
}
164165
```
165166

@@ -169,6 +170,7 @@ Then, configure the exporters in your `trigger.config.ts` file:
169170
import { defineConfig } from "@trigger.dev/sdk";
170171
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
171172
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
173+
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
172174

173175
// Initialize OTLP trace exporter with the endpoint URL and headers;
174176
export default defineConfig({
@@ -196,18 +198,28 @@ export default defineConfig({
196198
},
197199
}),
198200
],
201+
metricExporters: [
202+
new OTLPMetricExporter({
203+
url: "https://api.axiom.co/v1/metrics",
204+
headers: {
205+
Authorization: `Bearer ${process.env.AXIOM_API_TOKEN}`,
206+
"X-Axiom-Dataset": process.env.AXIOM_DATASET,
207+
},
208+
}),
209+
],
199210
},
200211
});
201212
```
202213

203214
Make sure to set the `AXIOM_API_TOKEN` and `AXIOM_DATASET` environment variables in your project.
204215

205-
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:
216+
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`, `OTLPLogExporter`, and `OTLPMetricExporter` constructors. For example, here is how you can configure exporting to Honeycomb:
206217

207218
```ts trigger.config.ts
208219
import { defineConfig } from "@trigger.dev/sdk";
209220
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
210221
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
222+
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
211223

212224
// Initialize OTLP trace exporter with the endpoint URL and headers;
213225
export default defineConfig({
@@ -235,10 +247,21 @@ export default defineConfig({
235247
},
236248
}),
237249
],
250+
metricExporters: [
251+
new OTLPMetricExporter({
252+
url: "https://api.honeycomb.io/v1/metrics",
253+
headers: {
254+
"x-honeycomb-team": process.env.HONEYCOMB_API_KEY,
255+
"x-honeycomb-dataset": process.env.HONEYCOMB_DATASET,
256+
},
257+
}),
258+
],
238259
},
239260
});
240261
```
241262

263+
Each metric exporter is automatically wrapped in a `PeriodicExportingMetricReader`. If you need more control over the reader configuration (e.g., custom export intervals), use `metricReaders` instead.
264+
242265
## Runtime
243266

244267
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)