Anaconda OpenTelemetry for Typescript
    Preparing search index...

    Class Configuration

    Represents the configuration for OpenTelemetry endpoints and options.

    Allows setting default endpoints, authentication tokens, and certificate files, as well as adding metrics and trace endpoints. Provides options for console output, metric export intervals, and skipping internet connectivity checks.

    Environment variables can override default endpoint, authentication token, and certificate file:

    • ATEL_DEFAULT_ENDPOINT
    • ATEL_DEFAULT_AUTH_TOKEN
    • ATEL_DEFAULT_TLS_PRIVATE_CA_CERT_FILE
    • Additionally, the following environment variables can be used to configure metrics and trace endpoints:
    • ATEL_METRICS_ENDPOINT
    • ATEL_METRICS_AUTH_TOKEN
    • ATEL_METRICS_TLS_PRIVATE_CA_CERT_FILE
    • ATEL_TRACE_ENDPOINT
    • ATEL_TRACE_AUTH_TOKEN
    • ATEL_TRACE_TLS_PRIVATE_CA_CERT_FILE
    • ATEL_LOGGING_ENDPOINT
    • ATEL_LOGGING_AUTH_TOKEN
    • ATEL_LOGGING_TLS_PRIVATE_CA_CERT_FILE
    • ATEL_USE_CONSOLE (to route ALL OTEL signals to console output, this is not a per signal type flag)
    • ATEL_METRICS_EXPORT_INTERVAL_MS (to set the interval for metrics export, default is 60000ms, minumum is 1000ms)
    • ATEL_TRACES_EXPORT_INTERVAL_MS (to set the interval for metrics export, default is 60000ms, minumum is 1000ms)
    • ATEL_LOGGING_EXPORT_INTERVAL_MS (to set the interval for logging export, default is 60000ms, minumum is 1000ms)
    • ATEL_SKIP_INTERNET_CHECK (to skip the internet connectivity check, use "true" or "yes" or "1" to skip)
    • ATEL_TRACING_SESSION_ENTROPY (to set the entropy for the tracing session, used to generate unique session IDs)
    • ATEL_USE_CUMULATIVE_METRICS (This will set CUMULATIVE for counter and histogram metrics instead of the default DELTA)
    const config = new Configuration();
    config.setMetricsEndpoint(new URL("https://metrics.example.com"), "token", "/path/to/cert.pem")
    .setUseConsoleOutput(true)
    .setMetricExportIntervalMs(2000);

    All endpoint network schemes must be one of these schemes or that endpoint will log a warning and not function as expected:

    • http: - Regular uncompressed HTTP JSON payloads unencrypted connection.
    • https: - Regular uncompressed HTTP JSON payloads over a TLS encrypted connection.
    • grpc: - GRPC compressed payloads over HTTP unencrypted connection.
    • grrpcs: - GRPC compressed payloads over HTTP TLS encrypted connection.
    • console: - JSON payload written to the stdout console.
    • devnull: - Suppresses all output for the specified signal type.

    All endpoints beginning with http: or https: must use the url path "/v1/signal_type"" where signal_types is one of metrics or traces for metrics and tracing signals respectively.

    Index

    Constructors

    • Constructs a new instance of the configuration class, initializing internal state and setting default values for endpoint, authentication token, and certificate file.

      The class prioritizes values in the following order:

      1. Environment variables (ATEL_DEFAULT_ENDPOINT, ATEL_DEFAULT_AUTH_TOKEN, ATEL_DEFAULT_TLS_PRIVATE_CA_CERT_FILE). This allows quick changes in behaviors without changing code of application configuration.
      2. Explicitly provided arguments to this constructor.
      3. Internal default values if both of the first 2 are missing.

      Parameters

      • OptionaldefaultEndpoint: URL

        The default endpoint URL to use. If not provided, falls back to environment variable or internal default (grpc://localhost:4317).

      • OptionaldefaultAuthToken: string

        The default authentication token. If not provided, falls back to environment variable or internal default (undefined).

      • OptionaldefaultCertFile: string

        The default certificate file path. If not provided, falls back to environment variable or internal default (undefined).

      Returns Configuration

    Methods

    • Enables or disables debug mode.

      Parameters

      • newState: boolean

        Whether to enable debug mode (default: false).

      Returns Configuration

      The current instance for method chaining.

    • Set a logging endpoint to the configuration, overriding any previous endpoints.

      Parameters

      • endpoint: URL

        The URL of the logging endpoint.

      • OptionalauthToken: string

        Optional authentication token for the endpoint.

      • OptionalcertFile: string

        Optional path to a certificate file for secure connections.

      Returns this

      The current instance for method chaining.

    • Sets the interval, in milliseconds, at which logs are exported.

      Parameters

      • value: number

        The export interval in milliseconds. Must be at least 1000ms.

      Returns this

      The current instance for method chaining.

      If the provided value is less than 1000ms.

    • Sets the interval, in milliseconds, at which metrics are exported.

      Parameters

      • value: number

        The export interval in milliseconds. Must be at least 1000ms.

      Returns this

      The current instance for method chaining.

      If the provided value is less than 1000ms.

    • Set a metrics endpoint to the configuration, overriding any previous endpoints.

      Parameters

      • endpoint: URL

        The URL of the metrics endpoint.

      • OptionalauthToken: string

        Optional authentication token for the endpoint.

      • OptionalcertFile: string

        Optional path to a certificate file for secure connections.

      Returns this

      The current instance for method chaining.

    • Sets whether to skip the internet connectivity check.

      Parameters

      • value: boolean

        If true, the internet check will be skipped; otherwise, it will be performed.

      Returns this

      The current instance for method chaining.

    • Set a trace endpoint to the configuration, overriding any previous endpoints.

      Parameters

      • endpoint: URL

        The URL of the traceing endpoint.

      • OptionalauthToken: string

        Optional authentication token for the endpoint.

      • OptionalcertFile: string

        Optional path to a certificate file for secure connections.

      Returns this

      The current instance for method chaining.

    • Sets the interval, in milliseconds, at which traces are exported.

      Parameters

      • value: number

        The export interval in milliseconds. Must be at least 1000ms.

      Returns this

      The current instance for method chaining.

      If the provided value is less than 1000ms.

    • Sets the entropy value for the tracing session.

      The entropy is typically used to introduce uniqueness into the tracing session, which can help with sampling or correlation.

      Parameters

      • entropy: string

        A string representing the entropy value to be used for the tracing session.

      Returns this

      The current instance for method chaining.

    • Sets whether console output should be used for logging or diagnostics. This value overrides all set endpoints. If required to send only one signal to console and not the other one(s), use endpoint network scheme "console:" for the specific signal stream(s) to be sent to the console.

      Parameters

      • value: boolean

        If true, enables console output for all signal types; if false, endpoints are used. Default for the Configuration is false

      Returns this

      The current instance for method chaining.

    • Enables or disables cumulative for counter metrics and histograms temporality.

      When enabled, metric instruments are exported using CUMULATIVE temporality (an ever-increasing total) instead of the default DELTA temporality (per-interval change).

      Parameters

      • enabled: boolean

        Set true to export metrics as cumulative; set false to use delta temporality.

      Returns this

      The current instance for method chaining.

      • This flag applies only to metric-like instruments; histogram temporality is controlled separately via setCumulativeMetricHistograms.
      • Environment override: if ATEL_USE_CUMULATIVE_METRICS is defined (e.g., "true"/"yes"/"1"), it may take precedence over this programmatic setting.
      • Temporality affects how backends aggregate and query time series; choose cumulative when your backend expects monotonic totals.
      • This method performs no I/O and can be called during configuration prior to starting exporters.
      • IMPORTANT: Setting DELTA (the default) may not actually work in the underlying OTel library. It is recommended that cumulative be converted to deltas in the collector if delta is desired for Counters and Histograms.