BSB Node.js Type Definitions
    Preparing search index...

    Class SBObservable

    BSB Observable Controller - Unified logging, metrics, and tracing

    This class is responsible for managing all observability in the BSB framework. It coordinates observable plugins (like OpenTelemetry, Prometheus, etc.) and routes events from the Observable API to the configured backends.

    If you have a specific way of managing observability, you can extend this class and use your own class when creating the ServiceBase instance.

    // Custom observable controller
    class MyObservable extends SBObservable {
    // Override methods as needed
    }

    // Use custom controller
    const serviceBase = new ServiceBase(appId, {
    observableClass: MyObservable
    });
    Index

    Constructors

    • Create an SBObservable instance

      Parameters

      • appId: string

        Application ID

      • mode: DEBUG_MODE

        Debug mode (development, production, production-debug)

      • cwd: string

        Current working directory

      • sbPlugins: SBPlugins

        Plugin manager instance

      Returns SBObservable

    Properties

    observableBus: EventEmitter = ...

    Accessors

    • get isReady(): boolean

      Check if observable plugins are ready

      Returns boolean

      true if all plugins have been initialized

    Methods

    • Setup and load observable plugins from configuration

      Loads configured observable plugins and initializes their filters. This is called during ServiceBase initialization.

      Parameters

      • sbConfig: SBConfig

        Configuration manager instance

      Returns Promise<void>

    • Initialize all observable plugins

      Calls the init lifecycle method on all loaded observable plugins. This is called during ServiceBase initialization.

      Parameters

      • trace: DTrace

        DTrace for tracking initialization

      • sbConfig: SBConfig

        Configuration manager instance

      Returns Promise<void>

    • Run all observable plugins

      Calls the run lifecycle method on all loaded observable plugins. This is called during ServiceBase startup.

      Parameters

      • trace: DTrace

        DTrace for tracking the run phase

      Returns Promise<void>

    • Dispose all observable plugins

      Calls the dispose lifecycle method on all loaded observable plugins and clears the plugin list. This is called during ServiceBase shutdown.

      Returns Promise<void>

    • Emit a debug log event

      Parameters

      • plugin: string

        Plugin name

      • trace: DTrace

        DTrace object

      • message: string

        Log message

      • meta: LogMeta<any>

        Log metadata

      Returns void

    • Emit an info log event

      Parameters

      • plugin: string

        Plugin name

      • trace: DTrace

        DTrace object

      • message: string

        Log message

      • meta: LogMeta<any>

        Log metadata

      Returns void

    • Emit a warn log event

      Parameters

      • plugin: string

        Plugin name

      • trace: DTrace

        DTrace object

      • message: string

        Log message

      • meta: LogMeta<any>

        Log metadata

      Returns void

    • Emit an error log event

      Parameters

      • plugin: string

        Plugin name

      • trace: DTrace

        DTrace object

      • message: string | BSBError<any>

        Log message or BSBError

      • Optionalmeta: LogMeta<any>

        Log metadata (optional)

      Returns void

    • Emit counter creation event

      Parameters

      • timestamp: number

        Event timestamp

      • pluginName: string

        Plugin name

      • name: string

        Metric name

      • description: string

        Short description

      • help: string

        Detailed help text

      • Optionallabels: string[]

        Optional label names

      Returns void

    • Emit counter increment event

      Parameters

      • timestamp: number

        Event timestamp

      • pluginName: string

        Plugin name

      • name: string

        Metric name

      • value: number

        Increment value

      • Optionallabels: Record<string, string>

        Optional label values

      Returns void

    • Emit gauge creation event

      Parameters

      • timestamp: number

        Event timestamp

      • pluginName: string

        Plugin name

      • name: string

        Metric name

      • description: string

        Short description

      • help: string

        Detailed help text

      • Optionallabels: string[]

        Optional label names

      Returns void

    • Emit gauge set event

      Parameters

      • timestamp: number

        Event timestamp

      • pluginName: string

        Plugin name

      • name: string

        Metric name

      • value: number

        New gauge value

      • Optionallabels: Record<string, string>

        Optional label values

      Returns void

    • Emit histogram creation event

      Parameters

      • timestamp: number

        Event timestamp

      • pluginName: string

        Plugin name

      • name: string

        Metric name

      • description: string

        Short description

      • help: string

        Detailed help text

      • Optionalboundaries: number[]

        Optional histogram boundaries

      • Optionallabels: string[]

        Optional label names

      Returns void

    • Emit histogram observation event

      Parameters

      • timestamp: number

        Event timestamp

      • pluginName: string

        Plugin name

      • name: string

        Metric name

      • value: number

        Observed value

      • Optionallabels: Record<string, string>

        Optional label values

      Returns void

    • Emit span start event

      Parameters

      • timestamp: number

        Event timestamp

      • appId: string

        Application ID

      • pluginName: string

        Plugin name

      • traceId: string

        Trace ID

      • parentSpanId: string | null

        Parent span ID (null for root spans)

      • spanId: string

        This span's ID

      • name: string

        Span name

      • Optionalattributes: Record<string, string | number | boolean>

        Optional span attributes

      Returns void

    • Emit span end event

      Parameters

      • timestamp: number

        Event timestamp

      • appId: string

        Application ID

      • pluginName: string

        Plugin name

      • traceId: string

        Trace ID

      • spanId: string

        Span ID

      • Optionalattributes: Record<string, string | number | boolean>

        Optional final attributes

      Returns void

    • Emit span error event

      Parameters

      • timestamp: number

        Event timestamp

      • appId: string

        Application ID

      • pluginName: string

        Plugin name

      • traceId: string

        Trace ID

      • spanId: string

        Span ID

      • error: Error

        Error to record

      • Optionalattributes: Record<string, string | number | boolean>

        Optional error attributes

      Returns void