Skip to content

Commit ef50f2e

Browse files
authored
feat(otel): add support for otel metrics api via protobuf and json (#6783)
* add otlp metrics protos * feat: add OTLP metrics proto definitions and reorganize directory - Add metrics.proto and metrics_service.proto (OTLP v1 spec) - Update protobuf_loader to support metrics protos - Rename protos/ -> otlp/ directory for better organization * refactor: extract common OTLP logic into base classes - Create OtlpHttpExporterBase for shared HTTP export logic - Create OtlpTransformerBase for shared transformation logic - Refactor logs exporter/transformer to extend base classes - Update test mocking paths - Eliminates ~400 lines of duplication * fix logs * increase test coverage * feat(metrics): add support for otel metrics provider * feat(metrics): add support for otlp configurations * updates to pass system tests * add temperolality support and clean up implementation * add support for encoding attributes * simplify tests * use real values in tests * do not encode numbers as strings * use enum in transformation * remove unneed fields * add better temporality support and include encoding for async metric types * improve test coverage for scope attributes * simplify stubs in tests * validate scope attributes * ruben comments * fix broken number test * clean up tests * clean up instruments and update tests * simplify meter * use constants and implement missing callbacks * move otlp_transformer changes over * clean up private/public fields * avoid redefining constant * clean up tests * update typing * linting clean ups * first round of changes from cr * limit number of metrics in each batch * round 3 changes * address more comments part 4 * update doc strings and typing * update max batch size to operate on the aggregate metrics * avoid converting aggregated metrics to arrays, perf * fix regression in logs implementation * revert closure * cleanup max measurement queue, jdocs and typing * log warning if value is invalid * final set of changes * update tests to be compatible with master branch * remove register from meter provider and simplify export * clean up stable stringify and update limit of max queue size * remove @Private from metrics docs * only implement the meterprovider api, renove shutdown and forceflush operations * remove observableInstruments * lint * fix linting failures * fix linting failures * fix linting 3
1 parent 0107e42 commit ef50f2e

21 files changed

+2665
-70
lines changed

docs/API.md

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,74 @@ app.listen(3000)
408408
The Datadog SDK supports many of the configurations supported by the OpenTelemetry SDK. The following environment variables are supported:
409409

410410
- `DD_LOGS_OTEL_ENABLED` - Enable OpenTelemetry logs (default: `false`)
411-
- `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` - OTLP endpoint URL for logs (default: `http://localhost:4318`)
412-
- `OTEL_EXPORTER_OTLP_LOGS_HEADERS` - Optional headers in JSON format for logs (default: `{}`)
413-
- `OTEL_EXPORTER_OTLP_LOGS_PROTOCOL` - OTLP protocol for logs (default: `http/protobuf`)
414-
- `OTEL_EXPORTER_OTLP_LOGS_TIMEOUT` - Request timeout in milliseconds for logs (default: `10000`)
415-
- `OTEL_BSP_SCHEDULE_DELAY` - Batch timeout in milliseconds (default: `5000`)
411+
- `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` - OTLP endpoint URL for logs. Falls back to `OTEL_EXPORTER_OTLP_ENDPOINT` with `/v1/logs` appended (default: `http://localhost:4318/v1/logs`)
412+
- `OTEL_EXPORTER_OTLP_LOGS_HEADERS` - Optional headers for logs in JSON format. Falls back to `OTEL_EXPORTER_OTLP_HEADERS` (default: `{}`)
413+
- `OTEL_EXPORTER_OTLP_LOGS_PROTOCOL` - OTLP protocol for logs. Options: `http/protobuf`, `http/json`. Falls back to `OTEL_EXPORTER_OTLP_PROTOCOL` (default: `http/protobuf`)
414+
- `OTEL_EXPORTER_OTLP_LOGS_TIMEOUT` - Request timeout in milliseconds for logs. Falls back to `OTEL_EXPORTER_OTLP_TIMEOUT` (default: `10000`)
415+
- `OTEL_BSP_SCHEDULE_DELAY` - Batch export delay in milliseconds (default: `5000`)
416416
- `OTEL_BSP_MAX_EXPORT_BATCH_SIZE` - Maximum logs per batch (default: `512`)
417+
- `OTEL_BSP_MAX_QUEUE_SIZE` - Maximum logs to queue before dropping (default: `2048`)
417418

418-
Logs are exported via OTLP over HTTP. The protocol can be configured using `OTEL_EXPORTER_OTLP_LOGS_PROTOCOL` or `OTEL_EXPORTER_OTLP_PROTOCOL` environment variables. Supported protocols are `http/protobuf` (default) and `http/json`. For complete OTLP exporter configuration options, see the [OpenTelemetry OTLP Exporter documentation](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/).
419+
For complete OTLP exporter configuration options, see the [OpenTelemetry OTLP Exporter documentation](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/).
420+
421+
<h3 id="opentelemetry-metrics">OpenTelemetry Metrics</h3>
422+
423+
dd-trace-js includes experimental support for OpenTelemetry metrics, designed as a drop-in replacement for the OpenTelemetry Metrics SDK. This lightweight implementation is fully compliant with the OpenTelemetry Metrics API and integrates with the existing OTLP export infrastructure. Enable it by setting `DD_METRICS_OTEL_ENABLED=true` and use the [OpenTelemetry Metrics API](https://open-telemetry.github.io/opentelemetry-js/modules/_opentelemetry_api.html) to record metric data:
424+
425+
```javascript
426+
require('dd-trace').init()
427+
const { metrics } = require('@opentelemetry/api')
428+
429+
const meter = metrics.getMeter('my-service', '1.0.0')
430+
431+
// Counter - monotonically increasing values
432+
const requestCounter = meter.createCounter('http.requests', {
433+
description: 'Total HTTP requests',
434+
unit: 'requests'
435+
})
436+
requestCounter.add(1, { method: 'GET', status: 200 })
437+
438+
// Histogram - distribution of values
439+
const durationHistogram = meter.createHistogram('http.duration', {
440+
description: 'HTTP request duration',
441+
unit: 'ms'
442+
})
443+
durationHistogram.record(145, { route: '/api/users' })
444+
445+
// UpDownCounter - can increase and decrease
446+
const connectionCounter = meter.createUpDownCounter('active.connections', {
447+
description: 'Active connections',
448+
unit: 'connections'
449+
})
450+
connectionCounter.add(1) // New connection
451+
connectionCounter.add(-1) // Connection closed
452+
453+
// ObservableGauge - asynchronous observations
454+
const cpuGauge = meter.createObservableGauge('system.cpu.usage', {
455+
description: 'CPU usage percentage',
456+
unit: 'percent'
457+
})
458+
cpuGauge.addCallback((result) => {
459+
const cpuUsage = process.cpuUsage()
460+
result.observe(cpuUsage.system / 1000000, { core: '0' })
461+
})
462+
```
463+
464+
#### Supported Configuration
465+
466+
The Datadog SDK supports many of the configurations supported by the OpenTelemetry SDK. The following environment variables are supported:
467+
468+
- `DD_METRICS_OTEL_ENABLED` - Enable OpenTelemetry metrics (default: `false`)
469+
- `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` - OTLP endpoint URL for metrics. Falls back to `OTEL_EXPORTER_OTLP_ENDPOINT` with `/v1/metrics` appended (default: `http://localhost:4318/v1/metrics`)
470+
- `OTEL_EXPORTER_OTLP_METRICS_HEADERS` - Optional headers for metrics in JSON format. Falls back to `OTEL_EXPORTER_OTLP_HEADERS` (default: `{}`)
471+
- `OTEL_EXPORTER_OTLP_METRICS_PROTOCOL` - OTLP protocol for metrics. Options: `http/protobuf`, `http/json`. Falls back to `OTEL_EXPORTER_OTLP_PROTOCOL` (default: `http/protobuf`)
472+
- `OTEL_EXPORTER_OTLP_METRICS_TIMEOUT` - Request timeout in milliseconds for metrics. Falls back to `OTEL_EXPORTER_OTLP_TIMEOUT` (default: `10000`)
473+
- `OTEL_METRIC_EXPORT_INTERVAL` - Metric export interval in milliseconds (default: `10000`)
474+
- `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` - Aggregation temporality preference. Options: `CUMULATIVE`, `DELTA`, `LOWMEMORY` (default: `DELTA`). See [OpenTelemetry spec](https://opentelemetry.io/docs/specs/otel/metrics/sdk_exporters/otlp/#additional-environment-variable-configuration) for details
475+
- `OTEL_BSP_MAX_QUEUE_SIZE` - Maximum metrics to queue before dropping (default: `2048`)
476+
- `OTEL_METRIC_EXPORT_TIMEOUT` - [NOT YET SUPPORTED] Time to export metrics including retries
477+
478+
For complete OTLP exporter configuration options, see the [OpenTelemetry OTLP Exporter documentation](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/).
419479

420480
<h2 id="advanced-configuration">Advanced Configuration</h2>
421481

packages/dd-trace/src/config.js

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ class Config {
478478
DD_INSTRUMENTATION_CONFIG_ID,
479479
DD_LOGS_INJECTION,
480480
DD_LOGS_OTEL_ENABLED,
481+
DD_METRICS_OTEL_ENABLED,
481482
DD_LANGCHAIN_SPAN_CHAR_LIMIT,
482483
DD_LANGCHAIN_SPAN_PROMPT_COMPLETION_SAMPLE_RATE,
483484
DD_LLMOBS_AGENTLESS_ENABLED,
@@ -572,12 +573,20 @@ class Config {
572573
OTEL_EXPORTER_OTLP_LOGS_HEADERS,
573574
OTEL_EXPORTER_OTLP_LOGS_PROTOCOL,
574575
OTEL_EXPORTER_OTLP_LOGS_TIMEOUT,
576+
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT,
577+
OTEL_EXPORTER_OTLP_METRICS_HEADERS,
578+
OTEL_EXPORTER_OTLP_METRICS_PROTOCOL,
579+
OTEL_EXPORTER_OTLP_METRICS_TIMEOUT,
580+
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE,
581+
OTEL_METRIC_EXPORT_TIMEOUT,
575582
OTEL_EXPORTER_OTLP_PROTOCOL,
576583
OTEL_EXPORTER_OTLP_ENDPOINT,
577584
OTEL_EXPORTER_OTLP_HEADERS,
578585
OTEL_EXPORTER_OTLP_TIMEOUT,
579586
OTEL_BSP_SCHEDULE_DELAY,
580-
OTEL_BSP_MAX_EXPORT_BATCH_SIZE
587+
OTEL_BSP_MAX_EXPORT_BATCH_SIZE,
588+
OTEL_BSP_MAX_QUEUE_SIZE,
589+
OTEL_METRIC_EXPORT_INTERVAL
581590
} = source
582591

583592
const tags = {}
@@ -604,10 +613,40 @@ class Config {
604613
this.#setString(target, 'otelLogsHeaders', OTEL_EXPORTER_OTLP_LOGS_HEADERS || target.otelHeaders)
605614
this.#setString(target, 'otelProtocol', OTEL_EXPORTER_OTLP_PROTOCOL)
606615
this.#setString(target, 'otelLogsProtocol', OTEL_EXPORTER_OTLP_LOGS_PROTOCOL || target.otelProtocol)
607-
target.otelTimeout = maybeInt(OTEL_EXPORTER_OTLP_TIMEOUT)
608-
target.otelLogsTimeout = maybeInt(OTEL_EXPORTER_OTLP_LOGS_TIMEOUT) || target.otelTimeout
609-
target.otelLogsBatchTimeout = maybeInt(OTEL_BSP_SCHEDULE_DELAY)
610-
target.otelLogsMaxExportBatchSize = maybeInt(OTEL_BSP_MAX_EXPORT_BATCH_SIZE)
616+
const otelTimeout = nonNegInt(OTEL_EXPORTER_OTLP_TIMEOUT, 'OTEL_EXPORTER_OTLP_TIMEOUT')
617+
if (otelTimeout !== undefined) {
618+
target.otelTimeout = otelTimeout
619+
}
620+
const otelLogsTimeout = nonNegInt(OTEL_EXPORTER_OTLP_LOGS_TIMEOUT, 'OTEL_EXPORTER_OTLP_LOGS_TIMEOUT')
621+
target.otelLogsTimeout = otelLogsTimeout === undefined ? target.otelTimeout : otelLogsTimeout
622+
const otelBatchTimeout = nonNegInt(OTEL_BSP_SCHEDULE_DELAY, 'OTEL_BSP_SCHEDULE_DELAY', false)
623+
if (otelBatchTimeout !== undefined) {
624+
target.otelBatchTimeout = otelBatchTimeout
625+
}
626+
target.otelMaxExportBatchSize = nonNegInt(OTEL_BSP_MAX_EXPORT_BATCH_SIZE, 'OTEL_BSP_MAX_EXPORT_BATCH_SIZE', false)
627+
target.otelMaxQueueSize = nonNegInt(OTEL_BSP_MAX_QUEUE_SIZE, 'OTEL_BSP_MAX_QUEUE_SIZE', false)
628+
629+
const otelMetricsExporter = !OTEL_METRICS_EXPORTER || OTEL_METRICS_EXPORTER.toLowerCase() !== 'none'
630+
this.#setBoolean(target, 'otelMetricsEnabled', DD_METRICS_OTEL_ENABLED && otelMetricsExporter)
631+
// Set OpenTelemetry metrics configuration with specific _METRICS_ vars
632+
// taking precedence over generic _EXPORTERS_ vars
633+
if (OTEL_EXPORTER_OTLP_ENDPOINT || OTEL_EXPORTER_OTLP_METRICS_ENDPOINT) {
634+
this.#setString(target, 'otelMetricsUrl', OTEL_EXPORTER_OTLP_METRICS_ENDPOINT || target.otelUrl)
635+
}
636+
this.#setString(target, 'otelMetricsHeaders', OTEL_EXPORTER_OTLP_METRICS_HEADERS || target.otelHeaders)
637+
this.#setString(target, 'otelMetricsProtocol', OTEL_EXPORTER_OTLP_METRICS_PROTOCOL || target.otelProtocol)
638+
const otelMetricsTimeout = nonNegInt(OTEL_EXPORTER_OTLP_METRICS_TIMEOUT, 'OTEL_EXPORTER_OTLP_METRICS_TIMEOUT')
639+
target.otelMetricsTimeout = otelMetricsTimeout === undefined ? target.otelTimeout : otelMetricsTimeout
640+
target.otelMetricsExportTimeout = nonNegInt(OTEL_METRIC_EXPORT_TIMEOUT, 'OTEL_METRIC_EXPORT_TIMEOUT')
641+
target.otelMetricsExportInterval = nonNegInt(OTEL_METRIC_EXPORT_INTERVAL, 'OTEL_METRIC_EXPORT_INTERVAL', false)
642+
643+
// Parse temporality preference (default to DELTA for Datadog)
644+
if (OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE) {
645+
const temporalityPref = OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE.toUpperCase()
646+
if (['DELTA', 'CUMULATIVE', 'LOWMEMORY'].includes(temporalityPref)) {
647+
this.#setString(target, 'otelMetricsTemporalityPreference', temporalityPref)
648+
}
649+
}
611650
this.#setBoolean(
612651
target,
613652
'apmTracingEnabled',
@@ -1206,9 +1245,10 @@ class Config {
12061245

12071246
calc['dogstatsd.hostname'] = this.#getHostname()
12081247

1209-
// Compute OTLP logs URL to send payloads to the active Datadog Agent
1248+
// Compute OTLP logs and metrics URLs to send payloads to the active Datadog Agent
12101249
const agentHostname = this.#getHostname()
12111250
calc.otelLogsUrl = `http://${agentHostname}:${DEFAULT_OTLP_PORT}`
1251+
calc.otelMetricsUrl = `http://${agentHostname}:${DEFAULT_OTLP_PORT}/v1/metrics`
12121252
calc.otelUrl = `http://${agentHostname}:${DEFAULT_OTLP_PORT}`
12131253

12141254
this.#setBoolean(calc, 'isGitUploadEnabled',
@@ -1497,6 +1537,16 @@ function maybeFloat (number) {
14971537
return Number.isNaN(parsed) ? undefined : parsed
14981538
}
14991539

1540+
function nonNegInt (value, envVarName, allowZero = true) {
1541+
if (value === undefined) return
1542+
const parsed = Number.parseInt(value)
1543+
if (Number.isNaN(parsed) || parsed < 0 || (parsed === 0 && !allowZero)) {
1544+
log.warn(`Invalid value ${parsed} for ${envVarName}. Using default value.`)
1545+
return
1546+
}
1547+
return parsed
1548+
}
1549+
15001550
function getAgentUrl (url, options) {
15011551
if (url) return new URL(url)
15021552

packages/dd-trace/src/config_defaults.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,17 @@ module.exports = {
140140
otelLogsProtocol: 'http/protobuf',
141141
otelLogsTimeout: 10_000,
142142
otelTimeout: 10_000,
143-
otelLogsBatchTimeout: 5000,
144-
otelLogsMaxExportBatchSize: 512,
143+
otelBatchTimeout: 5000,
144+
otelMaxExportBatchSize: 512,
145+
otelMaxQueueSize: 2048,
146+
otelMetricsEnabled: false,
147+
otelMetricsUrl: undefined, // Will be computed using agent host
148+
otelMetricsHeaders: '',
149+
otelMetricsProtocol: 'http/protobuf',
150+
otelMetricsTimeout: 10_000,
151+
otelMetricsExportTimeout: 7500,
152+
otelMetricsExportInterval: 10_000,
153+
otelMetricsTemporalityPreference: 'DELTA', // DELTA, CUMULATIVE, or LOWMEMORY
145154
lookup: undefined,
146155
inferredProxyServicesEnabled: false,
147156
memcachedCommandEnabled: false,

packages/dd-trace/src/opentelemetry/logs/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ function initializeOpenTelemetryLogs (config) {
7070
// Create batch processor for exporting logs to Datadog Agent
7171
const processor = new BatchLogRecordProcessor(
7272
exporter,
73-
config.otelLogsBatchTimeout,
74-
config.otelLogsMaxExportBatchSize
73+
config.otelBatchTimeout,
74+
config.otelMaxExportBatchSize
7575
)
7676

7777
// Create logger provider with processor for Datadog Agent export

packages/dd-trace/src/opentelemetry/logs/logger.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
const { sanitizeAttributes } = require('@opentelemetry/core')
44
const { context } = require('@opentelemetry/api')
5-
const packageVersion = require('../../../../../package.json').version
5+
const { VERSION: packageVersion } = require('../../../../../version')
6+
67
/**
78
* @typedef {import('@opentelemetry/api-logs').LogRecord} LogRecord
89
* @typedef {import('@opentelemetry/api-logs').LoggerProvider} LoggerProvider

packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const OtlpTransformer = require('./otlp_transformer')
1111
/**
1212
* OtlpHttpLogExporter exports log records via OTLP over HTTP.
1313
*
14-
* This implementation follows the OTLP HTTP specification:
14+
* This implementation follows the OTLP HTTP v1.7.0 specification:
1515
* https://opentelemetry.io/docs/specs/otlp/#otlphttp
1616
*
1717
* @class OtlpHttpLogExporter
@@ -37,6 +37,8 @@ class OtlpHttpLogExporter extends OtlpHttpExporterBase {
3737
*
3838
* @param {LogRecord[]} logRecords - Array of enriched log records to export
3939
* @param {Function} resultCallback - Callback function for export result
40+
*
41+
* @returns {void}
4042
*/
4143
export (logRecords, resultCallback) {
4244
if (logRecords.length === 0) {
@@ -45,8 +47,8 @@ class OtlpHttpLogExporter extends OtlpHttpExporterBase {
4547
}
4648

4749
const payload = this.transformer.transformLogRecords(logRecords)
48-
this._sendPayload(payload, resultCallback)
49-
this._recordTelemetry('otel.log_records', logRecords.length)
50+
this.sendPayload(payload, resultCallback)
51+
this.recordTelemetry('otel.log_records', logRecords.length)
5052
}
5153
}
5254

packages/dd-trace/src/opentelemetry/logs/otlp_transformer.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const SEVERITY_MAP = {
4040
/**
4141
* OtlpTransformer transforms log records to OTLP format.
4242
*
43-
* This implementation follows the OTLP Logs Data Model specification:
43+
* This implementation follows the OTLP Logs v1.7.0 Data Model specification:
4444
* https://opentelemetry.io/docs/specs/otlp/#log-data-model
4545
*
4646
* @class OtlpTransformer
@@ -79,12 +79,12 @@ class OtlpTransformer extends OtlpTransformerBase {
7979

8080
const logsData = {
8181
resourceLogs: [{
82-
resource: this._transformResource(),
82+
resource: this.transformResource(),
8383
scopeLogs: this.#transformScope(logRecords),
8484
}]
8585
}
8686

87-
return this._serializeToProtobuf(protoLogsService, logsData)
87+
return this.serializeToProtobuf(protoLogsService, logsData)
8888
}
8989

9090
/**
@@ -95,11 +95,11 @@ class OtlpTransformer extends OtlpTransformerBase {
9595
#transformToJson (logRecords) {
9696
const logsData = {
9797
resourceLogs: [{
98-
resource: this._transformResource(),
98+
resource: this.transformResource(),
9999
scopeLogs: this.#transformScope(logRecords)
100100
}]
101101
}
102-
return this._serializeToJson(logsData)
102+
return this.serializeToJson(logsData)
103103
}
104104

105105
/**
@@ -108,7 +108,7 @@ class OtlpTransformer extends OtlpTransformerBase {
108108
* @returns {Object[]} Array of scope log objects
109109
*/
110110
#transformScope (logRecords) {
111-
const groupedRecords = this._groupByInstrumentationScope(logRecords)
111+
const groupedRecords = this.groupByInstrumentationScope(logRecords)
112112
const scopeLogs = []
113113

114114
for (const records of groupedRecords.values()) {
@@ -155,7 +155,7 @@ class OtlpTransformer extends OtlpTransformerBase {
155155
}
156156

157157
if (logRecord.attributes) {
158-
result.attributes = this._transformAttributes(logRecord.attributes)
158+
result.attributes = this.transformAttributes(logRecord.attributes)
159159
}
160160

161161
if (spanContext?.traceFlags !== undefined) {
@@ -232,7 +232,7 @@ class OtlpTransformer extends OtlpTransformerBase {
232232
kvlistValue: {
233233
values: Object.entries(body).map(([key, value]) => ({
234234
key,
235-
value: this._transformAnyValue(value)
235+
value: this.transformAnyValue(value)
236236
}))
237237
}
238238
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict'
2+
3+
// Metric type constants
4+
const METRIC_TYPES = {
5+
HISTOGRAM: 'histogram',
6+
COUNTER: 'counter',
7+
UPDOWNCOUNTER: 'updowncounter',
8+
OBSERVABLECOUNTER: 'observable-counter',
9+
OBSERVABLEUPDOWNCOUNTER: 'observable-updowncounter',
10+
GAUGE: 'gauge'
11+
}
12+
13+
// Temporality constants
14+
const TEMPORALITY = {
15+
DELTA: 'DELTA',
16+
CUMULATIVE: 'CUMULATIVE',
17+
GAUGE: 'GAUGE',
18+
LOWMEMORY: 'LOWMEMORY'
19+
}
20+
21+
// Default histogram bucket boundaries (in milliseconds for latency metrics)
22+
const DEFAULT_HISTOGRAM_BUCKETS = [0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10_000]
23+
24+
// Maximum number of measurements to queue before dropping
25+
// This limit corresponds to the maximum number of items
26+
// that be reliably added to a single Array.
27+
const DEFAULT_MAX_MEASUREMENT_QUEUE_SIZE = 65_536
28+
29+
module.exports = {
30+
METRIC_TYPES,
31+
TEMPORALITY,
32+
DEFAULT_HISTOGRAM_BUCKETS,
33+
DEFAULT_MAX_MEASUREMENT_QUEUE_SIZE
34+
}

0 commit comments

Comments
 (0)