mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
misc: finalized config files
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import opentelemetry from "@opentelemetry/api";
|
||||
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
|
||||
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-proto";
|
||||
import { PrometheusExporter } from "@opentelemetry/exporter-prometheus";
|
||||
import { registerInstrumentations } from "@opentelemetry/instrumentation";
|
||||
import { Resource } from "@opentelemetry/resources";
|
||||
import { AggregationTemporality, MeterProvider, PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
|
||||
import { SEMRESATTRS_SERVICE_NAME, SEMRESATTRS_SERVICE_VERSION } from "@opentelemetry/semantic-conventions";
|
||||
|
||||
export const initTelemetry = (exportURL: string) => {
|
||||
export const initTelemetry = async ({ otlpURL }: { otlpURL?: string }) => {
|
||||
const resource = Resource.default().merge(
|
||||
new Resource({
|
||||
[SEMRESATTRS_SERVICE_NAME]: "infisical-server",
|
||||
@@ -14,22 +15,30 @@ export const initTelemetry = (exportURL: string) => {
|
||||
})
|
||||
);
|
||||
|
||||
const metricExporter = new OTLPMetricExporter({
|
||||
url: `${exportURL}/v1/metrics`,
|
||||
temporalityPreference: AggregationTemporality.DELTA
|
||||
});
|
||||
const metricReaders = [];
|
||||
if (otlpURL) {
|
||||
const otlpExporter = new OTLPMetricExporter({
|
||||
url: `${otlpURL}/v1/metrics`,
|
||||
temporalityPreference: AggregationTemporality.DELTA
|
||||
});
|
||||
|
||||
const metricReader = new PeriodicExportingMetricReader({
|
||||
exporter: metricExporter,
|
||||
exportIntervalMillis: 30000
|
||||
});
|
||||
metricReaders.push(
|
||||
new PeriodicExportingMetricReader({
|
||||
exporter: otlpExporter,
|
||||
exportIntervalMillis: 30000
|
||||
})
|
||||
);
|
||||
} else {
|
||||
const promExporter = new PrometheusExporter();
|
||||
metricReaders.push(promExporter);
|
||||
}
|
||||
|
||||
const myServiceMeterProvider = new MeterProvider({
|
||||
const meterProvider = new MeterProvider({
|
||||
resource,
|
||||
readers: [metricReader]
|
||||
readers: metricReaders
|
||||
});
|
||||
|
||||
opentelemetry.metrics.setGlobalMeterProvider(myServiceMeterProvider);
|
||||
opentelemetry.metrics.setGlobalMeterProvider(meterProvider);
|
||||
|
||||
registerInstrumentations({
|
||||
instrumentations: [getNodeAutoInstrumentations()]
|
||||
|
||||
Reference in New Issue
Block a user