diff --git a/CHANGELOG.md b/CHANGELOG.md index 2854b11b845..f80632b8f7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,104 @@ All notable changes to this project will be documented in this file. ## Unreleased +## 0.10.0 + +### :boom: Breaking Change + +* `opentelemetry-exporter-collector`, `opentelemetry-metrics` + * [#1292](https://github.com/open-telemetry/opentelemetry-js/pull/1292) feat: remove HistogramAggregator.reset ([@legendecas](https://github.com/legendecas)) +* `opentelemetry-api`, `opentelemetry-exporter-prometheus`, `opentelemetry-metrics` + * [#1137](https://github.com/open-telemetry/opentelemetry-js/pull/1137) Batch observer ([@obecny](https://github.com/obecny)) +* `opentelemetry-exporter-collector` + * [#1256](https://github.com/open-telemetry/opentelemetry-js/pull/1256) feat: [Collector Metric Exporter][1/x] Rename CollectorExporter to CollectorTraceExporter ([@davidwitten](https://github.com/davidwitten)) + +### :rocket: (Enhancement) + +* `opentelemetry-exporter-collector` + * [#1339](https://github.com/open-telemetry/opentelemetry-js/pull/1339) Proto update to latest to support arrays and maps ([@obecny](https://github.com/obecny)) + * [#1302](https://github.com/open-telemetry/opentelemetry-js/pull/1302) feat: adding proto over http for collector exporter ([@obecny](https://github.com/obecny)) + * [#1247](https://github.com/open-telemetry/opentelemetry-js/pull/1247) feat: adding json over http for collector exporter ([@obecny](https://github.com/obecny)) +* `opentelemetry-core`, `opentelemetry-metrics`, `opentelemetry-tracing` + * [#974](https://github.com/open-telemetry/opentelemetry-js/pull/974) feat: add OTEL_LOG_LEVEL env var ([@naseemkullah](https://github.com/naseemkullah)) +* `opentelemetry-metrics`, `opentelemetry-node`, `opentelemetry-sdk-node` + * [#1187](https://github.com/open-telemetry/opentelemetry-js/pull/1187) Add nodejs sdk package ([@dyladan](https://github.com/dyladan)) +* `opentelemetry-shim-opentracing` + * [#918](https://github.com/open-telemetry/opentelemetry-js/pull/918) feat: add baggage support to the opentracing shim ([@rubenvp8510](https://github.com/rubenvp8510)) +* `opentelemetry-tracing` + * [#1069](https://github.com/open-telemetry/opentelemetry-js/pull/1069) feat: add OTEL_SAMPLING_PROBABILITY env var ([@naseemkullah](https://github.com/naseemkullah)) + * [#1296](https://github.com/open-telemetry/opentelemetry-js/pull/1296) feat: force flush and shutdown callback for span exporters ([@dyladan](https://github.com/dyladan)) +* `opentelemetry-node` + * [#1343](https://github.com/open-telemetry/opentelemetry-js/pull/1343) feat(grpc-js): enable autoinstrumentation by default ([@markwolff](https://github.com/markwolff)) +* `opentelemetry-exporter-collector`, `opentelemetry-exporter-prometheus`, `opentelemetry-metrics` + * [#1276](https://github.com/open-telemetry/opentelemetry-js/pull/1276) chore: updating aggregator MinMaxLastSumCount and use it for value observer and value recorder ([@obecny](https://github.com/obecny)) +* `opentelemetry-plugin-fetch`, `opentelemetry-plugin-xml-http-request`, `opentelemetry-semantic-conventions`, `opentelemetry-web` + * [#1262](https://github.com/open-telemetry/opentelemetry-js/pull/1262) feat(opentelemetry-web): capture decodedBodySize / http.response_content_length ([@johnbley](https://github.com/johnbley)) +* `opentelemetry-resources` + * [#1211](https://github.com/open-telemetry/opentelemetry-js/pull/1211) Resource auto detection logging ([@adamegyed](https://github.com/adamegyed)) +* `opentelemetry-api`, `opentelemetry-exporter-prometheus`, `opentelemetry-metrics` + * [#1137](https://github.com/open-telemetry/opentelemetry-js/pull/1137) Batch observer ([@obecny](https://github.com/obecny)) +* `opentelemetry-core` + * [#1191](https://github.com/open-telemetry/opentelemetry-js/pull/1191) Add platform agnostic way to read environment variables ([@obecny](https://github.com/obecny)) +* `opentelemetry-context-async-hooks` + * [#1210](https://github.com/open-telemetry/opentelemetry-js/pull/1210) AsyncLocalStorage based ContextManager ([@johanneswuerbach](https://github.com/johanneswuerbach)) +* `opentelemetry-api`, `opentelemetry-context-async-hooks`, `opentelemetry-context-base`, `opentelemetry-context-zone-peer-dep`, `opentelemetry-context-zone`, `opentelemetry-core`, `opentelemetry-exporter-collector`, `opentelemetry-exporter-jaeger`, `opentelemetry-exporter-prometheus`, `opentelemetry-exporter-zipkin`, `opentelemetry-metrics`, `opentelemetry-node`, `opentelemetry-plugin-fetch`, `opentelemetry-plugin-grpc-js`, `opentelemetry-plugin-grpc`, `opentelemetry-plugin-http`, `opentelemetry-plugin-https`, `opentelemetry-plugin-xml-http-request`, `opentelemetry-resources`, `opentelemetry-semantic-conventions`, `opentelemetry-shim-opentracing`, `opentelemetry-tracing`, `opentelemetry-web` + * [#1237](https://github.com/open-telemetry/opentelemetry-js/pull/1237) fix(package.json): publish source maps ([@markwolff](https://github.com/markwolff)) +* `opentelemetry-core`, `opentelemetry-exporter-collector`, `opentelemetry-exporter-jaeger`, `opentelemetry-exporter-zipkin`, `opentelemetry-metrics`, `opentelemetry-tracing` + * [#1171](https://github.com/open-telemetry/opentelemetry-js/pull/1171) feat: add instrumentation library and update collector exporter ([@mwear](https://github.com/mwear)) +* `opentelemetry-plugin-xml-http-request` + * [#1216](https://github.com/open-telemetry/opentelemetry-js/pull/1216) Increase Test Coverage for XML Http Plugin ([@thgao](https://github.com/thgao)) +* `opentelemetry-core`, `opentelemetry-node`, `opentelemetry-tracing`, `opentelemetry-web` + * [#1218](https://github.com/open-telemetry/opentelemetry-js/pull/1218) fix: change default propagator to match spec ([@jonahrosenblum](https://github.com/jonahrosenblum)) + +### :bug: (Bug Fix) + +* `opentelemetry-plugin-grpc` + * [#1289](https://github.com/open-telemetry/opentelemetry-js/pull/1289) fix(grpc): camelCase methods can be double patched ([@markwolff](https://github.com/markwolff)) +* `opentelemetry-plugin-fetch` + * [#1274](https://github.com/open-telemetry/opentelemetry-js/pull/1274) fix: do not crash on fetch(new Request(url)) ([@dyladan](https://github.com/dyladan)) +* `opentelemetry-core` + * [#1269](https://github.com/open-telemetry/opentelemetry-js/pull/1269) fix(opentelemetry-core): modify regex to allow future versions ([@srjames90](https://github.com/srjames90)) +* `opentelemetry-exporter-collector` + * [#1254](https://github.com/open-telemetry/opentelemetry-js/pull/1254) fix: default url for otelcol ([@jufab](https://github.com/jufab)) + +### :books: (Refine Doc) + +* `opentelemetry-metrics` + * [#1239](https://github.com/open-telemetry/opentelemetry-js/pull/1239) chore: update metrics example with UpDownCounter ([@mayurkale22](https://github.com/mayurkale22)) +* `opentelemetry-exporter-jaeger` + * [#1234](https://github.com/open-telemetry/opentelemetry-js/pull/1234) docs: add note about endpoint config option ([@danielmbarlow](https://github.com/danielmbarlow)) +* `opentelemetry-api` + * [#1231](https://github.com/open-telemetry/opentelemetry-js/pull/1231) fix(jsdoc): change null to undefined ([@markwolff](https://github.com/markwolff)) + +### :sparkles: (Feature) + +* `opentelemetry-api`, `opentelemetry-metrics` + * [#1272](https://github.com/open-telemetry/opentelemetry-js/pull/1272) feat: adding new metric: up down sum observer ([@obecny](https://github.com/obecny)) + +#### Committers: 21 + +* Adam Egyed ([@adamegyed](https://github.com/adamegyed)) +* Aravin ([@aravinsiva](https://github.com/aravinsiva)) +* Bartlomiej Obecny ([@obecny](https://github.com/obecny)) +* Bryan Clement ([@lykkin](https://github.com/lykkin)) +* Connor Lindsey ([@connorlindsey](https://github.com/connorlindsey)) +* Daniel Dyla ([@dyladan](https://github.com/dyladan)) +* Daniel M Barlow ([@danielmbarlow](https://github.com/danielmbarlow)) +* David W. ([@davidwitten](https://github.com/davidwitten)) +* Johannes Würbach ([@johanneswuerbach](https://github.com/johanneswuerbach)) +* John Bley ([@johnbley](https://github.com/johnbley)) +* Jonah Rosenblum ([@jonahrosenblum](https://github.com/jonahrosenblum)) +* Julien FABRE ([@jufab](https://github.com/jufab)) +* Mark Wolff ([@markwolff](https://github.com/markwolff)) +* Matthew Wear ([@mwear](https://github.com/mwear)) +* Mayur Kale ([@mayurkale22](https://github.com/mayurkale22)) +* Naseem ([@naseemkullah](https://github.com/naseemkullah)) +* Ruben Vargas Palma ([@rubenvp8510](https://github.com/rubenvp8510)) +* Shivkanya Andhare ([@shivkanya9146](https://github.com/shivkanya9146)) +* Tina Gao ([@thgao](https://github.com/thgao)) +* [@srjames90](https://github.com/srjames90) +* legendecas ([@legendecas](https://github.com/legendecas)) + ## 0.9.0 ### :boom: Breaking Change diff --git a/examples/basic-tracer-node/package.json b/examples/basic-tracer-node/package.json index 339a9d96098..5efa04d94a6 100644 --- a/examples/basic-tracer-node/package.json +++ b/examples/basic-tracer-node/package.json @@ -1,7 +1,7 @@ { "name": "example-basic-tracer-node", "private": true, - "version": "0.9.0", + "version": "0.10.0", "description": "Example of using @opentelemetry/tracing in Node.js", "main": "index.js", "scripts": { @@ -24,9 +24,9 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/exporter-jaeger": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0" + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/exporter-jaeger": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme" } diff --git a/examples/collector-exporter-node/docker/collector-config.yaml b/examples/collector-exporter-node/docker/collector-config.yaml index 7e0cd7e7590..f104677f7eb 100644 --- a/examples/collector-exporter-node/docker/collector-config.yaml +++ b/examples/collector-exporter-node/docker/collector-config.yaml @@ -1,15 +1,15 @@ receivers: otlp: - {} -# keep it when upgrading to version 0.5+ -# protocols: -# grpc: -# http: -# endpoint: localhost:55680 + protocols: + grpc: + http: + cors_allowed_origins: + - http://* + - https://* exporters: zipkin: - url: "http://zipkin-all-in-one:9411/api/v2/spans" + endpoint: "http://zipkin-all-in-one:9411/api/v2/spans" processors: batch: diff --git a/examples/collector-exporter-node/docker/docker-compose.yaml b/examples/collector-exporter-node/docker/docker-compose.yaml index df43b97e33a..3882379ad35 100644 --- a/examples/collector-exporter-node/docker/docker-compose.yaml +++ b/examples/collector-exporter-node/docker/docker-compose.yaml @@ -2,17 +2,26 @@ version: "3" services: # Collector collector: - image: otel/opentelemetry-collector:0.4.0 + image: otel/opentelemetry-collector:latest +# image: otel/opentelemetry-collector:0.6.0 command: ["--config=/conf/collector-config.yaml", "--log-level=DEBUG"] + networks: + - otelcol volumes: - ./collector-config.yaml:/conf/collector-config.yaml ports: - "55680:55680" + - "55681:55681" depends_on: - zipkin-all-in-one + # Zipkin zipkin-all-in-one: image: openzipkin/zipkin:latest + networks: + - otelcol ports: - "9411:9411" +networks: + otelcol: diff --git a/examples/collector-exporter-node/package.json b/examples/collector-exporter-node/package.json index ac987ef149f..6669ec59aaa 100644 --- a/examples/collector-exporter-node/package.json +++ b/examples/collector-exporter-node/package.json @@ -1,7 +1,7 @@ { "name": "example-collector-exporter-node", "private": true, - "version": "0.9.0", + "version": "0.10.0", "description": "Example of using @opentelemetry/collector-exporter in Node.js", "main": "index.js", "scripts": { @@ -27,10 +27,10 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/exporter-collector": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0" + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/exporter-collector": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme" } diff --git a/examples/collector-exporter-node/start.js b/examples/collector-exporter-node/start.js index 138b6b41ec2..4e654c7e1b0 100644 --- a/examples/collector-exporter-node/start.js +++ b/examples/collector-exporter-node/start.js @@ -1,11 +1,13 @@ 'use strict'; const opentelemetry = require('@opentelemetry/api'); +// const { ConsoleLogger, LogLevel} = require('@opentelemetry/core'); const { BasicTracerProvider, ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/tracing'); const { CollectorTraceExporter, CollectorProtocolNode } = require('@opentelemetry/exporter-collector'); const exporter = new CollectorTraceExporter({ serviceName: 'basic-service', + // logger: new ConsoleLogger(LogLevel.DEBUG), // headers: { // foo: 'bar' // }, @@ -48,6 +50,14 @@ function doWork(parent) { // Set attributes to the span. span.setAttribute('key', 'value'); + span.setAttribute('mapAndArrayValue', [ + 0, 1, 2.25, 'otel', { + foo: 'bar', + baz: 'json', + array: [1, 2, 'boom'], + }, + ]); + // Annotate our span to capture metadata about our operation span.addEvent('invoking doWork'); diff --git a/examples/grpc-js/package.json b/examples/grpc-js/package.json index 14ab4981fdb..a03c37346be 100644 --- a/examples/grpc-js/package.json +++ b/examples/grpc-js/package.json @@ -1,7 +1,7 @@ { "name": "grpc-js-example", "private": true, - "version": "0.8.3", + "version": "0.10.0", "description": "Example of @grpc/grpc-js integration with OpenTelemetry", "main": "index.js", "scripts": { @@ -29,12 +29,12 @@ }, "dependencies": { "@grpc/grpc-js": "^1.0.5", - "@opentelemetry/api": "^0.8.3", - "@opentelemetry/exporter-jaeger": "^0.8.3", - "@opentelemetry/exporter-zipkin": "^0.8.3", - "@opentelemetry/node": "^0.8.3", - "@opentelemetry/plugin-grpc-js": "^0.8.3", - "@opentelemetry/tracing": "^0.8.3", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/exporter-jaeger": "^0.10.0", + "@opentelemetry/exporter-zipkin": "^0.10.0", + "@opentelemetry/node": "^0.10.0", + "@opentelemetry/plugin-grpc-js": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", "google-protobuf": "^3.9.2" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", diff --git a/examples/grpc/package.json b/examples/grpc/package.json index d8cb70cc122..a8ed93a115d 100644 --- a/examples/grpc/package.json +++ b/examples/grpc/package.json @@ -1,7 +1,7 @@ { "name": "grpc-example", "private": true, - "version": "0.9.0", + "version": "0.10.0", "description": "Example of gRPC integration with OpenTelemetry", "main": "index.js", "scripts": { @@ -28,12 +28,12 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/exporter-jaeger": "^0.9.0", - "@opentelemetry/exporter-zipkin": "^0.9.0", - "@opentelemetry/node": "^0.9.0", - "@opentelemetry/plugin-grpc": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/exporter-jaeger": "^0.10.0", + "@opentelemetry/exporter-zipkin": "^0.10.0", + "@opentelemetry/node": "^0.10.0", + "@opentelemetry/plugin-grpc": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", "google-protobuf": "^3.9.2", "grpc": "^1.23.3", "node-pre-gyp": "0.12.0" diff --git a/examples/http/package.json b/examples/http/package.json index ec895d5051d..9c476ca3f3f 100644 --- a/examples/http/package.json +++ b/examples/http/package.json @@ -1,7 +1,7 @@ { "name": "http-example", "private": true, - "version": "0.9.0", + "version": "0.10.0", "description": "Example of HTTP integration with OpenTelemetry", "main": "index.js", "scripts": { @@ -28,12 +28,12 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/exporter-jaeger": "^0.9.0", - "@opentelemetry/exporter-zipkin": "^0.9.0", - "@opentelemetry/node": "^0.9.0", - "@opentelemetry/plugin-http": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0" + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/exporter-jaeger": "^0.10.0", + "@opentelemetry/exporter-zipkin": "^0.10.0", + "@opentelemetry/node": "^0.10.0", + "@opentelemetry/plugin-http": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", "devDependencies": { diff --git a/examples/https/package.json b/examples/https/package.json index 42147f5d675..6dce6ba2a66 100644 --- a/examples/https/package.json +++ b/examples/https/package.json @@ -1,7 +1,7 @@ { "name": "https-example", "private": true, - "version": "0.9.0", + "version": "0.10.0", "description": "Example of HTTPs integration with OpenTelemetry", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -29,12 +29,12 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/exporter-jaeger": "^0.9.0", - "@opentelemetry/exporter-zipkin": "^0.9.0", - "@opentelemetry/node": "^0.9.0", - "@opentelemetry/plugin-https": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0" + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/exporter-jaeger": "^0.10.0", + "@opentelemetry/exporter-zipkin": "^0.10.0", + "@opentelemetry/node": "^0.10.0", + "@opentelemetry/plugin-https": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", "devDependencies": { diff --git a/examples/metrics/package.json b/examples/metrics/package.json index e7b8bfce832..11f0c46816c 100644 --- a/examples/metrics/package.json +++ b/examples/metrics/package.json @@ -1,7 +1,7 @@ { "name": "example-metrics", "private": true, - "version": "0.9.0", + "version": "0.10.0", "description": "Example of using @opentelemetry/metrics", "main": "index.js", "scripts": { @@ -26,9 +26,9 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/exporter-prometheus": "^0.9.0", - "@opentelemetry/metrics": "^0.9.0" + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/exporter-prometheus": "^0.10.0", + "@opentelemetry/metrics": "^0.10.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme" } diff --git a/examples/opentracing-shim/package.json b/examples/opentracing-shim/package.json index acfd9d3353e..dc176cca912 100644 --- a/examples/opentracing-shim/package.json +++ b/examples/opentracing-shim/package.json @@ -1,7 +1,7 @@ { "name": "opentracing-shim", "private": true, - "version": "0.9.0", + "version": "0.10.0", "description": "Example of using @opentelemetry/shim-opentracing in Node.js", "main": "index.js", "scripts": { @@ -29,11 +29,11 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/exporter-jaeger": "^0.9.0", - "@opentelemetry/exporter-zipkin": "^0.9.0", - "@opentelemetry/node": "^0.9.0", - "@opentelemetry/shim-opentracing": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", + "@opentelemetry/exporter-jaeger": "^0.10.0", + "@opentelemetry/exporter-zipkin": "^0.10.0", + "@opentelemetry/node": "^0.10.0", + "@opentelemetry/shim-opentracing": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", "opentracing": "^0.14.4" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", diff --git a/examples/prometheus/package.json b/examples/prometheus/package.json index 1039eec031c..c87fd542926 100644 --- a/examples/prometheus/package.json +++ b/examples/prometheus/package.json @@ -1,6 +1,6 @@ { "name": "prometheus-example", - "version": "0.9.0", + "version": "0.10.0", "description": "Example of using @opentelemetry/metrics and @opentelemetry/exporter-prometheus", "main": "index.js", "scripts": { @@ -9,7 +9,7 @@ "author": "OpenTelemetry Authors", "license": "Apache-2.0", "dependencies": { - "@opentelemetry/exporter-prometheus": "^0.9.0", - "@opentelemetry/metrics": "^0.9.0" + "@opentelemetry/exporter-prometheus": "^0.10.0", + "@opentelemetry/metrics": "^0.10.0" } } diff --git a/examples/tracer-web/examples/user-interaction/index.js b/examples/tracer-web/examples/user-interaction/index.js index b15f85a99e4..a193a7d17b4 100644 --- a/examples/tracer-web/examples/user-interaction/index.js +++ b/examples/tracer-web/examples/user-interaction/index.js @@ -10,7 +10,7 @@ const providerWithZone = new WebTracerProvider({ plugins: [ new UserInteractionPlugin(), new XMLHttpRequestPlugin({ - ignoreUrls: [/localhost:8090\/sockjs-node/], + ignoreUrls: [/localhost/], propagateTraceHeaderCorsUrls: [ 'http://localhost:8090' ] diff --git a/examples/tracer-web/package.json b/examples/tracer-web/package.json index 74d5d42d61e..0dab2ea2e0c 100644 --- a/examples/tracer-web/package.json +++ b/examples/tracer-web/package.json @@ -1,7 +1,7 @@ { "name": "web-tracer-example", "private": true, - "version": "0.9.0", + "version": "0.10.0", "description": "Example of using @opentelemetry/web in browser", "main": "index.js", "scripts": { @@ -34,15 +34,15 @@ "webpack-merge": "^4.2.2" }, "dependencies": { - "@opentelemetry/context-zone": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/exporter-collector": "^0.9.0", + "@opentelemetry/context-zone": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/exporter-collector": "^0.10.0", "@opentelemetry/plugin-document-load": "^0.6.1", - "@opentelemetry/plugin-fetch": "^0.9.0", + "@opentelemetry/plugin-fetch": "^0.10.0", "@opentelemetry/plugin-user-interaction": "^0.6.1", - "@opentelemetry/plugin-xml-http-request": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", - "@opentelemetry/web": "^0.9.0" + "@opentelemetry/plugin-xml-http-request": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", + "@opentelemetry/web": "^0.10.0" }, "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme" } diff --git a/getting-started/monitored-example/package.json b/getting-started/monitored-example/package.json index 10b0dd218ef..58d085e6b00 100644 --- a/getting-started/monitored-example/package.json +++ b/getting-started/monitored-example/package.json @@ -9,7 +9,7 @@ "author": "OpenTelemetry Authors", "license": "Apache-2.0", "dependencies": { - "@opentelemetry/metrics": "^0.9.0", + "@opentelemetry/metrics": "^0.10.0", "axios": "^0.19.0", "express": "^4.17.1" } diff --git a/getting-started/traced-example/package.json b/getting-started/traced-example/package.json index 78518717f26..73b1aa489ad 100644 --- a/getting-started/traced-example/package.json +++ b/getting-started/traced-example/package.json @@ -9,13 +9,13 @@ "author": "OpenTelemetry Authors", "license": "Apache-2.0", "dependencies": { - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/exporter-zipkin": "^0.9.0", - "@opentelemetry/node": "^0.9.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/exporter-zipkin": "^0.10.0", + "@opentelemetry/node": "^0.10.0", "@opentelemetry/plugin-express": "^0.8.0", - "@opentelemetry/plugin-http": "^0.9.0", - "@opentelemetry/plugin-https": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", + "@opentelemetry/plugin-http": "^0.10.0", + "@opentelemetry/plugin-https": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", "axios": "^0.19.0", "express": "^4.17.1" } diff --git a/getting-started/ts-example/package.json b/getting-started/ts-example/package.json index 41a896e4c0e..c75124ee509 100644 --- a/getting-started/ts-example/package.json +++ b/getting-started/ts-example/package.json @@ -13,14 +13,14 @@ "ts-node": "8.10.2" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/exporter-prometheus": "^0.9.0", - "@opentelemetry/exporter-zipkin": "^0.9.0", - "@opentelemetry/metrics": "^0.9.0", - "@opentelemetry/node": "^0.9.0", - "@opentelemetry/plugin-http": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/exporter-prometheus": "^0.10.0", + "@opentelemetry/exporter-zipkin": "^0.10.0", + "@opentelemetry/metrics": "^0.10.0", + "@opentelemetry/node": "^0.10.0", + "@opentelemetry/plugin-http": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", "axios": "^0.19.1", "express": "^4.17.1" } diff --git a/lerna.json b/lerna.json index f5d062d5736..bab09d2faab 100644 --- a/lerna.json +++ b/lerna.json @@ -6,7 +6,7 @@ "metapackages/*", "packages/*" ], - "version": "0.9.0", + "version": "0.10.0", "changelog": { "repo": "open-telemetry/opentelemetry-js", "labels": { diff --git a/metapackages/plugins-node-all/package.json b/metapackages/plugins-node-all/package.json index f7fb294d8fb..9b2d1d031dd 100644 --- a/metapackages/plugins-node-all/package.json +++ b/metapackages/plugins-node-all/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/plugins-node-all", - "version": "0.9.0", + "version": "0.10.0", "description": "Metapackage which bundles opentelemetry node core and contrib plugins", "author": "OpenTelemetry Authors", "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", @@ -16,13 +16,13 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/plugins-node-core": "^0.9.0", "@opentelemetry/plugin-express": "0.8.0", "@opentelemetry/plugin-ioredis": "0.8.0", "@opentelemetry/plugin-mongodb": "0.8.0", "@opentelemetry/plugin-mysql": "0.8.0", - "@opentelemetry/plugin-pg-pool": "0.8.0", "@opentelemetry/plugin-pg": "0.8.0", - "@opentelemetry/plugin-redis": "0.8.0" + "@opentelemetry/plugin-pg-pool": "0.8.0", + "@opentelemetry/plugin-redis": "0.8.0", + "@opentelemetry/plugins-node-core": "^0.10.0" } } diff --git a/metapackages/plugins-node-core/package.json b/metapackages/plugins-node-core/package.json index e4ea03b0df9..c2a89a30af2 100644 --- a/metapackages/plugins-node-core/package.json +++ b/metapackages/plugins-node-core/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/plugins-node-core", - "version": "0.9.0", + "version": "0.10.0", "description": "Metapackage which bundles all opentelemetry node core plugins", "author": "OpenTelemetry Authors", "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", @@ -16,9 +16,9 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/plugin-grpc": "^0.9.0", - "@opentelemetry/plugin-grpc-js": "^0.9.0", - "@opentelemetry/plugin-http": "^0.9.0", - "@opentelemetry/plugin-https": "^0.9.0" + "@opentelemetry/plugin-grpc": "^0.10.0", + "@opentelemetry/plugin-grpc-js": "^0.10.0", + "@opentelemetry/plugin-http": "^0.10.0", + "@opentelemetry/plugin-https": "^0.10.0" } } diff --git a/metapackages/plugins-web-core/package.json b/metapackages/plugins-web-core/package.json index 2c2c0664ca2..ad350b32f38 100644 --- a/metapackages/plugins-web-core/package.json +++ b/metapackages/plugins-web-core/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/plugins-web-core", - "version": "0.9.0", + "version": "0.10.0", "description": "Metapackage which bundles all opentelemetry web core plugins", "author": "OpenTelemetry Authors", "homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", @@ -16,6 +16,6 @@ "url": "https://github.com/open-telemetry/opentelemetry-js/issues" }, "dependencies": { - "@opentelemetry/plugin-xml-http-request": "^0.9.0" + "@opentelemetry/plugin-xml-http-request": "^0.10.0" } } diff --git a/package.json b/package.json index 335b5a6714b..a72465247df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opentelemetry-base", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry is a distributed tracing and stats collection framework.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -42,11 +42,11 @@ "devDependencies": { "@commitlint/cli": "9.1.1", "@commitlint/config-conventional": "9.1.1", - "@typescript-eslint/eslint-plugin": "3.6.1", - "@typescript-eslint/parser": "3.6.1", + "@typescript-eslint/eslint-plugin": "3.7.0", + "@typescript-eslint/parser": "3.7.0", "beautify-benchmark": "0.2.4", "benchmark": "2.1.4", - "eslint": "7.4.0", + "eslint": "7.5.0", "eslint-config-airbnb-base": "14.2.0", "eslint-plugin-header": "3.0.0", "eslint-plugin-import": "2.22.0", diff --git a/packages/opentelemetry-api/package.json b/packages/opentelemetry-api/package.json index cec27f995e2..6db776357c7 100644 --- a/packages/opentelemetry-api/package.json +++ b/packages/opentelemetry-api/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/api", - "version": "0.9.0", + "version": "0.10.0", "description": "Public API for OpenTelemetry", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -52,13 +52,13 @@ "access": "public" }, "dependencies": { - "@opentelemetry/context-base": "^0.9.0" + "@opentelemetry/context-base": "^0.10.0" }, "devDependencies": { "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/webpack-env": "1.15.2", - "codecov": "3.7.1", + "codecov": "3.7.2", "gts": "2.0.2", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.1.0", @@ -74,6 +74,6 @@ "ts-mocha": "7.0.0", "typedoc": "0.17.8", "typescript": "3.9.7", - "webpack": "4.43.0" + "webpack": "4.44.0" } } diff --git a/packages/opentelemetry-api/src/version.ts b/packages/opentelemetry-api/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-api/src/version.ts +++ b/packages/opentelemetry-api/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-context-async-hooks/package.json b/packages/opentelemetry-context-async-hooks/package.json index 506decad1e6..08c32420407 100644 --- a/packages/opentelemetry-context-async-hooks/package.json +++ b/packages/opentelemetry-context-async-hooks/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/context-async-hooks", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry AsyncHooks-based Context Manager", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -43,9 +43,9 @@ }, "devDependencies": { "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/shimmer": "1.0.1", - "codecov": "3.7.1", + "codecov": "3.7.2", "gts": "2.0.2", "mocha": "7.2.0", "nyc": "15.1.0", @@ -55,6 +55,6 @@ "typescript": "3.9.7" }, "dependencies": { - "@opentelemetry/context-base": "^0.9.0" + "@opentelemetry/context-base": "^0.10.0" } } diff --git a/packages/opentelemetry-context-async-hooks/src/version.ts b/packages/opentelemetry-context-async-hooks/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-context-async-hooks/src/version.ts +++ b/packages/opentelemetry-context-async-hooks/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-context-base/package.json b/packages/opentelemetry-context-base/package.json index 8affde53955..74e738973b4 100644 --- a/packages/opentelemetry-context-base/package.json +++ b/packages/opentelemetry-context-base/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/context-base", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry Base Context Manager", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -45,8 +45,8 @@ }, "devDependencies": { "@types/mocha": "8.0.0", - "@types/node": "14.0.23", - "codecov": "3.7.1", + "@types/node": "14.0.25", + "codecov": "3.7.2", "gts": "2.0.2", "mocha": "7.2.0", "nyc": "15.1.0", diff --git a/packages/opentelemetry-context-base/src/version.ts b/packages/opentelemetry-context-base/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-context-base/src/version.ts +++ b/packages/opentelemetry-context-base/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-context-zone-peer-dep/package.json b/packages/opentelemetry-context-zone-peer-dep/package.json index 2bd0fac7c07..89652772a4a 100644 --- a/packages/opentelemetry-context-zone-peer-dep/package.json +++ b/packages/opentelemetry-context-zone-peer-dep/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/context-zone-peer-dep", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry Context Zone with peer dependency for zone.js", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -44,12 +44,12 @@ "devDependencies": { "@babel/core": "7.10.5", "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/sinon": "9.0.4", "@types/webpack-env": "1.15.2", "@types/zone.js": "0.5.12", "babel-loader": "8.1.0", - "codecov": "3.7.1", + "codecov": "3.7.2", "gts": "2.0.2", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.1.0", @@ -66,12 +66,12 @@ "ts-mocha": "7.0.0", "ts-node": "8.10.2", "typescript": "3.9.7", - "webpack": "4.43.0", + "webpack": "4.44.0", "webpack-cli": "3.3.12", "zone.js": "0.10.3" }, "dependencies": { - "@opentelemetry/context-base": "^0.9.0" + "@opentelemetry/context-base": "^0.10.0" }, "peerDependencies": { "zone.js": "^0.10.2" diff --git a/packages/opentelemetry-context-zone-peer-dep/src/version.ts b/packages/opentelemetry-context-zone-peer-dep/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-context-zone-peer-dep/src/version.ts +++ b/packages/opentelemetry-context-zone-peer-dep/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-context-zone/package.json b/packages/opentelemetry-context-zone/package.json index e16c47b891e..1c97b794629 100644 --- a/packages/opentelemetry-context-zone/package.json +++ b/packages/opentelemetry-context-zone/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/context-zone", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry Context Zone", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -41,11 +41,11 @@ "devDependencies": { "@babel/core": "7.10.5", "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/sinon": "9.0.4", "@types/webpack-env": "1.15.2", "babel-loader": "8.1.0", - "codecov": "3.7.1", + "codecov": "3.7.2", "gts": "2.0.2", "karma": "5.1.0", "karma-chrome-launcher": "3.1.0", @@ -60,12 +60,12 @@ "ts-mocha": "7.0.0", "ts-node": "8.10.2", "typescript": "3.9.7", - "webpack": "4.43.0", + "webpack": "4.44.0", "webpack-cli": "3.3.12", "webpack-merge": "5.0.9" }, "dependencies": { - "@opentelemetry/context-zone-peer-dep": "^0.9.0", + "@opentelemetry/context-zone-peer-dep": "^0.10.0", "zone.js": "^0.10.2" }, "sideEffects": true diff --git a/packages/opentelemetry-context-zone/src/version.ts b/packages/opentelemetry-context-zone/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-context-zone/src/version.ts +++ b/packages/opentelemetry-context-zone/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-core/package.json b/packages/opentelemetry-core/package.json index aa8a1566478..28bc6b05d12 100644 --- a/packages/opentelemetry-core/package.json +++ b/packages/opentelemetry-core/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/core", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry Core provides default and no-op implementations of the OpenTelemetry types for trace and metrics", "main": "build/src/index.js", "browser": { @@ -53,11 +53,11 @@ }, "devDependencies": { "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/semver": "7.3.1", "@types/sinon": "9.0.4", "@types/webpack-env": "1.15.2", - "codecov": "3.7.1", + "codecov": "3.7.2", "gts": "2.0.2", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.1.0", @@ -74,11 +74,11 @@ "ts-mocha": "7.0.0", "ts-node": "8.10.2", "typescript": "3.9.7", - "webpack": "4.43.0" + "webpack": "4.44.0" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/context-base": "^0.9.0", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/context-base": "^0.10.0", "semver": "^7.1.3" } } diff --git a/packages/opentelemetry-core/src/common/ConsoleLogger.ts b/packages/opentelemetry-core/src/common/ConsoleLogger.ts index c2cc8b58f4a..d0ee72eaffb 100644 --- a/packages/opentelemetry-core/src/common/ConsoleLogger.ts +++ b/packages/opentelemetry-core/src/common/ConsoleLogger.ts @@ -16,9 +16,10 @@ import { Logger } from '@opentelemetry/api'; import { LogLevel } from './types'; +import { getEnv } from '../platform'; export class ConsoleLogger implements Logger { - constructor(level: LogLevel = LogLevel.INFO) { + constructor(level: LogLevel = getEnv().OTEL_LOG_LEVEL) { if (level >= LogLevel.DEBUG) { this.debug = (...args) => { console.debug(...args); diff --git a/packages/opentelemetry-core/src/common/types.ts b/packages/opentelemetry-core/src/common/types.ts index 4de46a327bf..399ed9d5c13 100644 --- a/packages/opentelemetry-core/src/common/types.ts +++ b/packages/opentelemetry-core/src/common/types.ts @@ -20,6 +20,12 @@ export enum LogLevel { DEBUG, } +/** + * This is equivalent to: + * type LogLevelString = 'ERROR' | 'WARN' | 'INFO' | 'DEBUG'; + */ +export type LogLevelString = keyof typeof LogLevel; + /** * This interface defines a fallback to read a timeOrigin when it is not available on performance.timeOrigin, * this happens for example on Safari Mac diff --git a/packages/opentelemetry-core/src/utils/environment.ts b/packages/opentelemetry-core/src/utils/environment.ts index 9ada4030cd9..73cde2085fd 100644 --- a/packages/opentelemetry-core/src/utils/environment.ts +++ b/packages/opentelemetry-core/src/utils/environment.ts @@ -28,7 +28,6 @@ export interface ENVIRONMENT { } const ENVIRONMENT_NUMBERS: Partial[] = [ - 'OTEL_LOG_LEVEL', 'OTEL_SAMPLING_PROBABILITY', ]; @@ -37,7 +36,7 @@ const ENVIRONMENT_NUMBERS: Partial[] = [ */ export const DEFAULT_ENVIRONMENT: Required = { OTEL_NO_PATCH_MODULES: '', - OTEL_LOG_LEVEL: LogLevel.ERROR, + OTEL_LOG_LEVEL: LogLevel.INFO, OTEL_SAMPLING_PROBABILITY: 1, }; @@ -64,6 +63,41 @@ function parseNumber( } } +/** + * Environmentally sets log level if valid log level string is provided + * @param key + * @param environment + * @param values + */ +function setLogLevelFromEnv( + key: keyof ENVIRONMENT, + environment: ENVIRONMENT_MAP | ENVIRONMENT, + values: ENVIRONMENT_MAP +) { + const value = values[key]; + switch (typeof value === 'string' ? value.toUpperCase() : value) { + case 'DEBUG': + environment[key] = LogLevel.DEBUG; + break; + + case 'INFO': + environment[key] = LogLevel.INFO; + break; + + case 'WARN': + environment[key] = LogLevel.WARN; + break; + + case 'ERROR': + environment[key] = LogLevel.ERROR; + break; + + default: + // do nothing + break; + } +} + /** * Parses environment values * @param values @@ -79,7 +113,7 @@ export function parseEnvironment(values: ENVIRONMENT_MAP): ENVIRONMENT { break; case 'OTEL_LOG_LEVEL': - parseNumber(key, environment, values, LogLevel.ERROR, LogLevel.DEBUG); + setLogLevelFromEnv(key, environment, values); break; default: diff --git a/packages/opentelemetry-core/src/version.ts b/packages/opentelemetry-core/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-core/src/version.ts +++ b/packages/opentelemetry-core/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-core/test/common/ConsoleLogger.test.ts b/packages/opentelemetry-core/test/common/ConsoleLogger.test.ts index b00900e39f7..b63cc58b3f0 100644 --- a/packages/opentelemetry-core/test/common/ConsoleLogger.test.ts +++ b/packages/opentelemetry-core/test/common/ConsoleLogger.test.ts @@ -17,6 +17,10 @@ import * as assert from 'assert'; import { ConsoleLogger } from '../../src/common/ConsoleLogger'; import { LogLevel } from '../../src/common/types'; +import { + mockEnvironment, + removeMockEnvironment, +} from '../utils/environment.test'; describe('ConsoleLogger', () => { const origDebug = console.debug; @@ -54,6 +58,7 @@ describe('ConsoleLogger', () => { console.info = origInfo; console.warn = origWarn; console.error = origError; + removeMockEnvironment(); }); describe('constructor', () => { @@ -65,6 +70,8 @@ describe('ConsoleLogger', () => { assert.deepStrictEqual(warnCalledArgs, ['warn called %s', 'param1']); consoleLogger.info('info called %s', 'param1'); assert.deepStrictEqual(infoCalledArgs, ['info called %s', 'param1']); + consoleLogger.debug('debug called %s', 'param1'); + assert.strictEqual(debugCalledArgs, undefined); }); it('should log with debug', () => { @@ -114,5 +121,35 @@ describe('ConsoleLogger', () => { consoleLogger.debug('debug called %s', 'param1'); assert.strictEqual(debugCalledArgs, null); }); + + it('should log with environmentally set level ', () => { + mockEnvironment({ + OTEL_LOG_LEVEL: 'WARN', + }); + const consoleLogger = new ConsoleLogger(); + consoleLogger.error('error called'); + assert.deepStrictEqual(errorCalledArgs, ['error called']); + consoleLogger.warn('warn called %s', 'param1'); + assert.deepStrictEqual(warnCalledArgs, ['warn called %s', 'param1']); + consoleLogger.info('info called %s', 'param1'); + assert.deepStrictEqual(infoCalledArgs, null); + consoleLogger.debug('debug called %s', 'param1'); + assert.deepStrictEqual(debugCalledArgs, null); + }); + + it('should log with default log level if environmentally set level is invalid', () => { + mockEnvironment({ + OTEL_LOG_LEVEL: 'INVALID_VALUE', + }); + const consoleLogger = new ConsoleLogger(); + consoleLogger.error('error called'); + assert.deepStrictEqual(errorCalledArgs, ['error called']); + consoleLogger.warn('warn called %s', 'param1'); + assert.deepStrictEqual(warnCalledArgs, ['warn called %s', 'param1']); + consoleLogger.info('info called %s', 'param1'); + assert.deepStrictEqual(infoCalledArgs, ['info called %s', 'param1']); + consoleLogger.debug('debug called %s', 'param1'); + assert.deepStrictEqual(debugCalledArgs, null); + }); }); }); diff --git a/packages/opentelemetry-core/test/utils/environment.test.ts b/packages/opentelemetry-core/test/utils/environment.test.ts index 267a6bf2856..578fb97ca2c 100644 --- a/packages/opentelemetry-core/test/utils/environment.test.ts +++ b/packages/opentelemetry-core/test/utils/environment.test.ts @@ -22,10 +22,14 @@ import { } from '../../src/utils/environment'; import * as assert from 'assert'; import * as sinon from 'sinon'; +import { LogLevel } from '../../src'; let lastMock: ENVIRONMENT_MAP = {}; -function mockEnvironment(values: ENVIRONMENT_MAP) { +/** + * Mocks environment used for tests. + */ +export function mockEnvironment(values: ENVIRONMENT_MAP) { lastMock = values; if (typeof process !== 'undefined') { Object.keys(values).forEach(key => { @@ -38,7 +42,10 @@ function mockEnvironment(values: ENVIRONMENT_MAP) { } } -function removeMockEnvironment() { +/** + * Removes mocked environment used for tests. + */ +export function removeMockEnvironment() { if (typeof process !== 'undefined') { Object.keys(lastMock).forEach(key => { delete process.env[key]; @@ -68,15 +75,23 @@ describe('environment', () => { mockEnvironment({ FOO: '1', OTEL_NO_PATCH_MODULES: 'a,b,c', - OTEL_LOG_LEVEL: '1', + OTEL_LOG_LEVEL: 'ERROR', OTEL_SAMPLING_PROBABILITY: '0.5', }); const env = getEnv(); assert.strictEqual(env.OTEL_NO_PATCH_MODULES, 'a,b,c'); - assert.strictEqual(env.OTEL_LOG_LEVEL, 1); + assert.strictEqual(env.OTEL_LOG_LEVEL, LogLevel.ERROR); assert.strictEqual(env.OTEL_SAMPLING_PROBABILITY, 0.5); }); + it('should parse OTEL_LOG_LEVEL despite casing', () => { + mockEnvironment({ + OTEL_LOG_LEVEL: 'waRn', + }); + const env = getEnv(); + assert.strictEqual(env.OTEL_LOG_LEVEL, LogLevel.WARN); + }); + it('should parse environment variables and use defaults', () => { const env = getEnv(); Object.keys(DEFAULT_ENVIRONMENT).forEach(envKey => { @@ -89,4 +104,17 @@ describe('environment', () => { }); }); }); + + describe('mockEnvironment', () => { + it('should remove a mock environment', () => { + mockEnvironment({ + OTEL_LOG_LEVEL: 'DEBUG', + OTEL_SAMPLING_PROBABILITY: 0.5, + }); + removeMockEnvironment(); + const env = getEnv(); + assert.strictEqual(env.OTEL_LOG_LEVEL, LogLevel.INFO); + assert.strictEqual(env.OTEL_SAMPLING_PROBABILITY, 1); + }); + }); }); diff --git a/packages/opentelemetry-exporter-collector/README.md b/packages/opentelemetry-exporter-collector/README.md index 89431bdbaf2..8233384dd15 100644 --- a/packages/opentelemetry-exporter-collector/README.md +++ b/packages/opentelemetry-exporter-collector/README.md @@ -24,7 +24,7 @@ import { WebTracerProvider } from '@opentelemetry/web'; import { CollectorTraceExporter } from '@opentelemetry/exporter-collector'; const collectorOptions = { - url: '', // url is optional and can be omitted - default is http://localhost:55680/v1/trace + url: '', // url is optional and can be omitted - default is http://localhost:55681/v1/trace headers: {}, //an optional object containing custom headers to be sent with each request }; @@ -118,10 +118,33 @@ const { CollectorExporter, CollectorTransportNode } = require('@opentelemetry/e const collectorOptions = { protocolNode: CollectorTransportNode.HTTP_JSON, serviceName: 'basic-service', - url: '', // url is optional and can be omitted - default is http://localhost:55680/v1/trace + url: '', // url is optional and can be omitted - default is http://localhost:55681/v1/trace headers: { foo: 'bar' - }, //an optional object containing custom headers to be sent with each request will only work with json over http + }, //an optional object containing custom headers to be sent with each request will only work with http +}; + +const provider = new BasicTracerProvider(); +const exporter = new CollectorExporter(collectorOptions); +provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); + +provider.register(); + +``` + +## Usage in Node - PROTO over http + +```js +const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tracing'); +const { CollectorExporter, CollectorTransportNode } = require('@opentelemetry/exporter-collector'); + +const collectorOptions = { + protocolNode: CollectorTransportNode.HTTP_PROTO, + serviceName: 'basic-service', + url: '', // url is optional and can be omitted - default is http://localhost:55681/v1/trace + headers: { + foo: 'bar' + }, //an optional object containing custom headers to be sent with each request will only work with http }; const provider = new BasicTracerProvider(); diff --git a/packages/opentelemetry-exporter-collector/package.json b/packages/opentelemetry-exporter-collector/package.json index f9b4438dfdc..6ec83399a31 100644 --- a/packages/opentelemetry-exporter-collector/package.json +++ b/packages/opentelemetry-exporter-collector/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/exporter-collector", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry Collector Exporter allows user to send collected traces to the OpenTelemetry Collector", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -56,11 +56,11 @@ "devDependencies": { "@babel/core": "7.10.5", "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/sinon": "9.0.4", "@types/webpack-env": "1.15.2", "babel-loader": "8.1.0", - "codecov": "3.7.1", + "codecov": "3.7.2", "cpx": "1.5.0", "gts": "2.0.2", "istanbul-instrumenter-loader": "3.0.1", @@ -78,18 +78,18 @@ "ts-mocha": "7.0.0", "ts-node": "8.10.2", "typescript": "3.9.7", - "webpack": "4.43.0", + "webpack": "4.44.0", "webpack-cli": "3.3.12", "webpack-merge": "5.0.9" }, "dependencies": { "@grpc/proto-loader": "^0.5.4", - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/resources": "^0.9.0", - "@opentelemetry/metrics": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", - "protobufjs": "^6.9.0", - "grpc": "^1.24.2" + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/metrics": "^0.10.0", + "@opentelemetry/resources": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", + "grpc": "^1.24.2", + "protobufjs": "^6.9.0" } } diff --git a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts index 6036fe3773d..d593e1d44db 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/browser/CollectorTraceExporter.ts @@ -23,7 +23,7 @@ import { sendWithBeacon, sendWithXhr } from './util'; import { parseHeaders } from '../../util'; const DEFAULT_SERVICE_NAME = 'collector-trace-exporter'; -const DEFAULT_COLLECTOR_URL = 'http://localhost:55680/v1/trace'; +const DEFAULT_COLLECTOR_URL = 'http://localhost:55681/v1/trace'; /** * Collector Trace Exporter for Web @@ -35,9 +35,6 @@ export class CollectorTraceExporter collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest > implements SpanExporter { - DEFAULT_HEADERS: Record = { - [collectorTypes.OT_REQUEST_HEADER]: '1', - }; private _headers: Record; private _useXHR: boolean = false; @@ -46,10 +43,13 @@ export class CollectorTraceExporter */ constructor(config: CollectorExporterConfigBrowser = {}) { super(config); - this._headers = - parseHeaders(config.headers, this.logger) || this.DEFAULT_HEADERS; this._useXHR = !!config.headers || typeof navigator.sendBeacon !== 'function'; + if (this._useXHR) { + this._headers = parseHeaders(config.headers, this.logger); + } else { + this._headers = {}; + } } onInit(): void { diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorMetricExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorMetricExporter.ts index fbf00089f82..3f0aa3c8def 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorMetricExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorMetricExporter.ts @@ -24,7 +24,7 @@ import { toCollectorExportMetricServiceRequest } from '../../transformMetrics'; const DEFAULT_SERVICE_NAME = 'collector-metric-exporter'; const DEFAULT_COLLECTOR_URL_GRPC = 'localhost:55680'; -const DEFAULT_COLLECTOR_URL_JSON = 'http://localhost:55680/v1/metrics'; +const DEFAULT_COLLECTOR_URL_JSON = 'http://localhost:55681/v1/metrics'; /** * Collector Metric Exporter for Node diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts index 2cabd1768c4..45f7194f55b 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/node/CollectorTraceExporter.ts @@ -24,8 +24,8 @@ import { toCollectorExportTraceServiceRequest } from '../../transform'; const DEFAULT_SERVICE_NAME = 'collector-trace-exporter'; const DEFAULT_COLLECTOR_URL_GRPC = 'localhost:55680'; -const DEFAULT_COLLECTOR_URL_JSON = 'http://localhost:55680/v1/trace'; -const DEFAULT_COLLECTOR_URL_JSON_PROTO = 'http://localhost:55680/v1/trace'; +const DEFAULT_COLLECTOR_URL_JSON = 'http://localhost:55681/v1/trace'; +const DEFAULT_COLLECTOR_URL_JSON_PROTO = 'http://localhost:55681/v1/trace'; /** * Collector Trace Exporter for Node diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/protos b/packages/opentelemetry-exporter-collector/src/platform/node/protos index b5468856918..9ffeee0ec53 160000 --- a/packages/opentelemetry-exporter-collector/src/platform/node/protos +++ b/packages/opentelemetry-exporter-collector/src/platform/node/protos @@ -1 +1 @@ -Subproject commit b54688569186e0b862bf7462a983ccf2c50c0547 +Subproject commit 9ffeee0ec532efe02285af84880deb2a53a3eab1 diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/util.ts b/packages/opentelemetry-exporter-collector/src/platform/node/util.ts index a91bc485223..c7a7e24a572 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/node/util.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/node/util.ts @@ -31,7 +31,7 @@ export function removeProtocol(url: string): string { * @param onSuccess * @param onError */ -export function sendDataUsingHttp( +export function sendWithHttp( collector: CollectorExporterNodeBase, data: string | Buffer, contentType: string, diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/utilWithJson.ts b/packages/opentelemetry-exporter-collector/src/platform/node/utilWithJson.ts index 38da393cfe6..72e2c3198b0 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/node/utilWithJson.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/node/utilWithJson.ts @@ -17,7 +17,7 @@ import * as collectorTypes from '../../types'; import { CollectorExporterNodeBase } from './CollectorExporterNodeBase'; import { CollectorExporterConfigNode } from './types'; -import { sendDataUsingHttp } from './util'; +import { sendWithHttp } from './util'; export function initWithJson( _collector: CollectorExporterNodeBase, @@ -34,7 +34,7 @@ export function sendWithJson( ): void { const serviceRequest = collector.convert(objects); - sendDataUsingHttp( + sendWithHttp( collector, JSON.stringify(serviceRequest), 'application/json', diff --git a/packages/opentelemetry-exporter-collector/src/platform/node/utilWithJsonProto.ts b/packages/opentelemetry-exporter-collector/src/platform/node/utilWithJsonProto.ts index ba0035bb652..15025ed56ed 100644 --- a/packages/opentelemetry-exporter-collector/src/platform/node/utilWithJsonProto.ts +++ b/packages/opentelemetry-exporter-collector/src/platform/node/utilWithJsonProto.ts @@ -20,7 +20,7 @@ import * as protobufjs from 'protobufjs'; import * as collectorTypes from '../../types'; import { CollectorExporterNodeBase } from './CollectorExporterNodeBase'; import { CollectorExporterConfigNode } from './types'; -import { sendDataUsingHttp } from './util'; +import { sendWithHttp } from './util'; let ExportTraceServiceRequestProto: Type | undefined; @@ -60,7 +60,7 @@ export function sendWithJsonProto( if (message) { const body = ExportTraceServiceRequestProto?.encode(message).finish(); if (body) { - sendDataUsingHttp( + sendWithHttp( collector, Buffer.from(body), 'application/x-protobuf', diff --git a/packages/opentelemetry-exporter-collector/src/transform.ts b/packages/opentelemetry-exporter-collector/src/transform.ts index c2916f0bf53..4c11bf8c4a1 100644 --- a/packages/opentelemetry-exporter-collector/src/transform.ts +++ b/packages/opentelemetry-exporter-collector/src/transform.ts @@ -30,47 +30,79 @@ import { opentelemetryProto, CollectorExporterConfigBase, } from './types'; -import ValueType = opentelemetryProto.common.v1.ValueType; /** - * Converts attributes + * Converts attributes to KeyValue array * @param attributes */ export function toCollectorAttributes( attributes: Attributes -): opentelemetryProto.common.v1.AttributeKeyValue[] { +): opentelemetryProto.common.v1.KeyValue[] { return Object.keys(attributes).map(key => { return toCollectorAttributeKeyValue(key, attributes[key]); }); } /** - * Converts key and value to AttributeKeyValue + * Converts array of unknown value to ArrayValue + * @param values + */ +export function toCollectorArrayValue( + values: unknown[] +): opentelemetryProto.common.v1.ArrayValue { + return { + values: values.map(value => toCollectorAnyValue(value)), + }; +} + +/** + * Converts attributes to KeyValueList + * @param attributes + */ +export function toCollectorKeyValueList( + attributes: Attributes +): opentelemetryProto.common.v1.KeyValueList { + return { + values: toCollectorAttributes(attributes), + }; +} + +/** + * Converts key and unknown value to KeyValue * @param value event value */ export function toCollectorAttributeKeyValue( key: string, value: unknown -): opentelemetryProto.common.v1.AttributeKeyValue { - let aType: opentelemetryProto.common.v1.ValueType = ValueType.STRING; - const AttributeKeyValue: opentelemetryProto.common.v1.AttributeKeyValue = { +): opentelemetryProto.common.v1.KeyValue { + const anyValue = toCollectorAnyValue(value); + return { key, - type: 0, + value: anyValue, }; +} + +/** + * Converts unknown value to AnyValue + * @param value + */ +export function toCollectorAnyValue( + value: unknown +): opentelemetryProto.common.v1.AnyValue { + const anyValue: opentelemetryProto.common.v1.AnyValue = {}; if (typeof value === 'string') { - AttributeKeyValue.stringValue = value; + anyValue.stringValue = value; } else if (typeof value === 'boolean') { - aType = ValueType.BOOL; - AttributeKeyValue.boolValue = value; + anyValue.boolValue = value; } else if (typeof value === 'number') { // all numbers will be treated as double - aType = ValueType.DOUBLE; - AttributeKeyValue.doubleValue = value; + anyValue.doubleValue = value; + } else if (Array.isArray(value)) { + anyValue.arrayValue = toCollectorArrayValue(value); + } else if (value) { + anyValue.kvlistValue = toCollectorKeyValueList(value as Attributes); } - - AttributeKeyValue.type = aType; - - return AttributeKeyValue; + return anyValue; } /** diff --git a/packages/opentelemetry-exporter-collector/src/types.ts b/packages/opentelemetry-exporter-collector/src/types.ts index 3f11157e7dc..5d95654fb01 100644 --- a/packages/opentelemetry-exporter-collector/src/types.ts +++ b/packages/opentelemetry-exporter-collector/src/types.ts @@ -41,7 +41,7 @@ export namespace opentelemetryProto { export namespace resource.v1 { export interface Resource { - attributes: opentelemetryProto.common.v1.AttributeKeyValue[]; + attributes: opentelemetryProto.common.v1.KeyValue[]; droppedAttributesCount: number; } } @@ -152,7 +152,7 @@ export namespace opentelemetryProto { export interface Event { timeUnixNano: number; name: string; - attributes?: opentelemetryProto.common.v1.AttributeKeyValue[]; + attributes?: opentelemetryProto.common.v1.KeyValue[]; droppedAttributesCount: number; } @@ -160,7 +160,7 @@ export namespace opentelemetryProto { traceId: string; spanId: string; traceState?: opentelemetryProto.trace.v1.Span.TraceState; - attributes?: opentelemetryProto.common.v1.AttributeKeyValue[]; + attributes?: opentelemetryProto.common.v1.KeyValue[]; droppedAttributesCount: number; } @@ -207,7 +207,7 @@ export namespace opentelemetryProto { kind?: opentelemetryProto.trace.v1.Span.SpanKind; startTimeUnixNano?: number; endTimeUnixNano?: number; - attributes?: opentelemetryProto.common.v1.AttributeKeyValue[]; + attributes?: opentelemetryProto.common.v1.KeyValue[]; droppedAttributesCount: number; events?: opentelemetryProto.trace.v1.Span.Event[]; droppedEventsCount: number; @@ -225,14 +225,27 @@ export namespace opentelemetryProto { } } export namespace common.v1 { - export interface AttributeKeyValue { + export interface KeyValue { key: string; - type: opentelemetryProto.common.v1.ValueType; + value: AnyValue; + } + + export type ArrayValue = { + values: AnyValue[]; + }; + + export interface KeyValueList { + values: KeyValue[]; + } + + export type AnyValue = { stringValue?: string; + boolValue?: boolean; intValue?: number; doubleValue?: number; - boolValue?: boolean; - } + arrayValue?: ArrayValue; + kvlistValue?: KeyValueList; + }; export interface InstrumentationLibrary { name: string; diff --git a/packages/opentelemetry-exporter-collector/src/version.ts b/packages/opentelemetry-exporter-collector/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-exporter-collector/src/version.ts +++ b/packages/opentelemetry-exporter-collector/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-exporter-collector/test/browser/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector/test/browser/CollectorTraceExporter.test.ts index 4893ddcb98f..bfb916b3338 100644 --- a/packages/opentelemetry-exporter-collector/test/browser/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/browser/CollectorTraceExporter.test.ts @@ -333,7 +333,7 @@ describe('CollectorTraceExporter - browser (getDefaultUrl)', () => { setTimeout(() => { assert.strictEqual( collectorExporter['url'], - 'http://localhost:55680/v1/trace' + 'http://localhost:55681/v1/trace' ); done(); }); diff --git a/packages/opentelemetry-exporter-collector/test/common/transform.test.ts b/packages/opentelemetry-exporter-collector/test/common/transform.test.ts index 2251d80a3f1..cd3f48058f9 100644 --- a/packages/opentelemetry-exporter-collector/test/common/transform.test.ts +++ b/packages/opentelemetry-exporter-collector/test/common/transform.test.ts @@ -33,7 +33,7 @@ describe('transform', () => { foo: 'bar', }; assert.deepStrictEqual(transform.toCollectorAttributes(attributes), [ - { key: 'foo', type: 0, stringValue: 'bar' }, + { key: 'foo', value: { stringValue: 'bar' } }, ]); }); @@ -42,7 +42,7 @@ describe('transform', () => { foo: 13, }; assert.deepStrictEqual(transform.toCollectorAttributes(attributes), [ - { key: 'foo', type: 2, doubleValue: 13 }, + { key: 'foo', value: { doubleValue: 13 } }, ]); }); @@ -51,7 +51,7 @@ describe('transform', () => { foo: true, }; assert.deepStrictEqual(transform.toCollectorAttributes(attributes), [ - { key: 'foo', type: 3, boolValue: true }, + { key: 'foo', value: { boolValue: true } }, ]); }); @@ -60,7 +60,63 @@ describe('transform', () => { foo: 1.34, }; assert.deepStrictEqual(transform.toCollectorAttributes(attributes), [ - { key: 'foo', type: 2, doubleValue: 1.34 }, + { key: 'foo', value: { doubleValue: 1.34 } }, + ]); + }); + it('should convert attribute mixed with maps and array', () => { + const attributes: Attributes = { + foo: [ + 0, + 1, + 2.25, + 'otel', + { + foo: 'bar', + baz: 'json', + array: [1, 2, 'boom'], + }, + ], + }; + assert.deepStrictEqual(transform.toCollectorAttributes(attributes), [ + { + key: 'foo', + value: { + arrayValue: { + values: [ + { doubleValue: 0 }, + { doubleValue: 1 }, + { doubleValue: 2.25 }, + { stringValue: 'otel' }, + { + kvlistValue: { + values: [ + { + key: 'foo', + value: { stringValue: 'bar' }, + }, + { + key: 'baz', + value: { stringValue: 'json' }, + }, + { + key: 'array', + value: { + arrayValue: { + values: [ + { doubleValue: 1 }, + { doubleValue: 2 }, + { stringValue: 'boom' }, + ], + }, + }, + }, + ], + }, + }, + ], + }, + }, + }, ]); }); }); @@ -79,13 +135,13 @@ describe('transform', () => { { timeUnixNano: 123000000123, name: 'foo', - attributes: [{ key: 'a', type: 0, stringValue: 'b' }], + attributes: [{ key: 'a', value: { stringValue: 'b' } }], droppedAttributesCount: 0, }, { timeUnixNano: 321000000321, name: 'foo2', - attributes: [{ key: 'c', type: 0, stringValue: 'd' }], + attributes: [{ key: 'c', value: { stringValue: 'd' } }], droppedAttributesCount: 0, }, ]); @@ -111,15 +167,13 @@ describe('transform', () => { attributes: [ { key: 'service', - type: 0, - stringValue: 'ui', + value: { stringValue: 'ui' }, }, { key: 'version', - type: 2, - doubleValue: 1, + value: { doubleValue: 1 }, }, - { key: 'success', type: 3, boolValue: true }, + { key: 'success', value: { boolValue: true } }, ], droppedAttributesCount: 0, }); diff --git a/packages/opentelemetry-exporter-collector/test/helper.ts b/packages/opentelemetry-exporter-collector/test/helper.ts index b992867c1ca..58d70d28ebc 100644 --- a/packages/opentelemetry-exporter-collector/test/helper.ts +++ b/packages/opentelemetry-exporter-collector/test/helper.ts @@ -398,49 +398,87 @@ export function ensureExportedEventsAreCorrect( } export function ensureExportedAttributesAreCorrect( - attributes: opentelemetryProto.common.v1.AttributeKeyValue[] + attributes: opentelemetryProto.common.v1.KeyValue[], + usingGRPC = false ) { - assert.deepStrictEqual( - attributes, - [ - { - key: 'component', - type: 'STRING', - stringValue: 'document-load', - intValue: '0', - doubleValue: 0, - boolValue: false, - }, - ], - 'exported attributes are incorrect' - ); + if (usingGRPC) { + assert.deepStrictEqual( + attributes, + [ + { + key: 'component', + value: { + stringValue: 'document-load', + value: 'stringValue', + }, + }, + ], + 'exported attributes are incorrect' + ); + } else { + assert.deepStrictEqual( + attributes, + [ + { + key: 'component', + value: { + stringValue: 'document-load', + }, + }, + ], + 'exported attributes are incorrect' + ); + } } export function ensureExportedLinksAreCorrect( - attributes: opentelemetryProto.trace.v1.Span.Link[] + attributes: opentelemetryProto.trace.v1.Span.Link[], + usingGRPC = false ) { - assert.deepStrictEqual( - attributes, - [ - { - attributes: [ - { - key: 'component', - type: 'STRING', - stringValue: 'document-load', - intValue: '0', - doubleValue: 0, - boolValue: false, - }, - ], - traceId: Buffer.from(traceIdArr), - spanId: Buffer.from(parentIdArr), - traceState: '', - droppedAttributesCount: 0, - }, - ], - 'exported links are incorrect' - ); + if (usingGRPC) { + assert.deepStrictEqual( + attributes, + [ + { + attributes: [ + { + key: 'component', + value: { + stringValue: 'document-load', + value: 'stringValue', + }, + }, + ], + traceId: Buffer.from(traceIdArr), + spanId: Buffer.from(parentIdArr), + traceState: '', + droppedAttributesCount: 0, + }, + ], + 'exported links are incorrect' + ); + } else { + assert.deepStrictEqual( + attributes, + [ + { + attributes: [ + { + key: 'component', + value: { + stringValue: 'document-load', + }, + }, + ], + traceId: Buffer.from(traceIdArr), + spanId: Buffer.from(parentIdArr), + traceState: '', + droppedAttributesCount: 0, + }, + ], + 'exported links are incorrect' + ); + } } export function ensureEventsAreCorrect( @@ -554,15 +592,16 @@ export function ensureProtoEventsAreCorrect( } export function ensureAttributesAreCorrect( - attributes: opentelemetryProto.common.v1.AttributeKeyValue[] + attributes: opentelemetryProto.common.v1.KeyValue[] ) { assert.deepStrictEqual( attributes, [ { key: 'component', - type: 0, - stringValue: 'document-load', + value: { + stringValue: 'document-load', + }, }, ], 'attributes are incorrect' @@ -570,15 +609,16 @@ export function ensureAttributesAreCorrect( } export function ensureProtoAttributesAreCorrect( - attributes: opentelemetryProto.common.v1.AttributeKeyValue[] + attributes: opentelemetryProto.common.v1.KeyValue[] ) { assert.deepStrictEqual( attributes, [ { key: 'component', - type: 'STRING', - stringValue: 'document-load', + value: { + stringValue: 'document-load', + }, }, ], 'attributes are incorrect' @@ -597,8 +637,9 @@ export function ensureLinksAreCorrect( attributes: [ { key: 'component', - type: 0, - stringValue: 'document-load', + value: { + stringValue: 'document-load', + }, }, ], droppedAttributesCount: 0, @@ -620,8 +661,9 @@ export function ensureProtoLinksAreCorrect( attributes: [ { key: 'component', - type: 'STRING', - stringValue: 'document-load', + value: { + stringValue: 'document-load', + }, }, ], droppedAttributesCount: 0, @@ -718,16 +760,17 @@ export function ensureProtoSpanIsCorrect( } export function ensureExportedSpanIsCorrect( - span: collectorTypes.opentelemetryProto.trace.v1.Span + span: collectorTypes.opentelemetryProto.trace.v1.Span, + usingGRPC = false ) { if (span.attributes) { - ensureExportedAttributesAreCorrect(span.attributes); + ensureExportedAttributesAreCorrect(span.attributes, usingGRPC); } if (span.events) { ensureExportedEventsAreCorrect(span.events); } if (span.links) { - ensureExportedLinksAreCorrect(span.links); + ensureExportedLinksAreCorrect(span.links, usingGRPC); } assert.deepStrictEqual( span.traceId, @@ -778,19 +821,27 @@ export function ensureWebResourceIsCorrect( attributes: [ { key: 'service.name', - type: 0, - stringValue: 'bar', + value: { + stringValue: 'bar', + }, }, { key: 'service', - type: 0, - stringValue: 'ui', + value: { + stringValue: 'ui', + }, + }, + { + key: 'version', + value: { + doubleValue: 1, + }, }, - { key: 'version', type: 2, doubleValue: 1 }, { key: 'cost', - type: 2, - doubleValue: 112.12, + value: { + doubleValue: 112.12, + }, }, ], droppedAttributesCount: 0, @@ -991,45 +1042,74 @@ export function ensureExportedValueRecorderIsCorrect( } export function ensureResourceIsCorrect( - resource: collectorTypes.opentelemetryProto.resource.v1.Resource + resource: collectorTypes.opentelemetryProto.resource.v1.Resource, + usingGRPC = true ) { - assert.deepStrictEqual(resource, { - attributes: [ - { - key: 'service.name', - type: 'STRING', - stringValue: 'basic-service', - intValue: '0', - doubleValue: 0, - boolValue: false, - }, - { - key: 'service', - type: 'STRING', - stringValue: 'ui', - intValue: '0', - doubleValue: 0, - boolValue: false, - }, - { - key: 'version', - type: 'DOUBLE', - stringValue: '', - intValue: '0', - doubleValue: 1, - boolValue: false, - }, - { - key: 'cost', - type: 'DOUBLE', - stringValue: '', - intValue: '0', - doubleValue: 112.12, - boolValue: false, - }, - ], - droppedAttributesCount: 0, - }); + if (usingGRPC) { + assert.deepStrictEqual(resource, { + attributes: [ + { + key: 'service.name', + value: { + stringValue: 'basic-service', + value: 'stringValue', + }, + }, + { + key: 'service', + value: { + stringValue: 'ui', + value: 'stringValue', + }, + }, + { + key: 'version', + value: { + doubleValue: 1, + value: 'doubleValue', + }, + }, + { + key: 'cost', + value: { + doubleValue: 112.12, + value: 'doubleValue', + }, + }, + ], + droppedAttributesCount: 0, + }); + } else { + assert.deepStrictEqual(resource, { + attributes: [ + { + key: 'service.name', + value: { + stringValue: 'basic-service', + }, + }, + { + key: 'service', + value: { + stringValue: 'ui', + }, + }, + { + key: 'version', + value: { + doubleValue: 1, + }, + }, + { + key: 'cost', + value: { + doubleValue: 112.12, + }, + }, + ], + droppedAttributesCount: 0, + }); + } } export function ensureExportTraceServiceRequestIsSet( diff --git a/packages/opentelemetry-exporter-collector/test/node/CollectorExporterWithProto.test.ts b/packages/opentelemetry-exporter-collector/test/node/CollectorExporterWithProto.test.ts index bf009167cb8..e847f6bea3b 100644 --- a/packages/opentelemetry-exporter-collector/test/node/CollectorExporterWithProto.test.ts +++ b/packages/opentelemetry-exporter-collector/test/node/CollectorExporterWithProto.test.ts @@ -170,7 +170,7 @@ describe('CollectorExporter - node with proto over http', () => { setTimeout(() => { assert.strictEqual( collectorExporter['url'], - 'http://localhost:55680/v1/trace' + 'http://localhost:55681/v1/trace' ); done(); }); diff --git a/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts b/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts index 300c257593b..ee659923d4a 100644 --- a/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporter.test.ts @@ -219,7 +219,7 @@ const testCollectorMetricExporter = (params: TestParams) => "resource doesn't exist" ); if (resource) { - ensureResourceIsCorrect(resource); + ensureResourceIsCorrect(resource, true); } } if (params.metadata && reqMetadata) { diff --git a/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporterWithJson.test.ts b/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporterWithJson.test.ts index a3e61d42f85..c8f767c82ba 100644 --- a/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporterWithJson.test.ts +++ b/packages/opentelemetry-exporter-collector/test/node/CollectorMetricExporterWithJson.test.ts @@ -120,7 +120,7 @@ describe('CollectorMetricExporter - node with json over http', () => { }); }); - it('should successfully send the spans', done => { + it('should successfully send metrics', done => { collectorExporter.export(metrics, () => {}); setTimeout(() => { @@ -215,7 +215,7 @@ describe('CollectorMetricExporter - node with json over http', () => { setTimeout(() => { assert.strictEqual( collectorExporter['url'], - 'http://localhost:55680/v1/metrics' + 'http://localhost:55681/v1/metrics' ); done(); }); diff --git a/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporter.test.ts b/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporter.test.ts index 9cadd1574ce..4c70e068ff3 100644 --- a/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporter.test.ts +++ b/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporter.test.ts @@ -187,14 +187,14 @@ const testCollectorExporter = (params: TestParams) => if (exportedData) { spans = exportedData.instrumentationLibrarySpans[0].spans; resource = exportedData.resource; - ensureExportedSpanIsCorrect(spans[0]); + ensureExportedSpanIsCorrect(spans[0], true); assert.ok( typeof resource !== 'undefined', "resource doesn't exist" ); if (resource) { - ensureResourceIsCorrect(resource); + ensureResourceIsCorrect(resource, true); } } if (params.metadata && reqMetadata) { diff --git a/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporterWithJson.test.ts b/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporterWithJson.test.ts index 105e5b346e1..bb9cd8f0e98 100644 --- a/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporterWithJson.test.ts +++ b/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporterWithJson.test.ts @@ -169,7 +169,7 @@ describe('CollectorTraceExporter - node with json over http', () => { setTimeout(() => { assert.strictEqual( collectorExporter['url'], - 'http://localhost:55680/v1/trace' + 'http://localhost:55681/v1/trace' ); done(); }); diff --git a/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporterWithProto.test.ts b/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporterWithProto.test.ts new file mode 100644 index 00000000000..e847f6bea3b --- /dev/null +++ b/packages/opentelemetry-exporter-collector/test/node/CollectorTraceExporterWithProto.test.ts @@ -0,0 +1,188 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as core from '@opentelemetry/core'; +import { ReadableSpan } from '@opentelemetry/tracing'; +import * as http from 'http'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import { CollectorProtocolNode } from '../../src/enums'; +import { CollectorTraceExporter } from '../../src/platform/node'; +import { CollectorExporterConfigNode } from '../../src/platform/node/types'; +import { getExportTraceServiceRequestProto } from '../../src/platform/node/utilWithJsonProto'; +import * as collectorTypes from '../../src/types'; + +import { + ensureExportTraceServiceRequestIsSet, + ensureProtoSpanIsCorrect, + mockedReadableSpan, +} from '../helper'; + +const fakeRequest = { + end: function () {}, + on: function () {}, + write: function () {}, +}; + +const mockRes = { + statusCode: 200, +}; + +const mockResError = { + statusCode: 400, +}; + +describe('CollectorExporter - node with proto over http', () => { + let collectorExporter: CollectorTraceExporter; + let collectorExporterConfig: CollectorExporterConfigNode; + let spyRequest: sinon.SinonSpy; + let spyWrite: sinon.SinonSpy; + let spans: ReadableSpan[]; + describe('export', () => { + beforeEach(() => { + spyRequest = sinon.stub(http, 'request').returns(fakeRequest as any); + spyWrite = sinon.stub(fakeRequest, 'write'); + collectorExporterConfig = { + headers: { + foo: 'bar', + }, + protocolNode: CollectorProtocolNode.HTTP_PROTO, + hostname: 'foo', + logger: new core.NoopLogger(), + serviceName: 'bar', + attributes: {}, + url: 'http://foo.bar.com', + }; + collectorExporter = new CollectorTraceExporter(collectorExporterConfig); + spans = []; + spans.push(Object.assign({}, mockedReadableSpan)); + }); + afterEach(() => { + spyRequest.restore(); + spyWrite.restore(); + }); + + it('should open the connection', done => { + collectorExporter.export(spans, () => {}); + + setTimeout(() => { + const args = spyRequest.args[0]; + const options = args[0]; + + assert.strictEqual(options.hostname, 'foo.bar.com'); + assert.strictEqual(options.method, 'POST'); + assert.strictEqual(options.path, '/'); + done(); + }); + }); + + it('should set custom headers', done => { + collectorExporter.export(spans, () => {}); + + setTimeout(() => { + const args = spyRequest.args[0]; + const options = args[0]; + assert.strictEqual(options.headers['foo'], 'bar'); + done(); + }); + }); + + it('should successfully send the spans', done => { + collectorExporter.export(spans, () => {}); + + setTimeout(() => { + const writeArgs = spyWrite.args[0]; + const ExportTraceServiceRequestProto = getExportTraceServiceRequestProto(); + const data = ExportTraceServiceRequestProto?.decode(writeArgs[0]); + const json = data?.toJSON() as collectorTypes.opentelemetryProto.collector.trace.v1.ExportTraceServiceRequest; + const span1 = + json.resourceSpans[0].instrumentationLibrarySpans[0].spans[0]; + assert.ok(typeof span1 !== 'undefined', "span doesn't exist"); + if (span1) { + ensureProtoSpanIsCorrect(span1); + } + + ensureExportTraceServiceRequestIsSet(json); + + done(); + }); + }); + + it('should log the successful message', done => { + const spyLoggerDebug = sinon.stub(collectorExporter.logger, 'debug'); + const spyLoggerError = sinon.stub(collectorExporter.logger, 'error'); + + const responseSpy = sinon.spy(); + collectorExporter.export(spans, responseSpy); + + setTimeout(() => { + const args = spyRequest.args[0]; + const callback = args[1]; + callback(mockRes); + setTimeout(() => { + const response: any = spyLoggerDebug.args[1][0]; + assert.strictEqual(response, 'statusCode: 200'); + assert.strictEqual(spyLoggerError.args.length, 0); + assert.strictEqual(responseSpy.args[0][0], 0); + done(); + }); + }); + }); + + it('should log the error message', done => { + const spyLoggerError = sinon.stub(collectorExporter.logger, 'error'); + + const responseSpy = sinon.spy(); + collectorExporter.export(spans, responseSpy); + + setTimeout(() => { + const args = spyRequest.args[0]; + const callback = args[1]; + callback(mockResError); + setTimeout(() => { + const response: any = spyLoggerError.args[0][0]; + assert.strictEqual(response, 'statusCode: 400'); + + assert.strictEqual(responseSpy.args[0][0], 1); + done(); + }); + }); + }); + }); + describe('CollectorTraceExporter - node (getDefaultUrl)', () => { + it('should default to localhost', done => { + const collectorExporter = new CollectorTraceExporter({ + protocolNode: CollectorProtocolNode.HTTP_PROTO, + }); + setTimeout(() => { + assert.strictEqual( + collectorExporter['url'], + 'http://localhost:55681/v1/trace' + ); + done(); + }); + }); + + it('should keep the URL if included', done => { + const url = 'http://foo.bar.com'; + const collectorExporter = new CollectorTraceExporter({ url }); + setTimeout(() => { + assert.strictEqual(collectorExporter['url'], url); + done(); + }); + }); + }); +}); diff --git a/packages/opentelemetry-exporter-jaeger/package.json b/packages/opentelemetry-exporter-jaeger/package.json index 13b3d22c950..c9f685d7288 100644 --- a/packages/opentelemetry-exporter-jaeger/package.json +++ b/packages/opentelemetry-exporter-jaeger/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/exporter-jaeger", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry Exporter Jaeger allows user to send collected traces to Jaeger", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -42,10 +42,10 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/resources": "^0.9.0", + "@opentelemetry/resources": "^0.10.0", "@types/mocha": "8.0.0", - "@types/node": "14.0.23", - "codecov": "3.7.1", + "@types/node": "14.0.25", + "codecov": "3.7.2", "gts": "2.0.2", "mocha": "7.2.0", "nock": "12.0.3", @@ -56,9 +56,9 @@ "typescript": "3.9.7" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", "jaeger-client": "^3.15.0" } } diff --git a/packages/opentelemetry-exporter-jaeger/src/version.ts b/packages/opentelemetry-exporter-jaeger/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-exporter-jaeger/src/version.ts +++ b/packages/opentelemetry-exporter-jaeger/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-exporter-prometheus/package.json b/packages/opentelemetry-exporter-prometheus/package.json index cd45cad7b02..58858680062 100644 --- a/packages/opentelemetry-exporter-prometheus/package.json +++ b/packages/opentelemetry-exporter-prometheus/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/exporter-prometheus", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry Exporter Prometheus provides a metrics endpoint for Prometheus", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -42,8 +42,8 @@ }, "devDependencies": { "@types/mocha": "8.0.0", - "@types/node": "14.0.23", - "codecov": "3.7.1", + "@types/node": "14.0.25", + "codecov": "3.7.2", "gts": "2.0.2", "mocha": "7.2.0", "nyc": "15.1.0", @@ -53,9 +53,9 @@ "typescript": "3.9.7" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/metrics": "^0.9.0", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/metrics": "^0.10.0", "prom-client": "^11.5.3" } } diff --git a/packages/opentelemetry-exporter-prometheus/src/version.ts b/packages/opentelemetry-exporter-prometheus/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-exporter-prometheus/src/version.ts +++ b/packages/opentelemetry-exporter-prometheus/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-exporter-zipkin/package.json b/packages/opentelemetry-exporter-zipkin/package.json index 7ffcaeac759..d643a7bc277 100644 --- a/packages/opentelemetry-exporter-zipkin/package.json +++ b/packages/opentelemetry-exporter-zipkin/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/exporter-zipkin", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry Zipkin Exporter allows the user to send collected traces to Zipkin.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -41,8 +41,8 @@ }, "devDependencies": { "@types/mocha": "8.0.0", - "@types/node": "14.0.23", - "codecov": "3.7.1", + "@types/node": "14.0.25", + "codecov": "3.7.2", "gts": "2.0.2", "mocha": "7.2.0", "nock": "12.0.3", @@ -53,9 +53,9 @@ "typescript": "3.9.7" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/resources": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0" + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/resources": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0" } } diff --git a/packages/opentelemetry-exporter-zipkin/src/version.ts b/packages/opentelemetry-exporter-zipkin/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-exporter-zipkin/src/version.ts +++ b/packages/opentelemetry-exporter-zipkin/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-grpc-utils/package.json b/packages/opentelemetry-grpc-utils/package.json index a259a5539f3..f6a26fa0696 100644 --- a/packages/opentelemetry-grpc-utils/package.json +++ b/packages/opentelemetry-grpc-utils/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/grpc-utils", - "version": "0.9.0", + "version": "0.10.0", "private": true, "description": "OpenTelemetry grpc plugin utility functions.", "main": "build/src/index.js", @@ -42,18 +42,18 @@ "access": "public" }, "devDependencies": { - "@grpc/grpc-js": "1.1.2", - "@grpc/proto-loader": "0.5.4", - "@opentelemetry/context-async-hooks": "^0.9.0", - "@opentelemetry/context-base": "^0.9.0", - "@opentelemetry/node": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", + "@grpc/grpc-js": "1.1.3", + "@grpc/proto-loader": "0.5.5", + "@opentelemetry/context-async-hooks": "^0.10.0", + "@opentelemetry/context-base": "^0.10.0", + "@opentelemetry/node": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", "@types/mocha": "7.0.2", - "@types/node": "14.0.13", - "@types/semver": "7.2.0", + "@types/node": "14.0.25", + "@types/semver": "7.3.1", "@types/shimmer": "1.0.1", "@types/sinon": "9.0.4", - "codecov": "3.7.0", + "codecov": "3.7.2", "grpc": "1.24.3", "gts": "2.0.2", "mocha": "7.2.0", @@ -64,12 +64,12 @@ "sinon": "9.0.2", "ts-mocha": "7.0.0", "ts-node": "8.10.2", - "typescript": "3.9.5" + "typescript": "3.9.7" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/semantic-conventions": "^0.9.0", - "shimmer": "^1.2.1" + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/semantic-conventions": "^0.10.0", + "shimmer": "1.2.1" } } diff --git a/packages/opentelemetry-grpc-utils/src/version.ts b/packages/opentelemetry-grpc-utils/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-grpc-utils/src/version.ts +++ b/packages/opentelemetry-grpc-utils/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-metrics/package.json b/packages/opentelemetry-metrics/package.json index 2ce7d6b9761..17ad7de60b8 100644 --- a/packages/opentelemetry-metrics/package.json +++ b/packages/opentelemetry-metrics/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/metrics", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry metrics SDK", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -43,9 +43,9 @@ }, "devDependencies": { "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/sinon": "9.0.4", - "codecov": "3.7.1", + "codecov": "3.7.2", "gts": "2.0.2", "mocha": "7.2.0", "nyc": "15.1.0", @@ -56,8 +56,8 @@ "typescript": "3.9.7" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/resources": "^0.9.0" + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/resources": "^0.10.0" } } diff --git a/packages/opentelemetry-metrics/src/index.ts b/packages/opentelemetry-metrics/src/index.ts index 0be805519a6..2a0c408d71f 100644 --- a/packages/opentelemetry-metrics/src/index.ts +++ b/packages/opentelemetry-metrics/src/index.ts @@ -26,3 +26,4 @@ export * from './export/Batcher'; export * from './export/ConsoleMetricExporter'; export * from './export/types'; export * from './UpDownCounterMetric'; +export { MeterConfig } from './types'; diff --git a/packages/opentelemetry-metrics/src/types.ts b/packages/opentelemetry-metrics/src/types.ts index 0334bac69c8..cc01af9f8d9 100644 --- a/packages/opentelemetry-metrics/src/types.ts +++ b/packages/opentelemetry-metrics/src/types.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { LogLevel } from '@opentelemetry/core'; +import { LogLevel, getEnv } from '@opentelemetry/core'; import * as api from '@opentelemetry/api'; import { MetricExporter } from './export/types'; import { Resource } from '@opentelemetry/resources'; @@ -43,7 +43,7 @@ export interface MeterConfig { /** Default Meter configuration. */ export const DEFAULT_CONFIG = { - logLevel: LogLevel.INFO, + logLevel: getEnv().OTEL_LOG_LEVEL, }; /** The default metric creation options value. */ diff --git a/packages/opentelemetry-metrics/src/version.ts b/packages/opentelemetry-metrics/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-metrics/src/version.ts +++ b/packages/opentelemetry-metrics/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-node/package.json b/packages/opentelemetry-node/package.json index 19a27beb271..f522cdc6a0c 100644 --- a/packages/opentelemetry-node/package.json +++ b/packages/opentelemetry-node/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/node", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry Node SDK provides automatic telemetry (tracing, metrics, etc) for Node.js applications", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -42,13 +42,13 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/context-base": "^0.9.0", - "@opentelemetry/resources": "^0.9.0", + "@opentelemetry/context-base": "^0.10.0", + "@opentelemetry/resources": "^0.10.0", "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/semver": "7.3.1", "@types/shimmer": "1.0.1", - "codecov": "3.7.1", + "codecov": "3.7.2", "gts": "2.0.2", "mocha": "7.2.0", "nyc": "15.1.0", @@ -59,10 +59,10 @@ "typescript": "3.9.7" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/context-async-hooks": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/context-async-hooks": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", "require-in-the-middle": "^5.0.0", "semver": "^7.1.3" } diff --git a/packages/opentelemetry-node/src/index.ts b/packages/opentelemetry-node/src/index.ts index bece472edea..092ae180c97 100644 --- a/packages/opentelemetry-node/src/index.ts +++ b/packages/opentelemetry-node/src/index.ts @@ -14,4 +14,6 @@ * limitations under the License. */ +export { NodeTracerConfig } from './config'; +export { Plugins } from './instrumentation/PluginLoader'; export * from './NodeTracerProvider'; diff --git a/packages/opentelemetry-node/src/version.ts b/packages/opentelemetry-node/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-node/src/version.ts +++ b/packages/opentelemetry-node/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-node/test/NodeTracerProvider.test.ts b/packages/opentelemetry-node/test/NodeTracerProvider.test.ts index 0a42f372ed6..1846819bf4b 100644 --- a/packages/opentelemetry-node/test/NodeTracerProvider.test.ts +++ b/packages/opentelemetry-node/test/NodeTracerProvider.test.ts @@ -114,16 +114,6 @@ describe('NodeTracerProvider', () => { require('http'); assert.strictEqual(plugins.length, 3); }); - - it('should construct an instance with default attributes', () => { - provider = new NodeTracerProvider({ - defaultAttributes: { - region: 'eu-west', - asg: 'my-asg', - }, - }); - assert.ok(provider instanceof NodeTracerProvider); - }); }); describe('.startSpan()', () => { @@ -195,19 +185,6 @@ describe('NodeTracerProvider', () => { assert.strictEqual(span.isRecording(), true); }); - it('should set default attributes on span', () => { - const defaultAttributes = { - foo: 'bar', - }; - provider = new NodeTracerProvider({ - defaultAttributes, - }); - - const span = provider.getTracer('default').startSpan('my-span') as Span; - assert.ok(span instanceof Span); - assert.deepStrictEqual(span.attributes, defaultAttributes); - }); - it('should assign resource to span', () => { provider = new NodeTracerProvider({ logger: new NoopLogger(), diff --git a/packages/opentelemetry-plugin-fetch/package.json b/packages/opentelemetry-plugin-fetch/package.json index fbb3fe79428..e0b366979c4 100644 --- a/packages/opentelemetry-plugin-fetch/package.json +++ b/packages/opentelemetry-plugin-fetch/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/plugin-fetch", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry fetch automatic instrumentation package.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -45,15 +45,15 @@ }, "devDependencies": { "@babel/core": "7.10.5", - "@opentelemetry/context-zone": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", + "@opentelemetry/context-zone": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/shimmer": "1.0.1", "@types/sinon": "7.5.2", "@types/webpack-env": "1.15.2", "babel-loader": "8.1.0", - "codecov": "3.7.1", + "codecov": "3.7.2", "gts": "2.0.2", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.1.0", @@ -70,14 +70,14 @@ "ts-mocha": "7.0.0", "ts-node": "8.10.2", "typescript": "3.9.7", - "webpack": "4.43.0", + "webpack": "4.44.0", "webpack-cli": "3.3.12", "webpack-merge": "5.0.9" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/web": "^0.9.0", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/web": "^0.10.0", "shimmer": "^1.2.1" } } diff --git a/packages/opentelemetry-plugin-fetch/src/version.ts b/packages/opentelemetry-plugin-fetch/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-plugin-fetch/src/version.ts +++ b/packages/opentelemetry-plugin-fetch/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-plugin-grpc-js/package.json b/packages/opentelemetry-plugin-grpc-js/package.json index 5377b374f70..c74188efb0b 100644 --- a/packages/opentelemetry-plugin-grpc-js/package.json +++ b/packages/opentelemetry-plugin-grpc-js/package.json @@ -1,7 +1,6 @@ { "name": "@opentelemetry/plugin-grpc-js", - "private": true, - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry @grpc/grpc-js automatic instrumentation package.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -45,18 +44,18 @@ "access": "public" }, "devDependencies": { - "@grpc/grpc-js": "1.1.2", - "@opentelemetry/context-async-hooks": "^0.9.0", - "@opentelemetry/context-base": "^0.9.0", - "@opentelemetry/grpc-utils": "^0.9.0", - "@opentelemetry/node": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", + "@grpc/grpc-js": "1.1.3", + "@opentelemetry/context-async-hooks": "^0.10.0", + "@opentelemetry/context-base": "^0.10.0", + "@opentelemetry/grpc-utils": "^0.10.0", + "@opentelemetry/node": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/semver": "7.3.1", "@types/shimmer": "1.0.1", "@types/sinon": "9.0.4", - "codecov": "3.7.1", + "codecov": "3.7.2", "gts": "2.0.2", "mocha": "7.2.0", "nyc": "15.1.0", @@ -68,9 +67,9 @@ "typescript": "3.9.7" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/semantic-conventions": "^0.9.0", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/semantic-conventions": "^0.10.0", "shimmer": "1.2.1" } } diff --git a/packages/opentelemetry-plugin-grpc-js/src/version.ts b/packages/opentelemetry-plugin-grpc-js/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-plugin-grpc-js/src/version.ts +++ b/packages/opentelemetry-plugin-grpc-js/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-plugin-grpc/package.json b/packages/opentelemetry-plugin-grpc/package.json index f75165e7a4f..28e2f61ec7a 100644 --- a/packages/opentelemetry-plugin-grpc/package.json +++ b/packages/opentelemetry-plugin-grpc/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/plugin-grpc", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry grpc automatic instrumentation package.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -42,17 +42,17 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/context-async-hooks": "^0.9.0", - "@opentelemetry/context-base": "^0.9.0", - "@opentelemetry/grpc-utils": "^0.9.0", - "@opentelemetry/node": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", + "@opentelemetry/context-async-hooks": "^0.10.0", + "@opentelemetry/context-base": "^0.10.0", + "@opentelemetry/grpc-utils": "^0.10.0", + "@opentelemetry/node": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/semver": "7.3.1", "@types/shimmer": "1.0.1", "@types/sinon": "9.0.4", - "codecov": "3.7.1", + "codecov": "3.7.2", "grpc": "1.24.3", "gts": "2.0.2", "mocha": "7.2.0", @@ -66,9 +66,9 @@ "typescript": "3.9.7" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/semantic-conventions": "^0.9.0", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/semantic-conventions": "^0.10.0", "shimmer": "^1.2.1" } } diff --git a/packages/opentelemetry-plugin-grpc/src/version.ts b/packages/opentelemetry-plugin-grpc/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-plugin-grpc/src/version.ts +++ b/packages/opentelemetry-plugin-grpc/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-plugin-http/package.json b/packages/opentelemetry-plugin-http/package.json index 200e5a33525..9cefa4dd1c3 100644 --- a/packages/opentelemetry-plugin-http/package.json +++ b/packages/opentelemetry-plugin-http/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/plugin-http", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry http automatic instrumentation package.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -42,27 +42,27 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/context-async-hooks": "^0.9.0", - "@opentelemetry/context-base": "^0.9.0", - "@opentelemetry/node": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", + "@opentelemetry/context-async-hooks": "^0.10.0", + "@opentelemetry/context-base": "^0.10.0", + "@opentelemetry/node": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", "@types/got": "9.6.11", "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/request-promise-native": "1.0.17", "@types/semver": "7.3.1", "@types/shimmer": "1.0.1", "@types/sinon": "9.0.4", "@types/superagent": "4.1.8", "axios": "0.19.2", - "codecov": "3.7.1", + "codecov": "3.7.2", "got": "9.6.0", "gts": "2.0.2", "mocha": "7.2.0", "nock": "12.0.3", "nyc": "15.1.0", "request": "2.88.2", - "request-promise-native": "1.0.8", + "request-promise-native": "1.0.9", "rimraf": "3.0.2", "sinon": "9.0.2", "superagent": "5.3.1", @@ -71,9 +71,9 @@ "typescript": "3.9.7" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/semantic-conventions": "^0.9.0", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/semantic-conventions": "^0.10.0", "semver": "^7.1.3", "shimmer": "^1.2.1" } diff --git a/packages/opentelemetry-plugin-http/src/version.ts b/packages/opentelemetry-plugin-http/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-plugin-http/src/version.ts +++ b/packages/opentelemetry-plugin-http/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-plugin-https/package.json b/packages/opentelemetry-plugin-https/package.json index 14495bc2353..6f19e677d97 100644 --- a/packages/opentelemetry-plugin-https/package.json +++ b/packages/opentelemetry-plugin-https/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/plugin-https", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry https automatic instrumentation package.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -42,27 +42,27 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/context-async-hooks": "^0.9.0", - "@opentelemetry/context-base": "^0.9.0", - "@opentelemetry/node": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", + "@opentelemetry/context-async-hooks": "^0.10.0", + "@opentelemetry/context-base": "^0.10.0", + "@opentelemetry/node": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", "@types/got": "9.6.11", "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/request-promise-native": "1.0.17", "@types/semver": "7.3.1", "@types/shimmer": "1.0.1", "@types/sinon": "9.0.4", "@types/superagent": "4.1.8", "axios": "0.19.2", - "codecov": "3.7.1", + "codecov": "3.7.2", "got": "9.6.0", "gts": "2.0.2", "mocha": "7.2.0", "nock": "12.0.3", "nyc": "15.1.0", "request": "2.88.2", - "request-promise-native": "1.0.8", + "request-promise-native": "1.0.9", "rimraf": "3.0.2", "sinon": "9.0.2", "superagent": "5.3.1", @@ -71,10 +71,10 @@ "typescript": "3.9.7" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/plugin-http": "^0.9.0", - "@opentelemetry/semantic-conventions": "^0.9.0", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/plugin-http": "^0.10.0", + "@opentelemetry/semantic-conventions": "^0.10.0", "semver": "^7.1.3", "shimmer": "^1.2.1" } diff --git a/packages/opentelemetry-plugin-https/src/version.ts b/packages/opentelemetry-plugin-https/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-plugin-https/src/version.ts +++ b/packages/opentelemetry-plugin-https/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-plugin-xml-http-request/package.json b/packages/opentelemetry-plugin-xml-http-request/package.json index a8b8d04e44f..9c8ba997055 100644 --- a/packages/opentelemetry-plugin-xml-http-request/package.json +++ b/packages/opentelemetry-plugin-xml-http-request/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/plugin-xml-http-request", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry XMLHttpRequest automatic instrumentation package.", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -45,15 +45,15 @@ }, "devDependencies": { "@babel/core": "7.10.5", - "@opentelemetry/context-zone": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0", + "@opentelemetry/context-zone": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0", "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/shimmer": "1.0.1", "@types/sinon": "9.0.4", "@types/webpack-env": "1.15.2", "babel-loader": "8.1.0", - "codecov": "3.7.1", + "codecov": "3.7.2", "gts": "2.0.2", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.1.0", @@ -70,15 +70,15 @@ "ts-mocha": "7.0.0", "ts-node": "8.10.2", "typescript": "3.9.7", - "webpack": "4.43.0", + "webpack": "4.44.0", "webpack-cli": "3.3.12", "webpack-merge": "5.0.9" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/semantic-conventions": "^0.9.0", - "@opentelemetry/web": "^0.9.0", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/semantic-conventions": "^0.10.0", + "@opentelemetry/web": "^0.10.0", "shimmer": "^1.2.1" } } diff --git a/packages/opentelemetry-plugin-xml-http-request/src/version.ts b/packages/opentelemetry-plugin-xml-http-request/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-plugin-xml-http-request/src/version.ts +++ b/packages/opentelemetry-plugin-xml-http-request/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-resources/package.json b/packages/opentelemetry-resources/package.json index 7deacf8d5ab..8a50ef0bd0d 100644 --- a/packages/opentelemetry-resources/package.json +++ b/packages/opentelemetry-resources/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/resources", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry SDK resources", "main": "build/src/index.js", "browser": { @@ -46,9 +46,9 @@ }, "devDependencies": { "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/sinon": "9.0.4", - "codecov": "3.7.1", + "codecov": "3.7.2", "gts": "2.0.2", "mocha": "7.2.0", "nock": "12.0.3", @@ -60,8 +60,8 @@ "typescript": "3.9.7" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", "gcp-metadata": "^3.5.0" } } diff --git a/packages/opentelemetry-resources/src/version.ts b/packages/opentelemetry-resources/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-resources/src/version.ts +++ b/packages/opentelemetry-resources/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-sdk-node/.eslintignore b/packages/opentelemetry-sdk-node/.eslintignore new file mode 100644 index 00000000000..378eac25d31 --- /dev/null +++ b/packages/opentelemetry-sdk-node/.eslintignore @@ -0,0 +1 @@ +build diff --git a/packages/opentelemetry-sdk-node/.eslintrc.js b/packages/opentelemetry-sdk-node/.eslintrc.js new file mode 100644 index 00000000000..f726f3becb6 --- /dev/null +++ b/packages/opentelemetry-sdk-node/.eslintrc.js @@ -0,0 +1,7 @@ +module.exports = { + "env": { + "mocha": true, + "node": true + }, + ...require('../../eslint.config.js') +} diff --git a/packages/opentelemetry-sdk-node/LICENSE b/packages/opentelemetry-sdk-node/LICENSE new file mode 100644 index 00000000000..5d6f747bfde --- /dev/null +++ b/packages/opentelemetry-sdk-node/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2020 The OpenTelemetry Authors + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/opentelemetry-sdk-node/README.md b/packages/opentelemetry-sdk-node/README.md new file mode 100644 index 00000000000..2db342d0d79 --- /dev/null +++ b/packages/opentelemetry-sdk-node/README.md @@ -0,0 +1,146 @@ +# OpenTelemetry SDK for Node.js + +[![Gitter chat][gitter-image]][gitter-url] +[![NPM Published Version][npm-img]][npm-url] +[![dependencies][dependencies-image]][dependencies-url] +[![devDependencies][devDependencies-image]][devDependencies-url] +[![Apache License][license-image]][license-image] + +This package provides the full OpenTelemetry SDK for Node.js including tracing and metrics. + +## Quick Start + +To get started you need to install `@opentelemetry/sdk-node`, a metrics and/or tracing exporter, and any appropriate plugins for the node modules used by your application. + +### Installation + +```sh +$ # Install the SDK +$ npm install @opentelemetry/sdk-node + +$ # Install exporters and plugins +$ npm install \ + @opentelemetry/exporter-jaeger \ # add tracing exporters as needed + @opentelemetry/exporter-prometheus # add metrics exporters as needed + @opentelemetry/plugin-http # add plugins as needed + +$ # or install all officially supported core and contrib plugins +$ npm install @opentelemetry/plugins-node-all +``` + +> Note: this example is for Node.js. See [examples/tracer-web](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/tracer-web) for a browser example. + +### Initialize the SDK + +Before any other module in your application is loaded, you must initialize the SDK. +If you fail to initialize the SDK or initialize it too late, no-op implementations will be provided to any library which acquires a tracer or meter from the API. +This example uses Jaeger and Prometheus, but exporters exist for [other tracing backends][other-tracing-backends]. + +```javascript +const opentelemetry = require("@opentelemetry/sdk-node"); +const { JaegerExporter } = require("@opentelemetry/exporter-jaeger"); +const { PrometheusExporter } = require("@opentelemetry/exporter-prometheus"); + +const jaegerExporter = new JaegerExporter({ + serviceName: 'my-service', +}); +const prometheusExporter = new PrometheusExporter({ startServer: true }); + +const sdk = new opentelemetry.NodeSDK({ + // Optional - if omitted, the tracing SDK will not be initialized + traceExporter: jaegerExporter, + // Optional - If omitted, the metrics SDK will not be initialized + metricExporter: prometheusExporter, + + // See the Configuration section below for additional configuration options +}); + +// You can optionally detect resources asynchronously from the environment. +// Detected resources are merged with the resources provided in the SDK configuration. +sdk + .start() + .then(() => { + // Resources have been detected and SDK is started + }) +``` + +## Configuration + +Below is a full list of configuration options which may be passed into the `NodeSDK` constructor; + +### autoDetectResources + +Detect resources automatically from the environment using the default resource detectors. Default `true`. + +### contextManager + +Use a custom context manager. Default: [AsyncHooksContextManager](../opentelemetry-context-async-hooks/README.md) + +### httpTextPropagator + +Use a custom propagator. Default: [CompositePropagator](../opentelemetry-core/src/context/propagation/composite.ts) using [W3C Trace Context](../opentelemetry-core/README.md#httptracecontext-propagator) and [Correlation Context](../opentelemetry-core/README.md#correlation-context-propagator) + +### logger + +Use a custom logger. Default: Logging disabled + +### logLevel + +Default: [INFO](../opentelemetry-core/src/common/types.ts#L19) + +### metricBatcher + +Use a custom batcher for metrics. Default: [UngroupedBatcher](../opentelemetry-metrics/src/export/Batcher.ts#L50) + +### metricExporter + +Configure a metric exporter. If an exporter is not configured, the metrics SDK will not be initialized and registered. + +### metricInterval + +Configure an interval for metrics export in ms. Default: 60,000 (60 seconds) + +### plugins + +Configure plugins. By default, all plugins which are installed and in the [Default Plugins List](../opentelemetry-node/src/config.ts#L29) will be enabled. + +### resource + +Configure a resource. Resources may also be detected by using the `autoDetectResources` method of the SDK. + +### sampler + +Configure a custom sampler. By default all traces will be sampled. + +### spanProcessor + +### traceExporter + +Configure a trace exporter. If an exporter OR span processor is not configured, the tracing SDK will not be initialized and registered. If an exporter is configured, it will be used with a [BatchSpanProcessor](../opentelemetry-tracing/src/export/BatchSpanProcessor.ts). + +### traceParams + +Configure tracing parameters. These are the same trace parameters used to [configure a tracer](../opentelemetry-tracing/src/types.ts#L71). + +## Useful links + +- For more information on OpenTelemetry, visit: +- For more about OpenTelemetry JavaScript: +- For help or feedback on this project, join us on [gitter][gitter-url] + +## License + +Apache 2.0 - See [LICENSE][license-url] for more information. + +[gitter-image]: https://badges.gitter.im/open-telemetry/opentelemetry-js.svg +[gitter-url]: https://gitter.im/open-telemetry/opentelemetry-node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge +[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/master/LICENSE +[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat +[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/status.svg?path=packages/opentelemetry-sdk-node +[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-sdk-node +[devDependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/dev-status.svg?path=packages/opentelemetry-sdk-node +[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-sdk-node&type=dev +[npm-url]: https://www.npmjs.com/package/@opentelemetry/sdk-node +[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fsdk-node.svg + +[other-tracing-backends]: https://github.com/open-telemetry/opentelemetry-js#trace-exporters diff --git a/packages/opentelemetry-sdk-node/package.json b/packages/opentelemetry-sdk-node/package.json new file mode 100644 index 00000000000..7815a676447 --- /dev/null +++ b/packages/opentelemetry-sdk-node/package.json @@ -0,0 +1,66 @@ +{ + "name": "@opentelemetry/sdk-node", + "version": "0.9.0", + "description": "OpenTelemetry SDK for Node.js", + "main": "build/src/index.js", + "types": "build/src/index.d.ts", + "repository": "open-telemetry/opentelemetry-js", + "scripts": { + "test": "nyc ts-mocha -p tsconfig.json test/**/*.test.ts", + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../", + "build": "npm run compile", + "lint": "eslint . --ext .ts", + "lint:fix": "eslint . --ext .ts --fix", + "precompile": "tsc --version", + "version:update": "node ../../scripts/version-update.js", + "compile": "npm run version:update && tsc -p .", + "prepare": "npm run compile", + "watch": "tsc -w" + }, + "keywords": [ + "opentelemetry", + "nodejs", + "tracing", + "profiling", + "metrics", + "stats", + "monitoring" + ], + "author": "OpenTelemetry Authors", + "license": "Apache-2.0", + "engines": { + "node": ">=8.0.0" + }, + "files": [ + "build/src/**/*.js", + "build/src/**/*.js.map", + "build/src/**/*.d.ts", + "LICENSE", + "README.md" + ], + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@opentelemetry/api": "0.9.0", + "@opentelemetry/context-base": "0.9.0", + "@opentelemetry/core": "0.9.0", + "@opentelemetry/metrics": "0.9.0", + "@opentelemetry/node": "0.9.0", + "@opentelemetry/resources": "0.9.0", + "@opentelemetry/tracing": "0.9.0" + }, + "devDependencies": { + "@opentelemetry/context-async-hooks": "0.9.0", + "@types/mocha": "7.0.2", + "@types/node": "14.0.13", + "codecov": "3.7.0", + "gts": "2.0.2", + "istanbul-instrumenter-loader": "3.0.1", + "mocha": "7.2.0", + "nyc": "15.1.0", + "ts-loader": "7.0.5", + "ts-mocha": "7.0.0", + "typescript": "3.9.5" + } +} diff --git a/packages/opentelemetry-sdk-node/src/index.ts b/packages/opentelemetry-sdk-node/src/index.ts new file mode 100644 index 00000000000..b511af8046a --- /dev/null +++ b/packages/opentelemetry-sdk-node/src/index.ts @@ -0,0 +1,25 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export * as api from '@opentelemetry/api'; +export * as contextBase from '@opentelemetry/context-base'; +export * as core from '@opentelemetry/core'; +export * as metrics from '@opentelemetry/metrics'; +export * as node from '@opentelemetry/node'; +export * as resources from '@opentelemetry/resources'; +export * as tracing from '@opentelemetry/tracing'; +export * from './sdk'; +export * from './types'; diff --git a/packages/opentelemetry-sdk-node/src/sdk.ts b/packages/opentelemetry-sdk-node/src/sdk.ts new file mode 100644 index 00000000000..3b27e1331ec --- /dev/null +++ b/packages/opentelemetry-sdk-node/src/sdk.ts @@ -0,0 +1,161 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { HttpTextPropagator, metrics } from '@opentelemetry/api'; +import { ContextManager } from '@opentelemetry/context-base'; +import { MeterConfig, MeterProvider } from '@opentelemetry/metrics'; +import { NodeTracerConfig, NodeTracerProvider } from '@opentelemetry/node'; +import { detectResources, Resource } from '@opentelemetry/resources'; +import { BatchSpanProcessor, SpanProcessor } from '@opentelemetry/tracing'; +import { NodeSDKConfiguration } from './types'; + +/** This class represents everything needed to register a fully configured OpenTelemetry Node.js SDK */ +export class NodeSDK { + private _tracerProviderConfig?: { + tracerConfig: NodeTracerConfig; + spanProcessor: SpanProcessor; + contextManager?: ContextManager; + httpTextPropagator?: HttpTextPropagator; + }; + private _meterProviderConfig?: MeterConfig; + + private _resource: Resource; + + private _autoDetectResources: boolean; + + /** + * Create a new NodeJS SDK instance + */ + public constructor(configuration: Partial = {}) { + this._resource = configuration.resource ?? new Resource({}); + + this._autoDetectResources = configuration.autoDetectResources ?? true; + + if (configuration.spanProcessor || configuration.traceExporter) { + const tracerProviderConfig: NodeTracerConfig = {}; + + if (typeof configuration.logLevel === 'number') { + tracerProviderConfig.logLevel = configuration.logLevel; + } + if (configuration.logger) { + tracerProviderConfig.logger = configuration.logger; + } + if (configuration.plugins) { + tracerProviderConfig.plugins = configuration.plugins; + } + if (configuration.sampler) { + tracerProviderConfig.sampler = configuration.sampler; + } + if (configuration.traceParams) { + tracerProviderConfig.traceParams = configuration.traceParams; + } + + const spanProcessor = + configuration.spanProcessor ?? + new BatchSpanProcessor(configuration.traceExporter!); + + this.configureTracerProvider( + tracerProviderConfig, + spanProcessor, + configuration.contextManager, + configuration.httpTextPropagator + ); + } + + if (configuration.metricExporter) { + const meterConfig: MeterConfig = {}; + + if (configuration.metricBatcher) { + meterConfig.batcher = configuration.metricBatcher; + } + if (configuration.metricExporter) { + meterConfig.exporter = configuration.metricExporter; + } + if (typeof configuration.metricInterval === 'number') { + meterConfig.interval = configuration.metricInterval; + } + if (typeof configuration.logLevel === 'number') { + meterConfig.logLevel = configuration.logLevel; + } + if (configuration.logger) { + meterConfig.logger = configuration.logger; + } + + this.configureMeterProvider(meterConfig); + } + } + + /** Set configurations required to register a NodeTracerProvider */ + public configureTracerProvider( + tracerConfig: NodeTracerConfig, + spanProcessor: SpanProcessor, + contextManager?: ContextManager, + httpTextPropagator?: HttpTextPropagator + ) { + this._tracerProviderConfig = { + tracerConfig, + spanProcessor, + contextManager, + httpTextPropagator, + }; + } + + /** Set configurations needed to register a MeterProvider */ + public configureMeterProvider(config: MeterConfig) { + this._meterProviderConfig = config; + } + + /** Detect resource attributes */ + public async detectResources() { + this.addResource(await detectResources()); + } + + /** Manually add a resource */ + public addResource(resource: Resource) { + this._resource = this._resource.merge(resource); + } + + /** + * Once the SDK has been configured, call this method to construct SDK components and register them with the OpenTelemetry API. + */ + public async start() { + if (this._autoDetectResources) { + await this.detectResources(); + } + + if (this._tracerProviderConfig) { + const tracerProvider = new NodeTracerProvider({ + ...this._tracerProviderConfig.tracerConfig, + resource: this._resource, + }); + + tracerProvider.addSpanProcessor(this._tracerProviderConfig.spanProcessor); + tracerProvider.register({ + contextManager: this._tracerProviderConfig.contextManager, + propagator: this._tracerProviderConfig.httpTextPropagator, + }); + } + + if (this._meterProviderConfig) { + const meterProvider = new MeterProvider({ + ...this._meterProviderConfig, + resource: this._resource, + }); + + metrics.setGlobalMeterProvider(meterProvider); + } + } +} diff --git a/packages/opentelemetry-sdk-node/src/types.ts b/packages/opentelemetry-sdk-node/src/types.ts new file mode 100644 index 00000000000..a093cbcfa4c --- /dev/null +++ b/packages/opentelemetry-sdk-node/src/types.ts @@ -0,0 +1,36 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import type { ContextManager } from '@opentelemetry/context-base'; +import type { api, core, metrics, node, resources, tracing } from '.'; + +export interface NodeSDKConfiguration { + autoDetectResources: boolean; + contextManager: ContextManager; + defaultAttributes: api.Attributes; + httpTextPropagator: api.HttpTextPropagator; + logger: api.Logger; + logLevel: core.LogLevel; + metricBatcher: metrics.Batcher; + metricExporter: metrics.MetricExporter; + metricInterval: number; + plugins: node.Plugins; + resource: resources.Resource; + sampler: api.Sampler; + spanProcessor: tracing.SpanProcessor; + traceExporter: tracing.SpanExporter; + traceParams: tracing.TraceParams; +} diff --git a/packages/opentelemetry-sdk-node/src/version.ts b/packages/opentelemetry-sdk-node/src/version.ts new file mode 100644 index 00000000000..2c92beb616c --- /dev/null +++ b/packages/opentelemetry-sdk-node/src/version.ts @@ -0,0 +1,18 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// this is autogenerated file, see scripts/version-update.js +export const VERSION = '0.9.0'; diff --git a/packages/opentelemetry-sdk-node/test/sdk.test.ts b/packages/opentelemetry-sdk-node/test/sdk.test.ts new file mode 100644 index 00000000000..b9d464025df --- /dev/null +++ b/packages/opentelemetry-sdk-node/test/sdk.test.ts @@ -0,0 +1,124 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + context, + metrics, + NoopHttpTextPropagator, + NoopMeterProvider, + NoopTracerProvider, + propagation, + trace, +} from '@opentelemetry/api'; +import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; +import { NoopContextManager } from '@opentelemetry/context-base'; +import { CompositePropagator } from '@opentelemetry/core'; +import { ConsoleMetricExporter, MeterProvider } from '@opentelemetry/metrics'; +import { NodeTracerProvider } from '@opentelemetry/node'; +import { + ConsoleSpanExporter, + SimpleSpanProcessor, +} from '@opentelemetry/tracing'; +import * as assert from 'assert'; +import { NodeSDK } from '../src'; + +describe('Node SDK', () => { + beforeEach(() => { + context.disable(); + trace.disable(); + propagation.disable(); + metrics.disable(); + }); + + describe('Basic Registration', () => { + it('should not register any unconfigured SDK components', async () => { + const sdk = new NodeSDK({ + autoDetectResources: false, + }); + + await sdk.start(); + + assert.ok(context['_getContextManager']() instanceof NoopContextManager); + assert.ok( + propagation['_getGlobalPropagator']() instanceof NoopHttpTextPropagator + ); + + assert.ok(trace.getTracerProvider() instanceof NoopTracerProvider); + assert.ok(metrics.getMeterProvider() instanceof NoopMeterProvider); + }); + + it('should register a tracer provider if an exporter is provided', async () => { + const sdk = new NodeSDK({ + traceExporter: new ConsoleSpanExporter(), + autoDetectResources: false, + }); + + await sdk.start(); + + assert.ok(metrics.getMeterProvider() instanceof NoopMeterProvider); + + assert.ok( + context['_getContextManager']() instanceof AsyncHooksContextManager + ); + assert.ok( + propagation['_getGlobalPropagator']() instanceof CompositePropagator + ); + assert.ok(trace.getTracerProvider() instanceof NodeTracerProvider); + }); + + it('should register a tracer provider if a span processor is provided', async () => { + const exporter = new ConsoleSpanExporter(); + const spanProcessor = new SimpleSpanProcessor(exporter); + + const sdk = new NodeSDK({ + spanProcessor, + autoDetectResources: false, + }); + + await sdk.start(); + + assert.ok(metrics.getMeterProvider() instanceof NoopMeterProvider); + + assert.ok( + context['_getContextManager']() instanceof AsyncHooksContextManager + ); + assert.ok( + propagation['_getGlobalPropagator']() instanceof CompositePropagator + ); + assert.ok(trace.getTracerProvider() instanceof NodeTracerProvider); + }); + + it('should register a meter provider if an exporter is provided', async () => { + const exporter = new ConsoleMetricExporter(); + + const sdk = new NodeSDK({ + metricExporter: exporter, + autoDetectResources: false, + }); + + await sdk.start(); + + assert.ok(context['_getContextManager']() instanceof NoopContextManager); + assert.ok( + propagation['_getGlobalPropagator']() instanceof NoopHttpTextPropagator + ); + + assert.ok(trace.getTracerProvider() instanceof NoopTracerProvider); + + assert.ok(metrics.getMeterProvider() instanceof MeterProvider); + }); + }); +}); diff --git a/packages/opentelemetry-sdk-node/tsconfig.json b/packages/opentelemetry-sdk-node/tsconfig.json new file mode 100644 index 00000000000..a2042cd68b1 --- /dev/null +++ b/packages/opentelemetry-sdk-node/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.base", + "compilerOptions": { + "rootDir": ".", + "outDir": "build" + }, + "include": [ + "src/**/*.ts", + "test/**/*.ts" + ] +} diff --git a/packages/opentelemetry-semantic-conventions/package.json b/packages/opentelemetry-semantic-conventions/package.json index e9f15d734ae..c9a1d960b09 100644 --- a/packages/opentelemetry-semantic-conventions/package.json +++ b/packages/opentelemetry-semantic-conventions/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/semantic-conventions", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry semantic conventions", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -42,9 +42,9 @@ }, "devDependencies": { "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/sinon": "9.0.4", - "codecov": "3.7.1", + "codecov": "3.7.2", "gts": "2.0.2", "mocha": "7.2.0", "nock": "12.0.3", diff --git a/packages/opentelemetry-semantic-conventions/src/version.ts b/packages/opentelemetry-semantic-conventions/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-semantic-conventions/src/version.ts +++ b/packages/opentelemetry-semantic-conventions/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-shim-opentracing/package.json b/packages/opentelemetry-shim-opentracing/package.json index 90f28246164..605484b79f1 100644 --- a/packages/opentelemetry-shim-opentracing/package.json +++ b/packages/opentelemetry-shim-opentracing/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/shim-opentracing", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTracing to OpenTelemetry shim", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -40,10 +40,10 @@ "access": "public" }, "devDependencies": { - "@opentelemetry/tracing": "^0.9.0", + "@opentelemetry/tracing": "^0.10.0", "@types/mocha": "8.0.0", - "@types/node": "14.0.23", - "codecov": "3.7.1", + "@types/node": "14.0.25", + "codecov": "3.7.2", "gts": "2.0.2", "mocha": "7.2.0", "nyc": "15.1.0", @@ -55,8 +55,8 @@ "typescript": "3.9.7" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/core": "^0.9.0", + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/core": "^0.10.0", "opentracing": "^0.14.4" } } diff --git a/packages/opentelemetry-shim-opentracing/src/shim.ts b/packages/opentelemetry-shim-opentracing/src/shim.ts index 14a49f411f5..c5d4417c3a3 100644 --- a/packages/opentelemetry-shim-opentracing/src/shim.ts +++ b/packages/opentelemetry-shim-opentracing/src/shim.ts @@ -19,10 +19,11 @@ import { getExtractedSpanContext, NoopLogger, setExtractedSpanContext, + setCorrelationContext, setActiveSpan, + getCorrelationContext, } from '@opentelemetry/core'; import * as opentracing from 'opentracing'; -import { defaultSetter } from '@opentelemetry/api'; function translateReferences(references: opentracing.Reference[]): api.Link[] { const links: api.Link[] = []; @@ -72,10 +73,15 @@ function getContextWithParent(options: opentracing.SpanOptions) { */ export class SpanContextShim extends opentracing.SpanContext { private readonly _spanContext: api.SpanContext; + private _correlationContext: api.CorrelationContext; - constructor(spanContext: api.SpanContext) { + constructor( + spanContext: api.SpanContext, + correlationContext: api.CorrelationContext + ) { super(); this._spanContext = spanContext; + this._correlationContext = correlationContext; } /** @@ -85,6 +91,13 @@ export class SpanContextShim extends opentracing.SpanContext { return this._spanContext; } + /** + * Returns the underlying {@link api.CorrelationContext} + */ + getCorrelationContext(): api.CorrelationContext { + return this._correlationContext; + } + /** * Returns the trace ID as a string. */ @@ -98,6 +111,16 @@ export class SpanContextShim extends opentracing.SpanContext { toSpanId(): string { return this._spanContext.spanId; } + + getBaggageItem(key: string): string | undefined { + return this._correlationContext[key]?.value; + } + + setBaggageItem(key: string, value: string) { + this._correlationContext = Object.assign({}, this._correlationContext, { + [key]: { value }, + }); + } } /** @@ -125,11 +148,19 @@ export class TracerShim extends opentracing.Tracer { getContextWithParent(options) ); + let correlationContext: api.CorrelationContext = {}; + if (options.childOf instanceof SpanShim) { + const shimContext = options.childOf.context() as SpanContextShim; + correlationContext = shimContext.getCorrelationContext(); + } else if (options.childOf instanceof SpanContextShim) { + correlationContext = options.childOf.getCorrelationContext(); + } + if (options.tags) { span.setAttributes(options.tags); } - return new SpanShim(this, span); + return new SpanShim(this, span, correlationContext); } _inject( @@ -137,17 +168,20 @@ export class TracerShim extends opentracing.Tracer { format: string, carrier: unknown ): void { - const opentelemSpanContext: api.SpanContext = (spanContext as SpanContextShim).getSpanContext(); + const spanContextShim: SpanContextShim = spanContext as SpanContextShim; + const oTelSpanContext: api.SpanContext = spanContextShim.getSpanContext(); + const oTelSpanCorrelationContext: api.CorrelationContext = spanContextShim.getCorrelationContext(); + if (!carrier || typeof carrier !== 'object') return; switch (format) { case opentracing.FORMAT_HTTP_HEADERS: case opentracing.FORMAT_TEXT_MAP: { api.propagation.inject( carrier, - defaultSetter, - setExtractedSpanContext( - api.Context.ROOT_CONTEXT, - opentelemSpanContext + api.defaultSetter, + setCorrelationContext( + setExtractedSpanContext(api.Context.ROOT_CONTEXT, oTelSpanContext), + oTelSpanCorrelationContext ) ); return; @@ -156,7 +190,7 @@ export class TracerShim extends opentracing.Tracer { this._logger.warn( 'OpentracingShim.inject() does not support FORMAT_BINARY' ); - // @todo: Implement binary format + // @todo: Implement binary formats return; } default: @@ -167,13 +201,14 @@ export class TracerShim extends opentracing.Tracer { switch (format) { case opentracing.FORMAT_HTTP_HEADERS: case opentracing.FORMAT_TEXT_MAP: { - const context = getExtractedSpanContext( - api.propagation.extract(carrier) - ); - if (!context) { + const context: api.Context = api.propagation.extract(carrier); + const spanContext = getExtractedSpanContext(context); + const correlationContext = getCorrelationContext(context); + + if (!spanContext) { return null; } - return new SpanContextShim(context); + return new SpanContextShim(spanContext, correlationContext || {}); } case opentracing.FORMAT_BINARY: { // @todo: Implement binary format @@ -191,8 +226,8 @@ export class TracerShim extends opentracing.Tracer { /** * SpanShim wraps an {@link types.Span} and implements the OpenTracing Span API * around it. - * @todo: Out of band baggage propagation is not currently supported. - */ + * + **/ export class SpanShim extends opentracing.Span { // _span is the original OpenTelemetry span that we are wrapping with // an opentracing interface. @@ -200,10 +235,14 @@ export class SpanShim extends opentracing.Span { private readonly _contextShim: SpanContextShim; private readonly _tracerShim: TracerShim; - constructor(tracerShim: TracerShim, span: api.Span) { + constructor( + tracerShim: TracerShim, + span: api.Span, + correlationContext: api.CorrelationContext + ) { super(); this._span = span; - this._contextShim = new SpanContextShim(span.context()); + this._contextShim = new SpanContextShim(span.context(), correlationContext); this._tracerShim = tracerShim; } @@ -295,12 +334,11 @@ export class SpanShim extends opentracing.Span { } getBaggageItem(key: string): string | undefined { - // TODO: should this go into the context? - return undefined; + return this._contextShim.getBaggageItem(key); } setBaggageItem(key: string, value: string): this { - // TODO: should this go into the context? + this._contextShim.setBaggageItem(key, value); return this; } diff --git a/packages/opentelemetry-shim-opentracing/src/version.ts b/packages/opentelemetry-shim-opentracing/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-shim-opentracing/src/version.ts +++ b/packages/opentelemetry-shim-opentracing/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts index 9524045d15a..51b0bdd890b 100644 --- a/packages/opentelemetry-shim-opentracing/test/Shim.test.ts +++ b/packages/opentelemetry-shim-opentracing/test/Shim.test.ts @@ -22,6 +22,8 @@ import { INVALID_SPAN_CONTEXT, timeInputToHrTime, HttpTraceContext, + CompositePropagator, + HttpCorrelationContext, } from '@opentelemetry/core'; import { propagation } from '@opentelemetry/api'; import { performance } from 'perf_hooks'; @@ -32,7 +34,11 @@ describe('OpenTracing Shim', () => { provider.getTracer('default') ); opentracing.initGlobalTracer(shimTracer); - propagation.setGlobalPropagator(new HttpTraceContext()); + const compositePropagator = new CompositePropagator({ + propagators: [new HttpTraceContext(), new HttpCorrelationContext()], + }); + + propagation.setGlobalPropagator(compositePropagator); describe('TracerShim', () => { let span: opentracing.Span; @@ -86,6 +92,25 @@ describe('OpenTracing Shim', () => { /* const extractedContext = shimTracer.extract(opentracing.FORMAT_BINARY, { buffer: new Uint8Array(carrier)}); */ /* assert.strictEqual(context.toSpanId(), extractedContext.toSpanId()) */ }); + + it('injects/extracts a span with baggage', () => { + const carrier: { [key: string]: unknown } = {}; + span.setBaggageItem('baggage1', 'value1'); + span.setBaggageItem('baggage2', 'value2'); + shimTracer.inject(span, opentracing.FORMAT_HTTP_HEADERS, carrier); + const extractedContext = shimTracer.extract( + opentracing.FORMAT_HTTP_HEADERS, + carrier + ) as SpanContextShim; + const childSpan = shimTracer.startSpan('other-span', { + childOf: extractedContext, + }) as SpanShim; + assert.ok(extractedContext !== null); + assert.strictEqual(context.toTraceId(), extractedContext!.toTraceId()); + assert.strictEqual(context.toSpanId(), extractedContext!.toSpanId()); + assert.strictEqual(childSpan.getBaggageItem('baggage1'), 'value1'); + assert.strictEqual(childSpan.getBaggageItem('baggage2'), 'value2'); + }); }); it('creates parent/child relationship using a span object', () => { @@ -135,7 +160,7 @@ describe('OpenTracing Shim', () => { describe('SpanContextShim', () => { it('returns the correct context', () => { - const shim = new SpanContextShim(INVALID_SPAN_CONTEXT); + const shim = new SpanContextShim(INVALID_SPAN_CONTEXT, {}); assert.strictEqual(shim.getSpanContext(), INVALID_SPAN_CONTEXT); assert.strictEqual(shim.toTraceId(), INVALID_SPAN_CONTEXT.traceId); assert.strictEqual(shim.toSpanId(), INVALID_SPAN_CONTEXT.spanId); @@ -190,7 +215,36 @@ describe('OpenTracing Shim', () => { it('can set and retrieve baggage', () => { span.setBaggageItem('baggage', 'item'); - // TODO: baggage + const value = span.getBaggageItem('baggage'); + assert.equal('item', value); + + const childSpan = shimTracer.startSpan('child-span1', { + childOf: span, + }); + childSpan.setBaggageItem('key2', 'item2'); + + // child should have parent baggage items. + assert.equal('item', childSpan.getBaggageItem('baggage')); + assert.equal('item2', childSpan.getBaggageItem('key2')); + + // Parent shouldn't have the child baggage item. + assert.equal(span.getBaggageItem('key2'), undefined); + }); + + it('can set and retrieve baggage with same key', () => { + span.setBaggageItem('key1', 'value1'); + const value = span.getBaggageItem('key1'); + assert.equal('value1', value); + + const childSpan = shimTracer.startSpan('child-span1', { + childOf: span, + }); + childSpan.setBaggageItem('key2', 'value2'); + childSpan.setBaggageItem('key1', 'value3'); + + // child should have parent baggage items. + assert.equal('value3', childSpan.getBaggageItem('key1')); + assert.equal('value2', childSpan.getBaggageItem('key2')); }); }); }); diff --git a/packages/opentelemetry-tracing/package.json b/packages/opentelemetry-tracing/package.json index 294ba5a87de..80498f1f41c 100644 --- a/packages/opentelemetry-tracing/package.json +++ b/packages/opentelemetry-tracing/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/tracing", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry Tracing", "main": "build/src/index.js", "browser": { @@ -51,10 +51,10 @@ }, "devDependencies": { "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/sinon": "9.0.4", "@types/webpack-env": "1.15.2", - "codecov": "3.7.1", + "codecov": "3.7.2", "gts": "2.0.2", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.1.0", @@ -71,12 +71,12 @@ "ts-mocha": "7.0.0", "ts-node": "8.10.2", "typescript": "3.9.7", - "webpack": "4.43.0" + "webpack": "4.44.0" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/context-base": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/resources": "^0.9.0" + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/context-base": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/resources": "^0.10.0" } } diff --git a/packages/opentelemetry-tracing/src/Tracer.ts b/packages/opentelemetry-tracing/src/Tracer.ts index 694829dda03..dc513d6dad2 100644 --- a/packages/opentelemetry-tracing/src/Tracer.ts +++ b/packages/opentelemetry-tracing/src/Tracer.ts @@ -36,7 +36,6 @@ import { mergeConfig } from './utility'; * This class represents a basic tracer. */ export class Tracer implements api.Tracer { - private readonly _defaultAttributes: api.Attributes; private readonly _sampler: api.Sampler; private readonly _traceParams: TraceParams; readonly resource: Resource; @@ -52,7 +51,6 @@ export class Tracer implements api.Tracer { private _tracerProvider: BasicTracerProvider ) { const localConfig = mergeConfig(config); - this._defaultAttributes = localConfig.defaultAttributes; this._sampler = localConfig.sampler; this._traceParams = localConfig.traceParams; this.resource = _tracerProvider.resource; @@ -83,7 +81,7 @@ export class Tracer implements api.Tracer { } const spanKind = options.kind ?? api.SpanKind.INTERNAL; const links = options.links ?? []; - const attributes = { ...this._defaultAttributes, ...options.attributes }; + const attributes = options.attributes ?? {}; // make sampling decision const samplingResult = this._sampler.shouldSample( parentContext, diff --git a/packages/opentelemetry-tracing/src/config.ts b/packages/opentelemetry-tracing/src/config.ts index a1d19ed1251..180dda3d771 100644 --- a/packages/opentelemetry-tracing/src/config.ts +++ b/packages/opentelemetry-tracing/src/config.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { AlwaysOnSampler, LogLevel } from '@opentelemetry/core'; +import { AlwaysOnSampler, getEnv } from '@opentelemetry/core'; /** Default limit for Message events per span */ export const DEFAULT_MAX_EVENTS_PER_SPAN = 128; @@ -30,8 +30,7 @@ export const DEFAULT_MAX_LINKS_PER_SPAN = 32; * used to extend the default value. */ export const DEFAULT_CONFIG = { - defaultAttributes: {}, - logLevel: LogLevel.INFO, + logLevel: getEnv().OTEL_LOG_LEVEL, sampler: new AlwaysOnSampler(), traceParams: { numberOfAttributesPerSpan: DEFAULT_MAX_ATTRIBUTES_PER_SPAN, diff --git a/packages/opentelemetry-tracing/src/types.ts b/packages/opentelemetry-tracing/src/types.ts index c6eeae35d0d..78b631faf99 100644 --- a/packages/opentelemetry-tracing/src/types.ts +++ b/packages/opentelemetry-tracing/src/types.ts @@ -14,12 +14,7 @@ * limitations under the License. */ -import { - Attributes, - HttpTextPropagator, - Logger, - Sampler, -} from '@opentelemetry/api'; +import { HttpTextPropagator, Logger, Sampler } from '@opentelemetry/api'; import { LogLevel } from '@opentelemetry/core'; import { ContextManager } from '@opentelemetry/context-base'; import { Resource } from '@opentelemetry/resources'; @@ -28,12 +23,6 @@ import { Resource } from '@opentelemetry/resources'; * TracerConfig provides an interface for configuring a Basic Tracer. */ export interface TracerConfig { - /** - * Attributes that will be applied on every span created by Tracer. - * Useful to add infrastructure and environment information to your spans. - */ - defaultAttributes?: Attributes; - /** * User provided logger. */ diff --git a/packages/opentelemetry-tracing/src/version.ts b/packages/opentelemetry-tracing/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-tracing/src/version.ts +++ b/packages/opentelemetry-tracing/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; diff --git a/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts b/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts index 159a98bbfd7..5933d04fd42 100644 --- a/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts +++ b/packages/opentelemetry-tracing/test/BasicTracerProvider.test.ts @@ -102,13 +102,8 @@ describe('BasicTracerProvider', () => { }); }); - it('should construct an instance with default attributes', () => { - const tracer = new BasicTracerProvider({ - defaultAttributes: { - region: 'eu-west', - asg: 'my-asg', - }, - }); + it('should construct an instance of BasicTracerProvider', () => { + const tracer = new BasicTracerProvider(); assert.ok(tracer instanceof BasicTracerProvider); }); }); @@ -142,10 +137,8 @@ describe('BasicTracerProvider', () => { span.end(); }); - it('should start a span with defaultAttributes and spanoptions->attributes', () => { - const tracer = new BasicTracerProvider({ - defaultAttributes: { foo: 'bar' }, - }).getTracer('default'); + it('should start a span with given attributes', () => { + const tracer = new BasicTracerProvider().getTracer('default'); const span = tracer.startSpan('my-span', { attributes: { foo: 'foo', bar: 'bar' }, }) as Span; @@ -153,15 +146,6 @@ describe('BasicTracerProvider', () => { span.end(); }); - it('should start a span with defaultAttributes and undefined spanoptions->attributes', () => { - const tracer = new BasicTracerProvider({ - defaultAttributes: { foo: 'bar' }, - }).getTracer('default'); - const span = tracer.startSpan('my-span', {}) as Span; - assert.deepStrictEqual(span.attributes, { foo: 'bar' }); - span.end(); - }); - it('should start a span with spanoptions->attributes', () => { const tracer = new BasicTracerProvider().getTracer('default'); const span = tracer.startSpan('my-span', { @@ -317,19 +301,6 @@ describe('BasicTracerProvider', () => { assert.strictEqual(span.isRecording(), true); }); - it('should set default attributes on span', () => { - const defaultAttributes = { - foo: 'bar', - }; - const tracer = new BasicTracerProvider({ - defaultAttributes, - }).getTracer('default'); - - const span = tracer.startSpan('my-span') as Span; - assert.ok(span instanceof Span); - assert.deepStrictEqual(span.attributes, defaultAttributes); - }); - it('should assign a resource', () => { const tracer = new BasicTracerProvider().getTracer('default'); const span = tracer.startSpan('my-span') as Span; diff --git a/packages/opentelemetry-web/package.json b/packages/opentelemetry-web/package.json index a796fb1faf0..8b66f4f36e3 100644 --- a/packages/opentelemetry-web/package.json +++ b/packages/opentelemetry-web/package.json @@ -1,6 +1,6 @@ { "name": "@opentelemetry/web", - "version": "0.9.0", + "version": "0.10.0", "description": "OpenTelemetry Web Tracer", "main": "build/src/index.js", "types": "build/src/index.d.ts", @@ -44,15 +44,15 @@ }, "devDependencies": { "@babel/core": "7.10.5", - "@opentelemetry/context-zone": "^0.9.0", - "@opentelemetry/resources": "^0.9.0", + "@opentelemetry/context-zone": "^0.10.0", + "@opentelemetry/resources": "^0.10.0", "@types/jquery": "3.5.0", "@types/mocha": "8.0.0", - "@types/node": "14.0.23", + "@types/node": "14.0.25", "@types/sinon": "9.0.4", "@types/webpack-env": "1.15.2", "babel-loader": "8.1.0", - "codecov": "3.7.1", + "codecov": "3.7.2", "gts": "2.0.2", "istanbul-instrumenter-loader": "3.0.1", "karma": "5.1.0", @@ -70,15 +70,15 @@ "ts-mocha": "7.0.0", "ts-node": "8.10.2", "typescript": "3.9.7", - "webpack": "4.43.0", + "webpack": "4.44.0", "webpack-cli": "3.3.12", "webpack-merge": "5.0.9" }, "dependencies": { - "@opentelemetry/api": "^0.9.0", - "@opentelemetry/context-base": "^0.9.0", - "@opentelemetry/core": "^0.9.0", - "@opentelemetry/semantic-conventions": "^0.9.0", - "@opentelemetry/tracing": "^0.9.0" + "@opentelemetry/api": "^0.10.0", + "@opentelemetry/context-base": "^0.10.0", + "@opentelemetry/core": "^0.10.0", + "@opentelemetry/semantic-conventions": "^0.10.0", + "@opentelemetry/tracing": "^0.10.0" } } diff --git a/packages/opentelemetry-web/src/version.ts b/packages/opentelemetry-web/src/version.ts index 2c92beb616c..aa9b19601b8 100644 --- a/packages/opentelemetry-web/src/version.ts +++ b/packages/opentelemetry-web/src/version.ts @@ -15,4 +15,4 @@ */ // this is autogenerated file, see scripts/version-update.js -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0';