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

    Class BSBObservable<ReferencedConfig>Abstract

    Unified Observable plugin base class for logging, metrics, and tracing

    Type Parameters

    Index

    Constructors

    Properties

    appId: string = "tbd"

    The unique app id of the app that is running

    mode: DEBUG_MODE = "development"

    The mode the app is running in

    production (production mode - no debug)
    
    production-debug (production mode - debug)
    
    development (development mode - debug)
    
    cwd: string

    The current working directory of the app

    packageCwd: string

    The current working directory of the plugin

    pluginCwd: string

    The current working directory of the service

    pluginName: string

    The name of the plugin This is also the mapped name, or the name defined in the config rather than it's original defined name

    region?: string

    The deployment region for resource context

    config: ConfigPropertyTypeSafe<ReferencedConfig extends null ? null : any>

    The config of the plugin

    Methods

    • Logging: Debug level

      Parameters

      • trace: DTrace

        Trace for tracking the operation

      • pluginName: string

        Name of the plugin emitting the log

      • message: string

        Log message

      • meta: LogMeta<any>

        Metadata

      Returns void

    • Logging: Info level

      Parameters

      • trace: DTrace

        Trace for tracking the operation

      • pluginName: string

        Name of the plugin emitting the log

      • message: string

        Log message

      • meta: LogMeta<any>

        Metadata

      Returns void

    • Logging: Warn level

      Parameters

      • trace: DTrace

        Trace for tracking the operation

      • pluginName: string

        Name of the plugin emitting the log

      • message: string

        Log message

      • meta: LogMeta<any>

        Metadata

      Returns void

    • Logging: Error level

      Parameters

      • trace: DTrace

        Trace for tracking the operation

      • pluginName: string

        Name of the plugin emitting the log

      • message: string | BSBError<any>

        Log message or error object

      • Optionalmeta: LogMeta<any>

        Metadata

      Returns void

    • Metrics: Counter creation

      Parameters

      • timestamp: number

        Timestamp of the metric

      • pluginName: string

        Name of the plugin emitting the metric

      • name: string

        Metric name

      • description: string

        Metric description

      • help: string

        Help text

      • Optionallabels: string[]

        Optional labels

      Returns void | Promise<void>

    • Metrics: Gauge creation

      Parameters

      • timestamp: number

        Timestamp of the metric

      • pluginName: string

        Name of the plugin emitting the metric

      • name: string

        Metric name

      • description: string

        Metric description

      • help: string

        Help text

      • Optionallabels: string[]

        Optional labels

      Returns void | Promise<void>

    • Metrics: Histogram creation

      Parameters

      • timestamp: number

        Timestamp of the metric

      • pluginName: string

        Name of the plugin emitting the metric

      • name: string

        Metric name

      • description: string

        Metric description

      • help: string

        Help text

      • Optionalboundaries: number[]

        Histogram boundaries

      • Optionallabels: string[]

        Optional labels

      Returns void | Promise<void>

    • Metrics: Counter increment

      Parameters

      • timestamp: number

        Timestamp of the metric

      • pluginName: string

        Name of the plugin emitting the metric

      • name: string

        Metric name

      • value: number

        Increment value

      • Optionallabels: Record<string, string>

        Optional label values

      Returns void | Promise<void>

    • Metrics: Gauge set

      Parameters

      • timestamp: number

        Timestamp of the metric

      • pluginName: string

        Name of the plugin emitting the metric

      • name: string

        Metric name

      • value: number

        Gauge value

      • Optionallabels: Record<string, string>

        Optional label values

      Returns void | Promise<void>

    • Metrics: Histogram observe

      Parameters

      • timestamp: number

        Timestamp of the metric

      • pluginName: string

        Name of the plugin emitting the metric

      • name: string

        Metric name

      • value: number

        Observed value

      • Optionallabels: Record<string, string>

        Optional label values

      Returns void | Promise<void>

    • Tracing: Span start

      Parameters

      • trace: DTrace

        Span trace (contains trace ID and new span ID)

      • pluginName: string

        Name of the plugin creating the span

      • spanName: string

        Name of the span

      • parentSpanId: string | null

        Parent span ID (null for root spans)

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

        Span attributes

      Returns void | Promise<void>

    • Tracing: Span end

      Parameters

      • trace: DTrace

        Span trace

      • pluginName: string

        Name of the plugin ending the span

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

        Final attributes

      Returns void | Promise<void>

    • Tracing: Span error

      Parameters

      • trace: DTrace

        Span trace

      • pluginName: string

        Name of the plugin recording the error

      • error: Error

        Error object

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

        Error attributes

      Returns void | Promise<void>

    • Dispose Optional function to be called when the plugin is being disposed

      Returns void

      dispose?(): void; //to not use it
      
      dispose() { your code here };
      
    • Init Optional function to be called when the plugin is being initialized Can be sync or async

      Parameters

      • obs: Observable

        Observable context with logging, metrics, and trace information

      Returns void | Promise<void>

      v9 BREAKING CHANGE: Now requires Observable instead of DTrace. Observable provides unified access to logging, metrics, and tracing with automatic context propagation.

      async init(obs: Observable) {
      obs.log.info("Initializing plugin");
      // Set attributes for all child operations
      const withVersion = obs.setAttribute("plugin.version", "1.0.0");
      }
    • Run Optional function to be called when the plugin is being run Can be sync or async

      Parameters

      • obs: Observable

        Observable context with logging, metrics, and trace information

      Returns void | Promise<void>

      v9 BREAKING CHANGE: Now requires Observable instead of DTrace. Observable provides unified access to logging, metrics, and tracing with automatic context propagation.

      async run(obs: Observable) {
      obs.log.info("Running plugin");
      // Create child span for work
      const workObs = obs.startSpan("do-work");
      // ... do work ...
      workObs.end();
      }