Socket
Socket
Sign inDemoInstall

@opentelemetry/exporter-metrics-otlp-http

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/exporter-metrics-otlp-http - npm Package Compare versions

Comparing version 0.33.0 to 0.34.0

26

build/esm/OTLPMetricExporterBase.js

@@ -52,4 +52,5 @@ /*

};
import { getEnv } from '@opentelemetry/core';
import { AggregationTemporality, InstrumentType } from '@opentelemetry/sdk-metrics';
import { defaultOptions } from './OTLPMetricExporterOptions';
import { diag } from '@opentelemetry/api';
export var CumulativeTemporalitySelector = function () { return AggregationTemporality.CUMULATIVE; };

@@ -68,13 +69,28 @@ export var DeltaTemporalitySelector = function (instrumentType) {

};
function chooseTemporalitySelector(temporalityPreference) {
if (temporalityPreference === AggregationTemporality.DELTA) {
function chooseTemporalitySelectorFromEnvironment() {
var env = getEnv();
var configuredTemporality = env.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE.trim().toLowerCase();
if (configuredTemporality === 'cumulative') {
return CumulativeTemporalitySelector;
}
if (configuredTemporality === 'delta') {
return DeltaTemporalitySelector;
}
diag.warn("OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '" + env.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE + "', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead.");
return CumulativeTemporalitySelector;
}
function chooseTemporalitySelector(temporalityPreference) {
// Directly passed preference has priority.
if (temporalityPreference != null) {
if (temporalityPreference === AggregationTemporality.DELTA) {
return DeltaTemporalitySelector;
}
return CumulativeTemporalitySelector;
}
return chooseTemporalitySelectorFromEnvironment();
}
var OTLPMetricExporterBase = /** @class */ (function () {
function OTLPMetricExporterBase(exporter, config) {
if (config === void 0) { config = defaultOptions; }
this._otlpExporter = exporter;
this._aggregationTemporalitySelector = chooseTemporalitySelector(config.temporalityPreference);
this._aggregationTemporalitySelector = chooseTemporalitySelector(config === null || config === void 0 ? void 0 : config.temporalityPreference);
}

@@ -81,0 +97,0 @@ OTLPMetricExporterBase.prototype.export = function (metrics, resultCallback) {

4

build/esm/OTLPMetricExporterOptions.d.ts

@@ -6,6 +6,2 @@ import { AggregationTemporality } from '@opentelemetry/sdk-metrics';

}
export declare const defaultExporterTemporality = AggregationTemporality.CUMULATIVE;
export declare const defaultOptions: {
temporalityPreference: AggregationTemporality;
};
//# sourceMappingURL=OTLPMetricExporterOptions.d.ts.map

@@ -16,5 +16,3 @@ /*

*/
import { AggregationTemporality } from '@opentelemetry/sdk-metrics';
export var defaultExporterTemporality = AggregationTemporality.CUMULATIVE;
export var defaultOptions = { temporalityPreference: defaultExporterTemporality };
export {};
//# sourceMappingURL=OTLPMetricExporterOptions.js.map

@@ -32,3 +32,2 @@ /*

import { baggageUtils, getEnv } from '@opentelemetry/core';
import { defaultOptions } from '../../OTLPMetricExporterOptions';
import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';

@@ -42,3 +41,2 @@ import { OTLPExporterBrowserBase, appendResourcePathToUrl, appendRootPathToUrlIfNeeded } from '@opentelemetry/otlp-exporter-base';

function OTLPExporterBrowserProxy(config) {
if (config === void 0) { config = defaultOptions; }
var _this = _super.call(this, config) || this;

@@ -52,3 +50,3 @@ _this._headers = Object.assign(_this._headers, baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS));

: getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
? appendRootPathToUrlIfNeeded(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
? appendRootPathToUrlIfNeeded(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT)
: getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0

@@ -69,3 +67,2 @@ ? appendResourcePathToUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)

function OTLPMetricExporter(config) {
if (config === void 0) { config = defaultOptions; }
return _super.call(this, new OTLPExporterBrowserProxy(config), config) || this;

@@ -72,0 +69,0 @@ }

@@ -32,3 +32,2 @@ /*

import { getEnv, baggageUtils } from '@opentelemetry/core';
import { defaultOptions } from '../../OTLPMetricExporterOptions';
import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';

@@ -42,3 +41,2 @@ import { OTLPExporterNodeBase, appendResourcePathToUrl, appendRootPathToUrlIfNeeded } from '@opentelemetry/otlp-exporter-base';

function OTLPExporterNodeProxy(config) {
if (config === void 0) { config = defaultOptions; }
var _this = _super.call(this, config) || this;

@@ -55,3 +53,3 @@ _this.headers = Object.assign(_this.headers, baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS));

: getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
? appendRootPathToUrlIfNeeded(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
? appendRootPathToUrlIfNeeded(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT)
: getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0

@@ -69,3 +67,2 @@ ? appendResourcePathToUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)

function OTLPMetricExporter(config) {
if (config === void 0) { config = defaultOptions; }
return _super.call(this, new OTLPExporterNodeProxy(config), config) || this;

@@ -72,0 +69,0 @@ }

@@ -1,2 +0,2 @@

export declare const VERSION = "0.33.0";
export declare const VERSION = "0.34.0";
//# sourceMappingURL=version.d.ts.map

@@ -17,3 +17,3 @@ /*

// this is autogenerated file, see scripts/version-update.js
export var VERSION = '0.33.0';
export var VERSION = '0.34.0';
//# sourceMappingURL=version.js.map

@@ -16,4 +16,5 @@ /*

*/
import { getEnv } from '@opentelemetry/core';
import { AggregationTemporality, InstrumentType } from '@opentelemetry/sdk-metrics';
import { defaultOptions } from './OTLPMetricExporterOptions';
import { diag } from '@opentelemetry/api';
export const CumulativeTemporalitySelector = () => AggregationTemporality.CUMULATIVE;

@@ -32,12 +33,28 @@ export const DeltaTemporalitySelector = (instrumentType) => {

};
function chooseTemporalitySelector(temporalityPreference) {
if (temporalityPreference === AggregationTemporality.DELTA) {
function chooseTemporalitySelectorFromEnvironment() {
const env = getEnv();
const configuredTemporality = env.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE.trim().toLowerCase();
if (configuredTemporality === 'cumulative') {
return CumulativeTemporalitySelector;
}
if (configuredTemporality === 'delta') {
return DeltaTemporalitySelector;
}
diag.warn(`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '${env.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE}', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead.`);
return CumulativeTemporalitySelector;
}
function chooseTemporalitySelector(temporalityPreference) {
// Directly passed preference has priority.
if (temporalityPreference != null) {
if (temporalityPreference === AggregationTemporality.DELTA) {
return DeltaTemporalitySelector;
}
return CumulativeTemporalitySelector;
}
return chooseTemporalitySelectorFromEnvironment();
}
export class OTLPMetricExporterBase {
constructor(exporter, config = defaultOptions) {
constructor(exporter, config) {
this._otlpExporter = exporter;
this._aggregationTemporalitySelector = chooseTemporalitySelector(config.temporalityPreference);
this._aggregationTemporalitySelector = chooseTemporalitySelector(config === null || config === void 0 ? void 0 : config.temporalityPreference);
}

@@ -44,0 +61,0 @@ export(metrics, resultCallback) {

@@ -6,6 +6,2 @@ import { AggregationTemporality } from '@opentelemetry/sdk-metrics';

}
export declare const defaultExporterTemporality = AggregationTemporality.CUMULATIVE;
export declare const defaultOptions: {
temporalityPreference: AggregationTemporality;
};
//# sourceMappingURL=OTLPMetricExporterOptions.d.ts.map

@@ -16,5 +16,3 @@ /*

*/
import { AggregationTemporality } from '@opentelemetry/sdk-metrics';
export const defaultExporterTemporality = AggregationTemporality.CUMULATIVE;
export const defaultOptions = { temporalityPreference: defaultExporterTemporality };
export {};
//# sourceMappingURL=OTLPMetricExporterOptions.js.map

@@ -17,3 +17,2 @@ /*

import { baggageUtils, getEnv } from '@opentelemetry/core';
import { defaultOptions } from '../../OTLPMetricExporterOptions';
import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';

@@ -25,3 +24,3 @@ import { OTLPExporterBrowserBase, appendResourcePathToUrl, appendRootPathToUrlIfNeeded } from '@opentelemetry/otlp-exporter-base';

class OTLPExporterBrowserProxy extends OTLPExporterBrowserBase {
constructor(config = defaultOptions) {
constructor(config) {
super(config);

@@ -34,3 +33,3 @@ this._headers = Object.assign(this._headers, baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS));

: getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
? appendRootPathToUrlIfNeeded(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
? appendRootPathToUrlIfNeeded(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT)
: getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0

@@ -48,3 +47,3 @@ ? appendResourcePathToUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)

export class OTLPMetricExporter extends OTLPMetricExporterBase {
constructor(config = defaultOptions) {
constructor(config) {
super(new OTLPExporterBrowserProxy(config), config);

@@ -51,0 +50,0 @@ }

@@ -17,3 +17,2 @@ /*

import { getEnv, baggageUtils } from '@opentelemetry/core';
import { defaultOptions } from '../../OTLPMetricExporterOptions';
import { OTLPMetricExporterBase } from '../../OTLPMetricExporterBase';

@@ -25,3 +24,3 @@ import { OTLPExporterNodeBase, appendResourcePathToUrl, appendRootPathToUrlIfNeeded } from '@opentelemetry/otlp-exporter-base';

class OTLPExporterNodeProxy extends OTLPExporterNodeBase {
constructor(config = defaultOptions) {
constructor(config) {
super(config);

@@ -37,3 +36,3 @@ this.headers = Object.assign(this.headers, baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS));

: getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
? appendRootPathToUrlIfNeeded(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
? appendRootPathToUrlIfNeeded(getEnv().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT)
: getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0

@@ -48,3 +47,3 @@ ? appendResourcePathToUrl(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)

export class OTLPMetricExporter extends OTLPMetricExporterBase {
constructor(config = defaultOptions) {
constructor(config) {
super(new OTLPExporterNodeProxy(config), config);

@@ -51,0 +50,0 @@ }

@@ -1,2 +0,2 @@

export declare const VERSION = "0.33.0";
export declare const VERSION = "0.34.0";
//# sourceMappingURL=version.d.ts.map

@@ -17,3 +17,3 @@ /*

// this is autogenerated file, see scripts/version-update.js
export const VERSION = '0.33.0';
export const VERSION = '0.34.0';
//# sourceMappingURL=version.js.map

@@ -19,4 +19,5 @@ "use strict";

exports.OTLPMetricExporterBase = exports.DeltaTemporalitySelector = exports.CumulativeTemporalitySelector = void 0;
const core_1 = require("@opentelemetry/core");
const sdk_metrics_1 = require("@opentelemetry/sdk-metrics");
const OTLPMetricExporterOptions_1 = require("./OTLPMetricExporterOptions");
const api_1 = require("@opentelemetry/api");
const CumulativeTemporalitySelector = () => sdk_metrics_1.AggregationTemporality.CUMULATIVE;

@@ -37,12 +38,28 @@ exports.CumulativeTemporalitySelector = CumulativeTemporalitySelector;

exports.DeltaTemporalitySelector = DeltaTemporalitySelector;
function chooseTemporalitySelector(temporalityPreference) {
if (temporalityPreference === sdk_metrics_1.AggregationTemporality.DELTA) {
function chooseTemporalitySelectorFromEnvironment() {
const env = (0, core_1.getEnv)();
const configuredTemporality = env.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE.trim().toLowerCase();
if (configuredTemporality === 'cumulative') {
return exports.CumulativeTemporalitySelector;
}
if (configuredTemporality === 'delta') {
return exports.DeltaTemporalitySelector;
}
api_1.diag.warn(`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE is set to '${env.OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE}', but only 'cumulative' and 'delta' are allowed. Using default ('cumulative') instead.`);
return exports.CumulativeTemporalitySelector;
}
function chooseTemporalitySelector(temporalityPreference) {
// Directly passed preference has priority.
if (temporalityPreference != null) {
if (temporalityPreference === sdk_metrics_1.AggregationTemporality.DELTA) {
return exports.DeltaTemporalitySelector;
}
return exports.CumulativeTemporalitySelector;
}
return chooseTemporalitySelectorFromEnvironment();
}
class OTLPMetricExporterBase {
constructor(exporter, config = OTLPMetricExporterOptions_1.defaultOptions) {
constructor(exporter, config) {
this._otlpExporter = exporter;
this._aggregationTemporalitySelector = chooseTemporalitySelector(config.temporalityPreference);
this._aggregationTemporalitySelector = chooseTemporalitySelector(config === null || config === void 0 ? void 0 : config.temporalityPreference);
}

@@ -49,0 +66,0 @@ export(metrics, resultCallback) {

@@ -6,6 +6,2 @@ import { AggregationTemporality } from '@opentelemetry/sdk-metrics';

}
export declare const defaultExporterTemporality = AggregationTemporality.CUMULATIVE;
export declare const defaultOptions: {
temporalityPreference: AggregationTemporality;
};
//# sourceMappingURL=OTLPMetricExporterOptions.d.ts.map

@@ -18,6 +18,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultOptions = exports.defaultExporterTemporality = void 0;
const sdk_metrics_1 = require("@opentelemetry/sdk-metrics");
exports.defaultExporterTemporality = sdk_metrics_1.AggregationTemporality.CUMULATIVE;
exports.defaultOptions = { temporalityPreference: exports.defaultExporterTemporality };
//# sourceMappingURL=OTLPMetricExporterOptions.js.map

@@ -20,3 +20,2 @@ "use strict";

const core_1 = require("@opentelemetry/core");
const OTLPMetricExporterOptions_1 = require("../../OTLPMetricExporterOptions");
const OTLPMetricExporterBase_1 = require("../../OTLPMetricExporterBase");

@@ -28,3 +27,3 @@ const otlp_exporter_base_1 = require("@opentelemetry/otlp-exporter-base");

class OTLPExporterBrowserProxy extends otlp_exporter_base_1.OTLPExporterBrowserBase {
constructor(config = OTLPMetricExporterOptions_1.defaultOptions) {
constructor(config) {
super(config);

@@ -37,3 +36,3 @@ this._headers = Object.assign(this._headers, core_1.baggageUtils.parseKeyPairsIntoRecord((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_METRICS_HEADERS));

: (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
? (0, otlp_exporter_base_1.appendRootPathToUrlIfNeeded)((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
? (0, otlp_exporter_base_1.appendRootPathToUrlIfNeeded)((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT)
: (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0

@@ -51,3 +50,3 @@ ? (0, otlp_exporter_base_1.appendResourcePathToUrl)((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)

class OTLPMetricExporter extends OTLPMetricExporterBase_1.OTLPMetricExporterBase {
constructor(config = OTLPMetricExporterOptions_1.defaultOptions) {
constructor(config) {
super(new OTLPExporterBrowserProxy(config), config);

@@ -54,0 +53,0 @@ }

@@ -20,3 +20,2 @@ "use strict";

const core_1 = require("@opentelemetry/core");
const OTLPMetricExporterOptions_1 = require("../../OTLPMetricExporterOptions");
const OTLPMetricExporterBase_1 = require("../../OTLPMetricExporterBase");

@@ -28,3 +27,3 @@ const otlp_exporter_base_1 = require("@opentelemetry/otlp-exporter-base");

class OTLPExporterNodeProxy extends otlp_exporter_base_1.OTLPExporterNodeBase {
constructor(config = OTLPMetricExporterOptions_1.defaultOptions) {
constructor(config) {
super(config);

@@ -40,3 +39,3 @@ this.headers = Object.assign(this.headers, core_1.baggageUtils.parseKeyPairsIntoRecord((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_METRICS_HEADERS));

: (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT.length > 0
? (0, otlp_exporter_base_1.appendRootPathToUrlIfNeeded)((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
? (0, otlp_exporter_base_1.appendRootPathToUrlIfNeeded)((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_METRICS_ENDPOINT)
: (0, core_1.getEnv)().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0

@@ -51,3 +50,3 @@ ? (0, otlp_exporter_base_1.appendResourcePathToUrl)((0, core_1.getEnv)().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)

class OTLPMetricExporter extends OTLPMetricExporterBase_1.OTLPMetricExporterBase {
constructor(config = OTLPMetricExporterOptions_1.defaultOptions) {
constructor(config) {
super(new OTLPExporterNodeProxy(config), config);

@@ -54,0 +53,0 @@ }

@@ -1,2 +0,2 @@

export declare const VERSION = "0.33.0";
export declare const VERSION = "0.34.0";
//# sourceMappingURL=version.d.ts.map

@@ -20,3 +20,3 @@ "use strict";

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.33.0';
exports.VERSION = '0.34.0';
//# sourceMappingURL=version.js.map
{
"name": "@opentelemetry/exporter-metrics-otlp-http",
"version": "0.33.0",
"version": "0.34.0",
"description": "OpenTelemetry Collector Metrics Exporter allows user to send collected metrics to the OpenTelemetry Collector",

@@ -67,4 +67,4 @@ "main": "build/src/index.js",

"@babel/core": "7.16.0",
"@opentelemetry/api": "^1.0.0",
"@types/mocha": "9.1.1",
"@opentelemetry/api": "^1.3.0",
"@types/mocha": "10.0.0",
"@types/node": "18.6.5",

@@ -95,14 +95,14 @@ "@types/sinon": "10.0.13",

"peerDependencies": {
"@opentelemetry/api": "^1.0.0"
"@opentelemetry/api": "^1.3.0"
},
"dependencies": {
"@opentelemetry/api-metrics": "0.33.0",
"@opentelemetry/core": "1.7.0",
"@opentelemetry/otlp-exporter-base": "0.33.0",
"@opentelemetry/otlp-transformer": "0.33.0",
"@opentelemetry/resources": "1.7.0",
"@opentelemetry/sdk-metrics": "0.33.0"
"@opentelemetry/core": "1.8.0",
"@opentelemetry/otlp-exporter-base": "0.34.0",
"@opentelemetry/otlp-transformer": "0.34.0",
"@opentelemetry/resources": "1.8.0",
"@opentelemetry/sdk-metrics": "1.8.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-exporter-metrics-otlp-http",
"gitHead": "ad88c3d9aa0100fe259b93f4b660e84417b757ac"
"sideEffects": false,
"gitHead": "7972edf6659fb6e0d5928a5cf7a35f26683e168f"
}

@@ -20,4 +20,6 @@ # OpenTelemetry Collector Metrics Exporter for web and node

The OpenTelemetry Collector Metrics Exporter does not have a service name configuration.
In order to set the service name, use the `service.name` resource attribute as prescribed in the [OpenTelemetry Resource Semantic Conventions][semconv-resource-service-name].
To see sample code and documentation for the traces exporter, visit the [Collector Trace Exporter for web and node][trace-exporter-url].
In order to set the service name, use the `service.name` resource attribute as prescribed in
the [OpenTelemetry Resource Semantic Conventions][semconv-resource-service-name].
To see sample code and documentation for the traces exporter, visit
the [Collector Trace Exporter for web and node][trace-exporter-url].

@@ -31,2 +33,3 @@ ## Metrics in Web

import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http';
const collectorOptions = {

@@ -37,3 +40,3 @@ url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:4318/v1/metrics

};
const exporter = new OTLPMetricExporter(collectorOptions);
const metricExporter = new OTLPMetricExporter(collectorOptions);
const meterProvider = new MeterProvider({});

@@ -56,3 +59,3 @@

const { MeterProvider, PeriodicExportingMetricReader } = require('@opentelemetry/sdk-metrics');
const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-http');
const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-http');
const collectorOptions = {

@@ -77,32 +80,15 @@ url: '<opentelemetry-collector-url>', // url is optional and can be omitted - default is http://localhost:4318/v1/metrics

## GRPC
## Environment Variable Configuration
For exporting metrics with GRPC please check [exporter-metrics-otlp-grpc][npm-url-grpc]
In addition to settings passed to the constructor, the exporter also supports configuration via environment variables:
## PROTOBUF
| Environment variable | Description |
|---------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| OTEL_EXPORTER_OTLP_ENDPOINT | The endpoint to send metrics to. This will also be used for the traces exporter if `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` is not configured. By default `http://localhost:4318` will be used. `/v1/metrics` will be automatically appended to configured values. |
| OTEL_EXPORTER_OTLP_METRICS_ENDPOINT | The endpoint to send metrics to. By default `https://localhost:4318/v1/metrics` will be used. `v1/metrics` will not be appended automatically and has to be added explicitly. |
| OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE | The exporters aggregation temporality preference. Valid values are `cumulative`, and `delta`. `cumulative` selects cumulative temporality for all instrument kinds. `delta` selects delta aggregation temporality for Counter, Asynchronous Counter and Histogram instrument kinds, and selects cumulative aggregation for UpDownCounter and Asynchronous UpDownCounter instrument kinds. By default `cumulative` is used. |
For exporting metrics with PROTOBUF please check [exporter-metrics-otlp-proto][npm-url-proto]
> Settings configured programmatically take precedence over environment variables. Per-signal environment variables take
> precedence over non-per-signal environment variables.
## Configuration options as environment variables
Instead of providing options to `OTLPMetricExporter` and `OTLPTraceExporter` explicitly, environment variables may be provided instead.
```sh
OTEL_EXPORTER_OTLP_ENDPOINT=https://localhost:4318
# this will automatically append the version and signal path
# e.g. https://localhost:4318/v1/traces for `OTLPTraceExporter` and https://localhost:4318/v1/metrics for `OTLPMetricExporter`
```
If the trace and metric exporter endpoints have different providers, the env var for per-signal endpoints are available to use
```sh
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://trace-service:4318/v1/traces
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=https://metric-service:4318/v1/metrics
# version and signal needs to be explicit
```
> The per-signal endpoints take precedence and overrides `OTEL_EXPORTER_OTLP_ENDPOINT`
For more details, see [OpenTelemetry Specification on Protocol Exporter][opentelemetry-spec-protocol-exporter].
## Running opentelemetry-collector locally to see the metrics

@@ -118,2 +104,4 @@

- For help or feedback on this project, join us in [GitHub Discussions][discussions-url]
- For exporting metrics via gRPC please check [exporter-metrics-otlp-grpc][npm-url-grpc]
- For exporting metrics via protobuf please check [exporter-metrics-otlp-proto][npm-url-proto]

@@ -120,0 +108,0 @@ ## License

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc