Skip to content

Commit

Permalink
feat: read OTEL_METRIC_EXPORT_INTERVAL and OTEL_METRIC_EXPORT_TIMEOUT
Browse files Browse the repository at this point in the history
  • Loading branch information
wrn14897 committed Jul 21, 2024
1 parent 67ed051 commit addf0ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions packages/node-opentelemetry/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +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_METRICS_EXPORTER_EXPORT_INTERVAL =
(otelEnv as any).OTEL_EXPORTER_OTLP_METRICS_EXPORT_INTERVAL ?? 60000; // not exist yet
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
6 changes: 4 additions & 2 deletions packages/node-opentelemetry/src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';

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

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

0 comments on commit addf0ce

Please sign in to comment.