UNPKG

solarwinds-apm

Version:
54 lines (51 loc) 1.99 kB
/* Copyright 2023-2026 SolarWinds Worldwide, LLC. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-proto"; import { AggregationTemporality, AggregationType, InstrumentType, PeriodicExportingMetricReader, } from "@opentelemetry/sdk-metrics"; import { exporterConfig } from "./config.js"; export class MetricExporter extends OTLPMetricExporter { constructor(config) { super(exporterConfig(config, "metrics")); } selectAggregationTemporality() { return AggregationTemporality.DELTA; } } const DEFAULT_CARDINALITY_LIMIT = 200; export class MetricReader extends PeriodicExportingMetricReader { #cardinalityLimit; constructor(options) { super(options); this.#cardinalityLimit = options.cardinalityLimit ?? DEFAULT_CARDINALITY_LIMIT; } selectAggregation(instrumentType) { switch (instrumentType) { case InstrumentType.HISTOGRAM: { return { type: AggregationType.EXPONENTIAL_HISTOGRAM, options: { recordMinMax: true, }, }; } default: { return super.selectAggregation(instrumentType); } } } selectCardinalityLimit(instrumentType) { return Math.min(super.selectCardinalityLimit(instrumentType), this.#cardinalityLimit); } } //# sourceMappingURL=metrics.js.map