cap-js / telemetry

CDS plugin providing observability features, incl. automatic OpenTelemetry instrumentation.
https://cap.cloud.sap/docs
Apache License 2.0
8 stars 6 forks source link

unhandledRejection: Cannot read properties of undefined when parentSpan is null #193

Closed sebastien-savalle closed 1 month ago

sebastien-savalle commented 2 months ago

Hi,

I'm getting an error when running the telemetry plugin together with 'cap-js/db-service'. The method _getParentSpan can return undefined (for example when the cds context is not set). In that case an unhandledRejection will be thrown due to:

TypeError: Cannot read properties of undefined (reading 'attributes')
at trace (/node_modules/@cap-js/telemetry/lib/tracing/trace.js:198:18)
at HANAService.prepare (/node_modules/@cap-js/telemetry/lib/tracing/cds.js:71:24)
at HANAService.onSIMPLE (/node_modules/@cap-js/hana/lib/HANAService.js:1137:27)
at HANAService.deep_delete [as onDELETE] (/node_modules/@cap-js/db-service/lib/SQLService.js:248:19)

Could you please have a look ?

Thanks, Sebastien

sjvans commented 1 month ago

hi @sebastien-savalle

thanks for reporting. should be solved by https://github.com/cap-js/telemetry/pull/195. please reopen if the issue persists in v1.0.0 (to be published).

thanks, sebastian