Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc authored Jul 14, 2023
2 parents f8870b5 + 65483a4 commit a93182c
Show file tree
Hide file tree
Showing 53 changed files with 261 additions and 87 deletions.
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"karma-mocha-webworker": "1.3.0",
"karma-spec-reporter": "0.0.36",
"karma-webpack": "4.0.2",
"lerna": "7.1.1",
"lerna": "7.1.3",
"memfs": "3.5.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
Expand Down
8 changes: 4 additions & 4 deletions doc/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ _Metrics API Reference: <https://open-telemetry.github.io/opentelemetry-js/class
- [Customizing the metric attributes of instrument](#customizing-the-metric-attributes-of-instrument)
- [Exporting measurements](#exporting-measurements)
- [Exporting measurements to Prometheus](#exporting-measurements-to-prometheus)
- [Exporting measurements to Opentelemetry Protocol](#exporting-measurements-to-opentelemetry-protocol)
- [Exporting measurements to OpenTelemetry Protocol](#exporting-measurements-to-opentelemetry-protocol)

## Getting Started

Expand Down Expand Up @@ -266,7 +266,7 @@ Most of the time, instruments will be used to measure operations in your applica

```typescript
async function myTask() {
const histogram = meter.createHistogram("taks.duration");
const histogram = meter.createHistogram("task.duration");
const startTime = new Date().getTime()
try {
// Wait for five seconds before continuing code execution
Expand Down Expand Up @@ -479,7 +479,7 @@ new View({

After you have instrumented your application with metrics, you also need to make
sure that the metrics get collected by your metrics backend. The most common formats
that are used are Prometheus and OLTP.
that are used are Prometheus and OTLP.

The latter is the [OpenTelemetry protocol format](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/otlp.md)
which is supported by the OpenTelemetry Collector. The former is based on the [OpenMetrics
Expand Down Expand Up @@ -528,7 +528,7 @@ at: <https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/e
## Exporting measurements to OpenTelemetry Protocol

OpenTelemetry JavaScript comes with three different kinds of exporters that export
the OTLP protocol, a) [over HTTP](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-exporter-metrics-otlp-http), b) [over GRPC](https://www.npmjs.com/package/@opentelemetry/exporter-metrics-otlp-grpc), c) [over Protofbuf](https://www.npmjs.com/package/@opentelemetry/exporter-metrics-otlp-proto).
the OTLP protocol, a) [over HTTP](https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/opentelemetry-exporter-metrics-otlp-http), b) [over GRPC](https://www.npmjs.com/package/@opentelemetry/exporter-metrics-otlp-grpc), c) [over Protobuf](https://www.npmjs.com/package/@opentelemetry/exporter-metrics-otlp-proto).

The example below shows how you can configure OpenTelemetry JavaScript to use
the OTLP exporter using http/protobuf.
Expand Down
44 changes: 37 additions & 7 deletions examples/otlp-exporter-node/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,50 @@ const { DiagConsoleLogger, DiagLogLevel, diag } = require('@opentelemetry/api');
const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-http');
// const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-grpc');
// const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-proto');
const { MeterProvider, PeriodicExportingMetricReader } = require('@opentelemetry/sdk-metrics');
// const { ConsoleMetricExporter } = require('@opentelemetry/sdk-metrics');
const {
ExponentialHistogramAggregation,
MeterProvider,
PeriodicExportingMetricReader,
View,
} = require('@opentelemetry/sdk-metrics');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const {
SemanticResourceAttributes,
} = require('@opentelemetry/semantic-conventions');

// Optional and only needed to see the internal diagnostic logging (during development)
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);

const metricExporter = new OTLPMetricExporter({});
const metricExporter = new OTLPMetricExporter({
// headers: {
// foo: 'bar'
// },
});

// Define view for the exponential histogram metric
const expHistogramView = new View({
aggregation: new ExponentialHistogramAggregation(),
// Note, the instrumentName is the same as the name that has been passed for
// the Meter#createHistogram function for exponentialHistogram.
instrumentName: 'test_exponential_histogram',
});

// Create an instance of the metric provider
const meterProvider = new MeterProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'basic-metric-service',
}),
views: [expHistogramView],
});

meterProvider.addMetricReader(new PeriodicExportingMetricReader({
exporter: metricExporter,
exportIntervalMillis: 1000,
}));
meterProvider.addMetricReader(
new PeriodicExportingMetricReader({
exporter: metricExporter,
// exporter: new ConsoleMetricExporter(),
exportIntervalMillis: 1000,
})
);

const meter = meterProvider.getMeter('example-exporter-collector');

Expand All @@ -38,10 +63,15 @@ const histogram = meter.createHistogram('test_histogram', {
description: 'Example of a Histogram',
});

const exponentialHistogram = meter.createHistogram('test_exponential_histogram', {
description: 'Example of an ExponentialHistogram',
});

const attributes = { pid: process.pid, environment: 'staging' };

setInterval(() => {
requestCounter.add(1, attributes);
upDownCounter.add(Math.random() > 0.5 ? 1 : -1, attributes);
histogram.record(Math.random(), attributes);
exponentialHistogram.record(Math.random(), attributes);
}, 1000);
6 changes: 6 additions & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ All notable changes to experimental packages in this project will be documented

## Unreleased

### :books: (Refine Doc)

* docs(sdk-metrics): add example of exponential histogram metric [#3855](https://github.com/open-telemetry/opentelemetry-js/pull/3855) @JamieDanielson

### :boom: Breaking Change

### :rocket: (Enhancement)

* feat(sdk-node): logs support added [#3969](https://github.com/open-telemetry/opentelemetry-js/pull/3969) @psk001

### :bug: (Bug Fix)

### :books: (Refine Doc)
Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/api-events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.36",
"karma-webpack": "4.0.2",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"ts-loader": "8.4.0",
Expand Down
14 changes: 10 additions & 4 deletions experimental/packages/api-logs/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# OpenTelemetry API for JavaScript
# OpenTelemetry Logs Bridge API for JavaScript

[![NPM Published Version][npm-img]][npm-url]
[![Apache License][license-image]][license-image]

This package provides everything needed to interact with the unstable OpenTelemetry Logs API, including all TypeScript interfaces, enums, and no-op implementations. It is intended for use both on the server and in the browser.
**Note: This is an experimental package under active development. New releases may include breaking changes.**

## Beta Software - Use at your own risk
This package provides everything needed to interact with the unstable OpenTelemetry Logs Bridge API, including all TypeScript interfaces, enums, and no-op implementations. It is intended for use both on the server and in the browser.

The logs API is considered alpha software and there is no guarantee of stability or long-term support. When the API is stabilized, it will be made available and supported long-term in the `@opentelemetry/api` package and this package will be deprecated.
**Note: This module defines a log backend API. The API is not intended to be called by application developers directly.
It is provided for logging library authors to build log appenders, which use this API to bridge between existing
logging libraries and the OpenTelemetry log data model.**

## Alpha Software - Use at your own risk

The Logs Bridge API is considered alpha software and there is no guarantee of stability or long-term support. When the API is stabilized, it will be made available and supported long-term in the `@opentelemetry/api` package and this package will be deprecated.

## Quick Start

Expand Down
2 changes: 1 addition & 1 deletion experimental/packages/api-logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.36",
"karma-webpack": "4.0.2",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"ts-loader": "8.4.0",
Expand Down
4 changes: 2 additions & 2 deletions experimental/packages/exporter-logs-otlp-grpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.8",
"@babel/core": "7.22.9",
"@grpc/proto-loader": "^0.7.3",
"@opentelemetry/api": "1.4.1",
"@opentelemetry/api-logs": "0.41.0",
Expand All @@ -60,7 +60,7 @@
"codecov": "3.8.3",
"cpx": "1.5.0",
"cross-var": "1.1.0",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"sinon": "15.1.2",
Expand Down
4 changes: 2 additions & 2 deletions experimental/packages/exporter-logs-otlp-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
],
"sideEffects": false,
"devDependencies": {
"@babel/core": "7.22.8",
"@babel/core": "7.22.9",
"@opentelemetry/api-logs": "0.41.0",
"@opentelemetry/resources": "1.15.0",
"@types/mocha": "10.0.1",
Expand All @@ -89,7 +89,7 @@
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.36",
"karma-webpack": "4.0.2",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"sinon": "15.1.2",
Expand Down
4 changes: 2 additions & 2 deletions experimental/packages/exporter-logs-otlp-proto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.8",
"@babel/core": "7.22.9",
"@opentelemetry/api": "1.4.1",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
Expand All @@ -78,7 +78,7 @@
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.36",
"karma-webpack": "4.0.2",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"sinon": "15.1.2",
Expand Down
4 changes: 2 additions & 2 deletions experimental/packages/exporter-trace-otlp-grpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.8",
"@babel/core": "7.22.9",
"@grpc/proto-loader": "^0.7.3",
"@opentelemetry/api": "1.4.1",
"@opentelemetry/otlp-exporter-base": "0.41.0",
Expand All @@ -57,7 +57,7 @@
"codecov": "3.8.3",
"cpx": "1.5.0",
"cross-var": "1.1.0",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"sinon": "15.1.2",
Expand Down
4 changes: 2 additions & 2 deletions experimental/packages/exporter-trace-otlp-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.8",
"@babel/core": "7.22.9",
"@opentelemetry/api": "1.4.1",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
Expand All @@ -80,7 +80,7 @@
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.36",
"karma-webpack": "4.0.2",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"sinon": "15.1.2",
Expand Down
4 changes: 2 additions & 2 deletions experimental/packages/exporter-trace-otlp-proto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.8",
"@babel/core": "7.22.9",
"@opentelemetry/api": "1.4.1",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
Expand All @@ -77,7 +77,7 @@
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.36",
"karma-webpack": "4.0.2",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"sinon": "15.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.8",
"@babel/core": "7.22.9",
"@opentelemetry/api": "1.4.1",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
Expand All @@ -67,7 +67,7 @@
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.36",
"karma-webpack": "4.0.2",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"sinon": "15.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.8",
"@babel/core": "7.22.9",
"@grpc/proto-loader": "^0.7.3",
"@opentelemetry/api": "1.4.1",
"@types/mocha": "10.0.1",
Expand All @@ -56,7 +56,7 @@
"codecov": "3.8.3",
"cpx": "1.5.0",
"cross-var": "1.1.0",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"sinon": "15.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.8",
"@babel/core": "7.22.9",
"@opentelemetry/api": "1.4.1",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
Expand All @@ -80,7 +80,7 @@
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.36",
"karma-webpack": "4.0.2",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"sinon": "15.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.8",
"@babel/core": "7.22.9",
"@opentelemetry/api": "1.4.1",
"@types/mocha": "10.0.1",
"@types/node": "18.6.5",
"@types/sinon": "10.0.15",
"codecov": "3.8.3",
"cpx": "1.5.0",
"cross-var": "1.1.0",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"sinon": "15.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@types/sinon": "10.0.15",
"codecov": "3.8.3",
"cross-var": "1.1.0",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"sinon": "15.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"access": "public"
},
"devDependencies": {
"@babel/core": "7.22.8",
"@babel/core": "7.22.9",
"@opentelemetry/api": "1.4.1",
"@opentelemetry/context-zone": "1.15.0",
"@opentelemetry/propagator-b3": "1.15.0",
Expand All @@ -73,7 +73,7 @@
"karma-mocha": "2.0.1",
"karma-spec-reporter": "0.0.36",
"karma-webpack": "4.0.2",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"sinon": "15.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@
"@types/sinon": "10.0.15",
"codecov": "3.8.3",
"cross-var": "1.1.0",
"lerna": "7.1.1",
"lerna": "7.1.3",
"mocha": "10.2.0",
"nyc": "15.1.0",
"semver": "7.5.3",
"semver": "7.5.4",
"sinon": "15.1.2",
"ts-mocha": "10.0.0",
"typescript": "4.4.4"
Expand Down
Loading

0 comments on commit a93182c

Please sign in to comment.