Skip to content

Commit

Permalink
Merge branch 'main' into resource-attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarchaud authored Apr 30, 2022
2 parents 40081fc + 6436d85 commit 7447724
Show file tree
Hide file tree
Showing 89 changed files with 382 additions and 485 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
packages/*/package-lock.json
experimental/packages/*/node_modules
experimental/packages/*/package-lock.json
key: node-tests-${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('package.json', 'packages/*/package.json', 'experimental/packages/*/package.json') }}-04142022
key: node-tests-${{ runner.os }}-${{ matrix.node_version }}-${{ hashFiles('package.json', 'packages/*/package.json', 'experimental/packages/*/package.json') }}-04292022

- name: Bootstrap
run: |
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
packages/*/package-lock.json
experimental/packages/*/node_modules
experimental/packages/*/package-lock.json
key: browser-tests-${{ runner.os }}-${{ hashFiles('package.json', 'packages/*/package.json', 'experimental/packages/*/package.json') }}-04142022
key: browser-tests-${{ runner.os }}-${{ hashFiles('package.json', 'packages/*/package.json', 'experimental/packages/*/package.json') }}-04292022

- name: Bootstrap
run: |
Expand Down Expand Up @@ -112,7 +112,7 @@ jobs:
packages/*/package-lock.json
experimental/packages/*/node_modules
experimental/packages/*/package-lock.json
key: webworker-tests-${{ runner.os }}-${{ hashFiles('package.json', 'packages/*/package.json', 'experimental/packages/*/package.json') }}-04142022
key: webworker-tests-${{ runner.os }}-${{ hashFiles('package.json', 'packages/*/package.json', 'experimental/packages/*/package.json') }}-04292022

- name: Bootstrap
run: |
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file.

### :rocket: (Enhancement)

* feat(ConsoleSpanExporter): export span links [#2917](https://github.com/open-telemetry/opentelemetry-js/pull/2917) @trentm
* feat: warn when hooked module is already loaded [#2926](https://github.com/open-telemetry/opentelemetry-js/pull/2926) @nozik

### :bug: (Bug Fix)

### :books: (Refine Doc)
Expand Down Expand Up @@ -36,6 +39,7 @@ All notable changes to this project will be documented in this file.
* chore: require changelog entry to merge PR [#2847](https://github.com/open-telemetry/opentelemetry-js/pull/2847) @dyladan
* chore: remove peer API check [#2892](https://github.com/open-telemetry/opentelemetry-js/pull/2892) @dyladan
* chore: merge lerna subdirectories into a single monorepo [#2892](https://github.com/open-telemetry/opentelemetry-js/pull/2892) @dyladan
* chore: indent the code with eslint [#2923](https://github.com/open-telemetry/opentelemetry-js/pull/2923) @blumamir
* `opentelemetry-propagator-jaeger`
* [#2906](https://github.com/open-telemetry/opentelemetry-js/pull/2906) fix: support extract one digit '0' in jaeger traceFlag ([@shmilyoo](https://github.com/shmilyoo))

Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
"project": "./tsconfig.json"
},
rules: {
"indent": ["error", 2, { "SwitchCase": 1 }],
"no-trailing-spaces": "error",
"eol-last": "error",
"quotes": [2, "single", { "avoidEscape": true }],
Expand Down
Binary file removed examples/prometheus/images/prom-counter.png
Binary file not shown.
Binary file removed examples/prometheus/images/prom-updowncounter.png
Binary file not shown.
32 changes: 0 additions & 32 deletions examples/prometheus/index.js

This file was deleted.

7 changes: 7 additions & 0 deletions experimental/examples/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
"env": {
"mocha": true,
"node": true
},
...require('../../eslint.config.js')
}
File renamed without changes.
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions experimental/examples/prometheus/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict';

const { DiagConsoleLogger, DiagLogLevel, diag } = require('@opentelemetry/api');
const { MeterProvider } = require('@opentelemetry/sdk-metrics-base');
const { PrometheusExporter } = require('@opentelemetry/exporter-prometheus');

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

const { endpoint, port } = PrometheusExporter.DEFAULT_OPTIONS;

const exporter = new PrometheusExporter({}, () => {
console.log(
`prometheus scrape endpoint: http://localhost:${port}${endpoint}`,
);
});

// Creates MeterProvider and installs the exporter as a MetricReader
const meterProvider = new MeterProvider();
meterProvider.addMetricReader(exporter);
const meter = meterProvider.getMeter('example-prometheus');

// Creates metric instruments
const requestCounter = meter.createCounter('requests', {
description: 'Example of a Counter',
});

const upDownCounter = meter.createUpDownCounter('test_up_down_counter', {
description: 'Example of a UpDownCounter',
});

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

// Record metrics
setInterval(() => {
requestCounter.add(1, attributes);
upDownCounter.add(Math.random() > 0.5 ? 1 : -1, attributes);
}, 1000);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prometheus-example",
"version": "0.25.0",
"version": "0.28.0",
"description": "Example of using @opentelemetry/sdk-metrics-base and @opentelemetry/exporter-prometheus",
"main": "index.js",
"scripts": {
Expand All @@ -10,7 +10,7 @@
"license": "Apache-2.0",
"dependencies": {
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/exporter-prometheus": "0.25.0",
"@opentelemetry/sdk-metrics-base": "0.25.0"
"@opentelemetry/exporter-prometheus": "0.28.0",
"@opentelemetry/sdk-metrics-base": "0.28.0"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"rimraf": "3.0.2",
"sinon": "12.0.1",
"ts-loader": "8.3.0",
"ts-mocha": "8.0.0",
"ts-mocha": "9.0.2",
"typescript": "4.4.4"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ const testCollectorExporter = (params: TestParams) =>
);
const credentials = params.useTLS
? grpc.ServerCredentials.createSsl(
fs.readFileSync('./test/certs/ca.crt'),
[
{
cert_chain: fs.readFileSync('./test/certs/server.crt'),
private_key: fs.readFileSync('./test/certs/server.key'),
},
]
)
fs.readFileSync('./test/certs/ca.crt'),
[
{
cert_chain: fs.readFileSync('./test/certs/server.crt'),
private_key: fs.readFileSync('./test/certs/server.key'),
},
]
)
: grpc.ServerCredentials.createInsecure();
server.bindAsync(address, credentials, () => {
server.start();
Expand All @@ -120,10 +120,10 @@ const testCollectorExporter = (params: TestParams) =>
beforeEach(done => {
const credentials = params.useTLS
? grpc.credentials.createSsl(
fs.readFileSync('./test/certs/ca.crt'),
fs.readFileSync('./test/certs/client.key'),
fs.readFileSync('./test/certs/client.crt')
)
fs.readFileSync('./test/certs/ca.crt'),
fs.readFileSync('./test/certs/client.key'),
fs.readFileSync('./test/certs/client.crt')
)
: undefined;
collectorExporter = new OTLPTraceExporter({
url: 'grpcs://' + address,
Expand Down Expand Up @@ -203,12 +203,12 @@ const testCollectorExporter = (params: TestParams) =>
describe('export - with gzip compression', () => {
beforeEach(() => {
const credentials = params.useTLS
? grpc.credentials.createSsl(
? grpc.credentials.createSsl(
fs.readFileSync('./test/certs/ca.crt'),
fs.readFileSync('./test/certs/client.key'),
fs.readFileSync('./test/certs/client.crt')
)
: undefined;
: undefined;
collectorExporter = new OTLPTraceExporter({
url: 'grpcs://' + address,
credentials,
Expand Down Expand Up @@ -254,12 +254,12 @@ const testCollectorExporter = (params: TestParams) =>
const envSource = process.env;
it('should return gzip compression algorithm on exporter', () => {
const credentials = params.useTLS
? grpc.credentials.createSsl(
? grpc.credentials.createSsl(
fs.readFileSync('./test/certs/ca.crt'),
fs.readFileSync('./test/certs/client.key'),
fs.readFileSync('./test/certs/client.crt')
)
: undefined;
: undefined;

envSource.OTEL_EXPORTER_OTLP_COMPRESSION='gzip';
collectorExporter = new OTLPTraceExporter({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"rimraf": "3.0.2",
"sinon": "12.0.1",
"ts-loader": "8.3.0",
"ts-mocha": "8.0.0",
"ts-mocha": "9.0.2",
"typescript": "4.4.4",
"webpack": "4.46.0",
"webpack-cli": "4.9.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export class OTLPTraceExporter
return typeof config.url === 'string'
? config.url
: getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT.length > 0
? getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
: getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
: DEFAULT_COLLECTOR_URL;
? getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
: getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
: DEFAULT_COLLECTOR_URL;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"rimraf": "3.0.2",
"sinon": "12.0.1",
"ts-loader": "8.3.0",
"ts-mocha": "8.0.0",
"ts-mocha": "9.0.2",
"typescript": "4.4.4"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ export class OTLPTraceExporter
return typeof config.url === 'string'
? config.url
: getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT.length > 0
? getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
: getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
: DEFAULT_COLLECTOR_URL;
? getEnv().OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
: getEnv().OTEL_EXPORTER_OTLP_ENDPOINT.length > 0
? appendResourcePathToUrlIfNotPresent(getEnv().OTEL_EXPORTER_OTLP_ENDPOINT, DEFAULT_COLLECTOR_RESOURCE_PATH)
: DEFAULT_COLLECTOR_URL;
}

getServiceClientType() {
Expand Down
3 changes: 1 addition & 2 deletions experimental/packages/opentelemetry-api-metrics/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "@opentelemetry/api-metrics",
"version": "0.28.0",
"private": true,
"description": "Public metrics API for OpenTelemetry",
"main": "build/src/index.js",
"module": "build/esm/index.js",
Expand Down Expand Up @@ -79,7 +78,7 @@
"mocha": "7.2.0",
"nyc": "15.1.0",
"ts-loader": "8.3.0",
"ts-mocha": "8.0.0",
"ts-mocha": "9.0.2",
"typescript": "4.4.4",
"webpack": "4.46.0"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
// eslint-disable-next-line node/no-unsupported-features/es-builtins, no-undef
export const _globalThis: typeof globalThis =
typeof globalThis === 'object' ? globalThis :
typeof self === 'object' ? self :
typeof window === 'object' ? window :
typeof global === 'object' ? global :
typeof self === 'object' ? self :
typeof window === 'object' ? window :
typeof global === 'object' ? global :
{} as typeof globalThis;
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"rimraf": "3.0.2",
"sinon": "12.0.1",
"ts-loader": "8.3.0",
"ts-mocha": "8.0.0",
"ts-mocha": "9.0.2",
"typescript": "4.4.4"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"rimraf": "3.0.2",
"sinon": "12.0.1",
"ts-loader": "8.3.0",
"ts-mocha": "8.0.0",
"ts-mocha": "9.0.2",
"typescript": "4.4.4",
"webpack": "4.46.0",
"webpack-cli": "4.9.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import { OTLPExporterBase } from '@opentelemetry/otlp-exporter-base';
export class OTLPMetricExporterBase<T extends OTLPExporterBase<OTLPMetricExporterOptions,
ResourceMetrics,
otlpTypes.opentelemetryProto.collector.metrics.v1.ExportMetricsServiceRequest>>
implements PushMetricExporter {
implements PushMetricExporter {
public _otlpExporter: T;
protected _preferredAggregationTemporality: AggregationTemporality;

constructor(exporter: T,
config: OTLPMetricExporterOptions = defaultOptions) {
config: OTLPMetricExporterOptions = defaultOptions) {
this._otlpExporter = exporter;
this._preferredAggregationTemporality = config.aggregationTemporality ?? AggregationTemporality.CUMULATIVE;
}
Expand Down
Loading

0 comments on commit 7447724

Please sign in to comment.