UNPKG

@splunk/otel

Version:

The Splunk distribution of OpenTelemetry Node Instrumentation provides a Node agent that automatically instruments your Node application to capture and report distributed traces to Splunk APM.

78 lines 3.37 kB
"use strict"; /* * Copyright Splunk Inc. * * 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. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.enableDebugMetrics = enableDebugMetrics; exports.recordCpuProfilerMetrics = recordCpuProfilerMetrics; exports.recordHeapProfilerMetrics = recordHeapProfilerMetrics; exports.getDebugMetricsViews = getDebugMetricsViews; const api_1 = require("@opentelemetry/api"); const sdk_metrics_1 = require("@opentelemetry/sdk-metrics"); let meters; const instrumentCpuProfilerStart = 'splunk.profiler.cpu.start.duration'; const instrumentCpuProfilerStop = 'splunk.profiler.cpu.stop.duration'; const instrumentCpuProfilerProcess = 'splunk.profiler.cpu.process.duration'; const instrumentHeapProfilerCollect = 'splunk.profiler.heap.collect.duration'; const instrumentHeapProfilerProcess = 'splunk.profiler.heap.process.duration'; function enableDebugMetrics() { const meter = api_1.metrics.getMeter('splunk-otel-js-debug-metrics'); const opts = { unit: 'ns' }; const cpuProfilerStartDuration = meter.createHistogram(instrumentCpuProfilerStart, opts); const cpuProfilerStopDuration = meter.createHistogram(instrumentCpuProfilerStop, opts); const cpuProfilerProcessingStepDuration = meter.createHistogram(instrumentCpuProfilerProcess, opts); const heapProfilerCollectDuration = meter.createHistogram(instrumentHeapProfilerCollect, opts); const heapProfilerProcessingStepDuration = meter.createHistogram(instrumentHeapProfilerProcess, opts); meters = { meter, cpuProfilerStartDuration, cpuProfilerStopDuration, cpuProfilerProcessingStepDuration, heapProfilerCollectDuration, heapProfilerProcessingStepDuration, }; } function recordCpuProfilerMetrics(metrics) { if (meters === undefined) { return; } meters.cpuProfilerStartDuration.record(metrics.profilerStartDuration); meters.cpuProfilerStopDuration.record(metrics.profilerStopDuration); meters.cpuProfilerProcessingStepDuration.record(metrics.profilerProcessingStepDuration); } function recordHeapProfilerMetrics(metrics) { if (meters === undefined) { return; } meters.heapProfilerCollectDuration.record(metrics.profilerCollectDuration); meters.heapProfilerProcessingStepDuration.record(metrics.profilerProcessingStepDuration); } function getDebugMetricsViews() { return [ instrumentCpuProfilerStart, instrumentCpuProfilerStop, instrumentCpuProfilerProcess, ].map((instrumentName) => ({ instrumentName, aggregation: { type: sdk_metrics_1.AggregationType.EXPLICIT_BUCKET_HISTOGRAM, options: { boundaries: [1e6, 1e8, 1e9, 1e10], recordMinMax: true, }, }, })); } //# sourceMappingURL=debug_metrics.js.map