Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support OTEL_METRIC_EXPORT_INTERVAL and OTEL_METRIC_EXPORT_TIMEOUT #168

Merged
merged 5 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
});
Loading