@opentelemetry/exporter-prometheus
Advanced tools
Comparing version 0.31.0 to 0.32.0
/// <reference types="node" /> | ||
import { AggregationTemporality, MetricReader } from '@opentelemetry/sdk-metrics-base'; | ||
import { AggregationTemporality, MetricReader } from '@opentelemetry/sdk-metrics'; | ||
import { IncomingMessage, ServerResponse } from 'http'; | ||
@@ -4,0 +4,0 @@ import { ExporterConfig } from './export/types'; |
@@ -21,3 +21,3 @@ "use strict"; | ||
const core_1 = require("@opentelemetry/core"); | ||
const sdk_metrics_base_1 = require("@opentelemetry/sdk-metrics-base"); | ||
const sdk_metrics_1 = require("@opentelemetry/sdk-metrics"); | ||
const http_1 = require("http"); | ||
@@ -28,3 +28,3 @@ const PrometheusSerializer_1 = require("./PrometheusSerializer"); | ||
const NO_REGISTERED_METRICS = '# no registered metrics'; | ||
class PrometheusExporter extends sdk_metrics_base_1.MetricReader { | ||
class PrometheusExporter extends sdk_metrics_1.MetricReader { | ||
// This will be required when histogram is implemented. Leaving here so it is not forgotten | ||
@@ -111,3 +111,3 @@ // Histogram cannot have a attribute named 'le' | ||
selectAggregationTemporality() { | ||
return sdk_metrics_base_1.AggregationTemporality.CUMULATIVE; | ||
return sdk_metrics_1.AggregationTemporality.CUMULATIVE; | ||
} | ||
@@ -114,0 +114,0 @@ async onForceFlush() { |
@@ -1,2 +0,2 @@ | ||
import { ResourceMetrics } from '@opentelemetry/sdk-metrics-base'; | ||
import { ResourceMetrics } from '@opentelemetry/sdk-metrics'; | ||
export declare class PrometheusSerializer { | ||
@@ -3,0 +3,0 @@ private _prefix; |
@@ -20,3 +20,3 @@ "use strict"; | ||
const api_1 = require("@opentelemetry/api"); | ||
const sdk_metrics_base_1 = require("@opentelemetry/sdk-metrics-base"); | ||
const sdk_metrics_1 = require("@opentelemetry/sdk-metrics"); | ||
const core_1 = require("@opentelemetry/core"); | ||
@@ -71,3 +71,3 @@ function escapeString(str) { | ||
// Prometheus requires that metrics of the Counter kind have "_total" suffix | ||
if (!name.endsWith('_total') && type === sdk_metrics_base_1.InstrumentType.COUNTER) { | ||
if (!name.endsWith('_total') && type === sdk_metrics_1.InstrumentType.COUNTER) { | ||
name = name + '_total'; | ||
@@ -95,3 +95,3 @@ } | ||
switch (metricData.dataPointType) { | ||
case sdk_metrics_base_1.DataPointType.SUM: | ||
case sdk_metrics_1.DataPointType.SUM: | ||
if (metricData.isMonotonic) { | ||
@@ -101,5 +101,5 @@ return 'counter'; | ||
return 'gauge'; | ||
case sdk_metrics_base_1.DataPointType.GAUGE: | ||
case sdk_metrics_1.DataPointType.GAUGE: | ||
return 'gauge'; | ||
case sdk_metrics_base_1.DataPointType.HISTOGRAM: | ||
case sdk_metrics_1.DataPointType.HISTOGRAM: | ||
return 'histogram'; | ||
@@ -159,7 +159,8 @@ default: | ||
const help = `# HELP ${name} ${escapeString(metricData.descriptor.description || 'description missing')}`; | ||
const unit = metricData.descriptor.unit ? `\n# UNIT ${name} ${escapeString(metricData.descriptor.unit)}` : ''; | ||
const type = `# TYPE ${name} ${toPrometheusType(metricData)}`; | ||
let results = ''; | ||
switch (dataPointType) { | ||
case sdk_metrics_base_1.DataPointType.SUM: | ||
case sdk_metrics_base_1.DataPointType.GAUGE: { | ||
case sdk_metrics_1.DataPointType.SUM: | ||
case sdk_metrics_1.DataPointType.GAUGE: { | ||
results = metricData.dataPoints | ||
@@ -170,3 +171,3 @@ .map(it => this._serializeSingularDataPoint(name, metricData.descriptor.type, it)) | ||
} | ||
case sdk_metrics_base_1.DataPointType.HISTOGRAM: { | ||
case sdk_metrics_1.DataPointType.HISTOGRAM: { | ||
results = metricData.dataPoints | ||
@@ -181,3 +182,3 @@ .map(it => this._serializeHistogramDataPoint(name, metricData.descriptor.type, it)) | ||
} | ||
return `${help}\n${type}\n${results}`.trim(); | ||
return `${help}${unit}\n${type}\n${results}`.trim(); | ||
} | ||
@@ -184,0 +185,0 @@ _serializeSingularDataPoint(name, type, dataPoint) { |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.31.0"; | ||
export declare const VERSION = "0.32.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.31.0'; | ||
exports.VERSION = '0.32.0'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/exporter-prometheus", | ||
"version": "0.31.0", | ||
"version": "0.32.0", | ||
"description": "OpenTelemetry Exporter Prometheus provides a metrics endpoint for Prometheus", | ||
@@ -47,11 +47,11 @@ "main": "build/src/index.js", | ||
"@opentelemetry/api": "^1.0.0", | ||
"@types/mocha": "8.2.3", | ||
"@types/node": "14.17.33", | ||
"@types/sinon": "10.0.6", | ||
"@types/mocha": "9.1.1", | ||
"@types/node": "18.6.5", | ||
"@types/sinon": "10.0.13", | ||
"codecov": "3.8.3", | ||
"mocha": "7.2.0", | ||
"mocha": "10.0.0", | ||
"nyc": "15.1.0", | ||
"rimraf": "3.0.2", | ||
"sinon": "12.0.1", | ||
"ts-mocha": "9.0.2", | ||
"sinon": "14.0.0", | ||
"ts-mocha": "10.0.0", | ||
"typescript": "4.4.4" | ||
@@ -63,8 +63,8 @@ }, | ||
"dependencies": { | ||
"@opentelemetry/api-metrics": "0.31.0", | ||
"@opentelemetry/core": "1.5.0", | ||
"@opentelemetry/sdk-metrics-base": "0.31.0" | ||
"@opentelemetry/api-metrics": "0.32.0", | ||
"@opentelemetry/core": "1.6.0", | ||
"@opentelemetry/sdk-metrics": "0.32.0" | ||
}, | ||
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-exporter-prometheus", | ||
"gitHead": "776656b6e0cd0fc49a52b734702bc77110e483f1" | ||
"gitHead": "a5abee69119cc41d9d34f6beb5c1826eef1ac0dd" | ||
} |
@@ -6,3 +6,3 @@ # OpenTelemetry Prometheus Metric Exporter | ||
The OpenTelemetry Prometheus Metrics Exporter allows the user to send collected [OpenTelemetry Metrics](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-sdk-metrics-base) to Prometheus. | ||
The OpenTelemetry Prometheus Metrics Exporter allows the user to send collected [OpenTelemetry Metrics](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-sdk-metrics) to Prometheus. | ||
@@ -14,3 +14,3 @@ [Prometheus](https://prometheus.io/) is a monitoring system that collects metrics, by scraping exposed endpoints at regular intervals, evaluating rule expressions. It can also trigger alerts if certain conditions are met. For assistance setting up Prometheus, [Click here](https://opencensus.io/codelabs/prometheus/#0) for a guided codelab. | ||
```bash | ||
npm install --save @opentelemetry/sdk-metrics-base | ||
npm install --save @opentelemetry/sdk-metrics | ||
npm install --save @opentelemetry/exporter-prometheus | ||
@@ -25,3 +25,3 @@ ``` | ||
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus'); | ||
const { MeterProvider } = require('@opentelemetry/sdk-metrics-base'); | ||
const { MeterProvider } = require('@opentelemetry/sdk-metrics'); | ||
@@ -32,7 +32,6 @@ // Add your port and startServer to the Prometheus options | ||
// Register the exporter | ||
const meter = new MeterProvider({ | ||
exporter, | ||
interval: 1000, | ||
}).getMeter('example-prometheus'); | ||
// Creates MeterProvider and installs the exporter as a MetricReader | ||
const meterProvider = new MeterProvider(); | ||
meterProvider.addMetricReader(exporter); | ||
const meter = meterProvider.getMeter('example-prometheus'); | ||
@@ -39,0 +38,0 @@ // Now, start recording data |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68384
583
63
+ Added@opentelemetry/api@1.2.0(transitive)
+ Added@opentelemetry/api-metrics@0.32.0(transitive)
+ Added@opentelemetry/core@1.6.0(transitive)
+ Added@opentelemetry/resources@1.6.0(transitive)
+ Added@opentelemetry/sdk-metrics@0.32.0(transitive)
+ Added@opentelemetry/semantic-conventions@1.6.0(transitive)
- Removed@opentelemetry/api@1.1.0(transitive)
- Removed@opentelemetry/api-metrics@0.31.0(transitive)
- Removed@opentelemetry/core@1.5.0(transitive)
- Removed@opentelemetry/resources@1.5.0(transitive)
- Removed@opentelemetry/sdk-metrics-base@0.31.0(transitive)
- Removed@opentelemetry/semantic-conventions@1.5.0(transitive)
Updated@opentelemetry/core@1.6.0