11import { DiagLogLevel } from '@opentelemetry/api'
2+ import { InstrumentationConfigMap } from '@opentelemetry/auto-instrumentations-node'
23import { MetricReader } from '@opentelemetry/sdk-metrics'
34import { IdGenerator , SpanProcessor } from '@opentelemetry/sdk-trace-base'
45import * as logfireApi from '@pydantic/logfire-api'
@@ -68,6 +69,10 @@ export interface LogfireConfigOptions {
6869 * Set to False to disable sending all metrics, or provide a MetricsOptions object to configure metrics, e.g. additional metric readers.
6970 */
7071 metrics ?: false | MetricsOptions
72+ /**
73+ * The node auto instrumentations to use. See [Node Auto Instrumentations](https://opentelemetry.io/docs/languages/js/libraries/#registration) for more information.
74+ */
75+ nodeAutoInstrumentations ?: InstrumentationConfigMap
7176 /**
7277 * The otel scope to use for the logfire API. Defaults to 'logfire'.
7378 */
@@ -101,6 +106,13 @@ export interface LogfireConfigOptions {
101106const DEFAULT_OTEL_SCOPE = 'logfire'
102107const TRACE_ENDPOINT_PATH = 'v1/traces'
103108const METRIC_ENDPOINT_PATH = 'v1/metrics'
109+ const DEFAULT_AUTO_INSTRUMENTATION_CONFIG : InstrumentationConfigMap = {
110+ // https://opentelemetry.io/docs/languages/js/libraries/#registration
111+ // This particular instrumentation creates a lot of noise on startup
112+ '@opentelemetry/instrumentation-fs' : {
113+ enabled : false ,
114+ } ,
115+ }
104116
105117export interface LogfireConfig {
106118 additionalSpanProcessors : SpanProcessor [ ]
@@ -113,6 +125,7 @@ export interface LogfireConfig {
113125 idGenerator : IdGenerator
114126 metricExporterUrl : string
115127 metrics : false | MetricsOptions | undefined
128+ nodeAutoInstrumentations : InstrumentationConfigMap
116129 otelScope : string
117130 sendToLogfire : boolean
118131 serviceName : string | undefined
@@ -132,6 +145,7 @@ const DEFAULT_LOGFIRE_CONFIG: LogfireConfig = {
132145 idGenerator : new ULIDGenerator ( ) ,
133146 metricExporterUrl : '' ,
134147 metrics : undefined ,
148+ nodeAutoInstrumentations : DEFAULT_AUTO_INSTRUMENTATION_CONFIG ,
135149 otelScope : DEFAULT_OTEL_SCOPE ,
136150 sendToLogfire : false ,
137151 serviceName : process . env . LOGFIRE_SERVICE_NAME ,
@@ -168,6 +182,7 @@ export function configure(config: LogfireConfigOptions = {}) {
168182 idGenerator : cnf . advanced ?. idGenerator ?? new ULIDGenerator ( ) ,
169183 metricExporterUrl : `${ baseUrl } /${ METRIC_ENDPOINT_PATH } ` ,
170184 metrics : cnf . metrics ,
185+ nodeAutoInstrumentations : cnf . nodeAutoInstrumentations ?? DEFAULT_AUTO_INSTRUMENTATION_CONFIG ,
171186 sendToLogfire,
172187 serviceName : cnf . serviceName ?? env . LOGFIRE_SERVICE_NAME ,
173188 serviceVersion : cnf . serviceVersion ?? env . LOGFIRE_SERVICE_VERSION ,
0 commit comments