@nestjs-yalc/observability
v1.3.4
Published
Observability utilities and OpenTelemetry integration for nestjs-yalc
Readme
@nestjs-yalc/observability
OpenTelemetry integration for YALC applications.
The package adds opt-in telemetry around EventManager events and selected call
or event strategies. It can export logs, metrics, span events, and exceptions
through OTLP while keeping YalcEventService as the source of structured
application events.
Installation
npm install @nestjs-yalc/observabilityInstall and run an OpenTelemetry-compatible backend, such as an OTLP collector or Grafana LGTM stack, when you want exported telemetry.
Module
import {
ObservabilityModule,
createObservabilityOptionsFromEnv,
} from '@nestjs-yalc/observability';
@Module({
imports: [
ObservabilityModule.forRoot(() =>
createObservabilityOptionsFromEnv('task-system-app'),
),
],
})
export class AppModule {}Runtime Helpers
TelemetryService.measurerecords workflow duration.TelemetryCallStrategyobserves an existing call strategy without changing the caller contract.TelemetryEventStrategyobserves an existing event strategy.OpenTelemetryEventManagerPluginsubscribes to EventManager events.
Environment
YALC_OBSERVABILITY_ENABLED=trueenables the plugin.YALC_OTEL_SERVICE_NAMEoverrides the OpenTelemetry service name.YALC_OTEL_ENDPOINTdefaults tohttp://127.0.0.1:4318.YALC_OBSERVABILITY_EVENT_LISTEN_TOdefaults to**.YALC_OBSERVABILITY_EVENT_IGNOREdefaults toobservability.**.YALC_OBSERVABILITY_INCLUDE_EVENT_PAYLOAD=trueexports masked event payloads.YALC_OBSERVABILITY_FAILURE_MODE=throwmakes telemetry failures visible.
Payloads are not exported by default. When enabled, payloads are JSON encoded, truncated, and masked for common secret keys.
Documentation
- Observability guide: https://github.com/NestDevLab/nestjs-yalc/blob/dev/docs/observability.md
- Task app observability example: https://github.com/NestDevLab/nestjs-yalc/blob/dev/examples/task/app/README.md
