UNPKG

@aws/aws-distro-opentelemetry-node-autoinstrumentation

Version:

This package provides Amazon Web Services distribution of the OpenTelemetry Node Instrumentation, which allows for auto-instrumentation of NodeJS applications.

112 lines 5.27 kB
import { Instrumentation } from '@opentelemetry/instrumentation'; import { Resource } from '@opentelemetry/resources'; import { PushMetricExporter } from '@opentelemetry/sdk-metrics'; import { NodeSDKConfiguration } from '@opentelemetry/sdk-node'; import type { Sampler, SpanExporter, SpanProcessor } from '@opentelemetry/sdk-trace-base'; import { LogRecordExporter, LogRecordProcessor } from '@opentelemetry/sdk-logs'; import { EMFExporterBase } from './exporter/aws/metrics/emf-exporter-base'; export declare const AWS_LAMBDA_FUNCTION_NAME_CONFIG: string; export declare const AGENT_OBSERVABILITY_ENABLED = "AGENT_OBSERVABILITY_ENABLED"; export declare const LAMBDA_APPLICATION_SIGNALS_REMOTE_ENVIRONMENT: string; interface OtlpLogHeaderSetting { logGroup?: string; logStream?: string; namespace?: string; isValid: boolean; } /** * Aws Application Signals Config Provider creates a configuration object that can be provided to * the OTel NodeJS SDK for Auto Instrumentation with Application Signals Functionality. * * The config includes: * - Use AlwaysRecordSampler (wraps around a specified Sampler) to record all spans. * - Add SpanMetricsProcessor to create metrics. * - Add AttributePropagatingSpanProcessor to propagate span attributes from parent to child spans. * - Add AwsMetricAttributesSpanExporter to add more attributes to all spans. * * You can control when these customizations are applied using the environment variable * OTEL_AWS_APPLICATION_SIGNALS_ENABLED. This flag is disabled by default. */ export declare class AwsOpentelemetryConfigurator { private resource; private instrumentations; private idGenerator; private sampler; private spanProcessors; private logRecordProcessors; private propagator; private metricReader; /** * The constructor will setup the AwsOpentelemetryConfigurator object to be able to provide a * configuration for ADOT JavaScript Auto-Instrumentation. * * The `instrumentations` are the desired Node auto-instrumentations to be used when using ADOT JavaScript. * The auto-Instrumentions are usually populated from OTel's `getNodeAutoInstrumentations()` method from the * `@opentelemetry/auto-instrumentations-node` NPM package, and may have instrumentation patching applied. * * @constructor * @param {Instrumentation[]} instrumentations - Auto-Instrumentations to be added to the ADOT Config */ constructor(instrumentations: Instrumentation[], useXraySampler?: boolean); private customizeVersions; private customizeResource; configure(): Partial<NodeSDKConfiguration>; static isApplicationSignalsEnabled(): boolean; static geMetricExportInterval(): number; static exportUnsampledSpanForAgentObservability(spanProcessors: SpanProcessor[], resource: Resource): void; static customizeSpanProcessors(spanProcessors: SpanProcessor[], resource: Resource): void; private customizeMetricReader; static customizeSampler(sampler: Sampler): Sampler; } export declare function customBuildSamplerFromEnv(resource: Resource, useXraySampler?: boolean): Sampler; export declare class ApplicationSignalsExporterProvider { private static _instance; private constructor(); static get Instance(): ApplicationSignalsExporterProvider; createExporter(): PushMetricExporter; private aggregationSelector; } export declare class AwsLoggerProcessorProvider { static getlogRecordProcessors(): LogRecordProcessor[]; static configureLogExportersFromEnv(): LogRecordExporter[]; } export declare class AwsSpanProcessorProvider { private _configuredExporters; private _spanProcessors; private resource; static configureOtlp(): SpanExporter; static getOtlpProtocol(): string; private static configureJaeger; protected static _registeredExporters: Map<string, () => SpanExporter>; constructor(resource: Resource); private createExportersFromList; protected _getSpanExporter(name: string): SpanExporter | undefined; private configureSpanProcessors; private filterBlanksAndNulls; static customizeSpanExporter(spanExporter: SpanExporter, resource: Resource): SpanExporter; getSpanProcessors(): SpanProcessor[]; } /** * Based on environment, builds a sampler, complies with specification. * Uses the new OTel 2.x getStringFromEnv API instead of deprecated getEnv(). */ export declare function buildSamplerFromEnv(): Sampler; export declare function isLambdaEnvironment(): boolean; /** * Determines if the given endpoint is either the AWS OTLP Traces or Logs endpoint. */ export declare function isAwsOtlpEndpoint(otlpEndpoint: string, service: string): boolean; /** * Checks if x-aws-log-group and x-aws-log-stream are present in the headers in order to send logs to * AWS OTLP Logs endpoint. */ export declare function validateAndFetchLogsHeader(): OtlpLogHeaderSetting; export declare function checkEmfExporterEnabled(): boolean; /** * Create the appropriate EMF exporter based on the environment and configuration. * * @returns {EMFExporterBase | undefined} */ export declare function createEmfExporter(): EMFExporterBase | undefined; export {}; //# sourceMappingURL=aws-opentelemetry-configurator.d.ts.map