Skip to content

Commit

Permalink
feat: support OTEL_METRIC_EXPORT_INTERVAL and `OTEL_METRIC_EXPORT_T…
Browse files Browse the repository at this point in the history
  • Loading branch information
wrn14897 authored Jul 30, 2024
1 parent 5ddd5dd commit 26ae2d9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-pumas-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperdx/node-opentelemetry': patch
---

feat: support OTEL_METRIC_EXPORT_INTERVAL and OTEL_METRIC_EXPORT_TIMEOUT
10 changes: 8 additions & 2 deletions packages/node-opentelemetry/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ export const DEFAULT_OTEL_LOGS_EXPORTER_URL =
(otelEnv.OTEL_EXPORTER_OTLP_ENDPOINT
? `${otelEnv.OTEL_EXPORTER_OTLP_ENDPOINT}/v1/logs`
: 'https://in-otel.hyperdx.io/v1/logs');
export const DEFAULT_OTEL_METRICS_EXPORTER = (otelEnv as any)
.OTEL_METRICS_EXPORTER; // not exist yet
export const DEFAULT_OTEL_METRICS_EXPORTER = env.OTEL_METRICS_EXPORTER; // not exist yet
export const DEFAULT_OTEL_METRICS_EXPORTER_URL =
otelEnv.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT ??
(otelEnv.OTEL_EXPORTER_OTLP_ENDPOINT
? `${otelEnv.OTEL_EXPORTER_OTLP_ENDPOINT}/v1/metrics`
: 'https://in-otel.hyperdx.io/v1/metrics');
export const DEFAULT_OTEL_METRIC_EXPORT_INTERVAL =
env.OTEL_METRIC_EXPORT_INTERVAL
? Number(env.OTEL_METRIC_EXPORT_INTERVAL)
: 60000; // not exist yet
export const DEFAULT_OTEL_METRIC_EXPORT_TIMEOUT = env.OTEL_METRIC_EXPORT_TIMEOUT
? Number(env.OTEL_METRIC_EXPORT_TIMEOUT)
: 30000; // not exist yet
export const DEFAULT_SERVICE_NAME = () =>
getEnvWithoutDefaults().OTEL_SERVICE_NAME ?? defaultServiceName();
export const DEFAULT_OTEL_LOG_LEVEL = otelEnvWithDefaults.OTEL_LOG_LEVEL;
Expand Down
9 changes: 7 additions & 2 deletions packages/node-opentelemetry/src/metrics.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-proto';
import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';

import { DEFAULT_OTEL_METRICS_EXPORTER_URL } from './constants';
import {
DEFAULT_OTEL_METRIC_EXPORT_INTERVAL,
DEFAULT_OTEL_METRIC_EXPORT_TIMEOUT,
DEFAULT_OTEL_METRICS_EXPORTER_URL,
} from './constants';

export const getHyperDXMetricReader = () =>
new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter({
url: DEFAULT_OTEL_METRICS_EXPORTER_URL,
}),
exportIntervalMillis: 1000,
exportIntervalMillis: DEFAULT_OTEL_METRIC_EXPORT_INTERVAL,
exportTimeoutMillis: DEFAULT_OTEL_METRIC_EXPORT_TIMEOUT,
});

0 comments on commit 26ae2d9

Please sign in to comment.