opentelemetry-instrumentation-sapphire
v0.1.3
Published
Adds opentelemetry tracing instrumentation for the `@sapphire/framework` library. Enables and adds tracing across registered listeners.
Downloads
90
Maintainers
Readme
opentelemetry-instrumentation-sapphire
Adds opentelemetry tracing instrumentation for the @sapphire/framework library. Enables and adds tracing across registered listeners.
Additional instrumentation is work-in-progress.
Installation
Install with your favorite package manager
# npm
npm install opentelemetry-instrumentation-sapphire
# pnpm
pnpm add opentelemetry-instrumentation-sapphire
# yarn
yarn add opentelemetry-instrumentation-sapphire
Usage
You must register instrumentation using the OpenTelemetry Node SDK. As with other instrumentation libraries, you must initialize instrumentation as-soon-as-possible before @sapphire/framework is imported elsewhere by your app.
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { SapphireInstrumentation } from "opentelemetry-instrumentation-sapphire";
registerInstrumentations({
tracerProvider,
instrumentations: [
new SapphireInstrumentation({
// see below for configuration options
})
]
});If you are missing spans or do not see the instrumentation being loaded in OTEL debug logs, try the following:
- Preload your telemetry code separately by launching
nodewith--require telemetry.cjs/--import telemetry.mjs. This guarantees the import script will finish completely before your app launches. - Convert your app to CommonJS. Native ESM import hooks are still unreliable.
If you want, you can read more about the above issues or look at this thread.
Config
Additional configuration is still WIP.
