File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ export default [
185185 'src/languages/**/*.{ts,js}' ,
186186 'src/links/**/*.{ts,js}' ,
187187 'src/metrics/**/*.{ts,js}' ,
188- 'src/observability/**/*.{ts,js} ' ,
188+ 'src/observability/lib/handle-package-not-found.ts ' ,
189189 'src/rest/**/*.{ts,js}' ,
190190 'src/search/**/*.{ts,js}' ,
191191 'src/shielding/**/*.{ts,js}' ,
Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ import { ExpressInstrumentation } from '@opentelemetry/instrumentation-express'
2626import { HttpInstrumentation } from '@opentelemetry/instrumentation-http'
2727import { UndiciInstrumentation } from '@opentelemetry/instrumentation-undici'
2828import { NodeSDK } from '@opentelemetry/sdk-node'
29+ import { createLogger } from '@/observability/logger'
30+ import { toError } from '@/observability/lib/to-error'
31+
32+ const logger = createLogger ( import . meta. url )
2933
3034if ( process . env . OTEL_EXPORTER_OTLP_TRACES_ENDPOINT ) {
3135 const sdk = new NodeSDK ( {
@@ -44,7 +48,9 @@ if (process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT) {
4448 try {
4549 sdk . start ( )
4650 } catch ( error ) {
47- console . error ( '[tracing] failed to start:' , error instanceof Error ? error . message : error )
51+ logger . error ( '[tracing] failed to start' , {
52+ error : toError ( error ) ,
53+ } )
4854 }
4955
5056 // Gracefully shut down the SDK on process exit.
@@ -54,7 +60,7 @@ if (process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT) {
5460 await sdk . shutdown ( )
5561 } catch ( error ) {
5662 if ( error instanceof Error ) {
57- console . error ( ` [tracing] shutdown error: ${ error . message } ` )
63+ logger . error ( ' [tracing] shutdown error' , { error } )
5864 }
5965 }
6066 } )
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { minimumNotFoundHtml } from '@/frame/lib/constants'
66import { setFastlySurrogateKey , SURROGATE_ENUMS } from '@/frame/middleware/set-fastly-surrogate-key'
77import { errorCacheControl } from '@/frame/middleware/cache-control'
88import statsd from '@/observability/lib/statsd'
9+ import { toError } from '@/observability/lib/to-error'
910import { ExtendedRequest } from '@/types'
1011import { createLogger } from '@/observability/logger'
1112
@@ -86,7 +87,7 @@ async function handleError(
8687 setFastlySurrogateKey ( res , SURROGATE_ENUMS . DEFAULT )
8788 }
8889 } else if ( DEBUG_MIDDLEWARE_TESTS ) {
89- console . warn ( 'An error occurred in some middleware handler' , error )
90+ logger . warn ( 'An error occurred in some middleware handler' , { error } )
9091 }
9192
9293 try {
@@ -147,7 +148,9 @@ async function handleError(
147148 await logException ( error , req )
148149 }
149150 } catch ( handlingError ) {
150- console . error ( 'An error occurred in the error handling middleware!' , handlingError )
151+ logger . error ( 'An error occurred in the error handling middleware' , {
152+ error : toError ( handlingError ) ,
153+ } )
151154 next ( handlingError )
152155 return
153156 }
You can’t perform that action at this time.
0 commit comments