Skip to content

Commit

Permalink
Merge branch 'main' into fix-1774
Browse files Browse the repository at this point in the history
  • Loading branch information
obecny committed May 17, 2021
2 parents e5304cf + e379e59 commit 82525a8
Show file tree
Hide file tree
Showing 485 changed files with 8,451 additions and 15,397 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/peer-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Ensure API Peer Dependency

on:
push:
branches:
- main
pull_request:

jobs:
peer-api-check:
runs-on: ubuntu-latest
container:
image: node:14
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install lerna
run: npm install -g lerna

- name: Check API dependency semantics
run: lerna exec "node ../../scripts/peer-api-check.js"
159 changes: 159 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ npm run lint:fix

### Adding a package

To add a new package, copy `packages/template` to your new package directory and modify the `package.json` file to reflect your desired package settings. If the package will not support browser, the `karma.conf` file may be deleted. If the package will support es5 targets, the reference to `tsconfig.base.json` in `tsconfig.json` should be changed to `tsconfig.es5.json`.
To add a new package, copy `packages/template` to your new package directory and modify the `package.json` file to reflect your desired package settings. If the package will not support browser, the `karma.conf` and `tsconifg.esm.json` files may be deleted. If the package will support es5 targets, the reference to `tsconfig.base.json` in `tsconfig.json` should be changed to `tsconfig.es5.json`.

After adding the package, run `npm install` from the root of the project. This will update the `tsconfig.json` project references automatically and install all dependencies in your new package.
After adding the package, run `npm install` from the root of the project. This will update the `tsconfig.json` project references automatically and install all dependencies in your new package. For packages supporting browser, file `tsconfig.esm.json` needs to be manually updated to include reference to ES modules build.

### Guidelines for Pull Requests

Expand Down
138 changes: 65 additions & 73 deletions README.md

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions backwards-compatability/node10/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "backcompat-node10",
"version": "0.18.0",
"version": "0.19.0",
"private": true,
"description": "Backwards compatability app for node8 types and the OpenTelemetry Node.js SDK",
"main": "index.js",
"scripts": {
"test:backcompat": "tsc --noEmit index.ts"
},
"dependencies": {
"@opentelemetry/sdk-node": "^0.18.0",
"@opentelemetry/tracing": "^0.18.0"
"@opentelemetry/sdk-node": "0.19.0",
"@opentelemetry/tracing": "0.19.0"
},
"devDependencies": {
"@types/node": "10.17.50",
"typescript": "4.1.3"
"@types/node": "10.17.59",
"typescript": "4.2.4"
},
"author": "OpenTelemetry Authors",
"license": "Apache-2.0"
Expand Down
10 changes: 5 additions & 5 deletions backwards-compatability/node12/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "backcompat-node12",
"version": "0.18.0",
"version": "0.19.0",
"private": true,
"description": "Backwards compatability app for node8 types and the OpenTelemetry Node.js SDK",
"main": "index.js",
"scripts": {
"test:backcompat": "tsc --noEmit index.ts"
},
"dependencies": {
"@opentelemetry/sdk-node": "^0.18.0",
"@opentelemetry/tracing": "^0.18.0"
"@opentelemetry/sdk-node": "0.19.0",
"@opentelemetry/tracing": "0.19.0"
},
"devDependencies": {
"@types/node": "12.19.13",
"typescript": "4.1.3"
"@types/node": "12.20.11",
"typescript": "4.2.4"
},
"author": "OpenTelemetry Authors",
"license": "Apache-2.0"
Expand Down
8 changes: 4 additions & 4 deletions backwards-compatability/node8/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "backcompat-node8",
"version": "0.18.0",
"version": "0.19.0",
"private": true,
"description": "Backwards compatability app for node8 types and the OpenTelemetry Node.js SDK",
"main": "index.js",
"scripts": {
"test:backcompat": "tsc --noEmit index.ts"
},
"dependencies": {
"@opentelemetry/sdk-node": "^0.18.0",
"@opentelemetry/tracing": "^0.18.0"
"@opentelemetry/sdk-node": "0.19.0",
"@opentelemetry/tracing": "0.19.0"
},
"devDependencies": {
"@types/node": "8.10.66",
"typescript": "4.1.3"
"typescript": "4.2.4"
},
"author": "OpenTelemetry Authors",
"license": "Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Beginning B3Propagator Benchmark...
#Inject x 2,018,725 ops/sec ±3.49% (100 runs sampled)
#Extract x 2,040,891 ops/sec ±1.75% (100 runs sampled)
Beginning HttpTraceContext Benchmark...
Beginning HttpTraceContextPropagator Benchmark...
2 tests completed.
#Inject x 3,987,007 ops/sec ±1.87% (100 runs sampled)
Expand Down Expand Up @@ -112,7 +112,7 @@ Beginning B3Propagator Benchmark...
#Inject x 5,086,366 ops/sec ±3.18% (100 runs sampled)
#Extract x 4,859,557 ops/sec ±3.80% (100 runs sampled)
Beginning HttpTraceContext Benchmark...
Beginning HttpTraceContextPropagator Benchmark...
2 tests completed.
#Inject x 13,660,710 ops/sec ±1.84% (100 runs sampled)
Expand Down
4 changes: 2 additions & 2 deletions benchmark/propagator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const setups = [
}
},
{
name: 'HttpTraceContext',
propagator: new opentelemetry.HttpTraceContext(),
name: 'HttpTraceContextPropagator',
propagator: new opentelemetry.HttpTraceContextPropagator(),
injectCarrier: {},
extractCarrier: {
traceparent: '00-d4cda95b652f4a1592b449d5929fda1b-6e0c63257de34c92-00'
Expand Down
55 changes: 7 additions & 48 deletions doc/instrumentation-guide.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,11 @@
# Instrumentation Developer Guide

We provide out-of-the-box instrumentations for many popular frameworks and libraries by using an instrumentation system (see [builtin instrumentations][builtin-instrumentations]), and provide a means for developers to create their own.
A detailed explained guide how to instrument a package is available at [instrumentation package][base-instrumentation]

We strongly recommended to create a dedicated package for newly added plugin, example: `@opentelemetry/plugin-xxx`.
For more comprehensive examples please refer to the [HTTP instrumentation][http-instrumentation] or [gRPC instrumentation][grpc-instrumentation] for node
and [XMLHttpRequest instrumentation][xhr-instrumentation] for web.

Each plugin must extend the abstract class [BasePlugin][base-plugin] implementing the below methods:

- `patch`: A function describing how the module exports for a given file should be modified.

- `unpatch`: A function describing how the module exports for a given file should be unpatched. This should generally mirror the logic in `patch`; for example, if `patch` wraps a method, `unpatch` should unwrap it.

The core `PluginLoader` class is responsible for loading the instrumented plugins that use a patch mechanism to enable automatic tracing for specific target modules. In order to load new plugin, it should export `plugin` identifier.

```typescript
export const plugin = new HttpPlugin(...);
```

> Example of simple module plugin created and used in the tests.
<https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-node/test/instrumentation/node_modules/%40opentelemetry/plugin-simple-module/simple-module.js>
After the plugin is created, it must be added in the [list of default supported plugins][DEFAULT_INSTRUMENTATION_PLUGINS].

```typescript
export const DEFAULT_INSTRUMENTATION_PLUGINS: Plugins = {
http: {
enabled: true,
path: '@opentelemetry/plugin-http',
},
grpc: {
enabled: true,
path: '@opentelemetry/plugin-grpc',
},
// [ADD NEW PLUGIN HERE]
xxx: {
enabled: true,
// You may use a package name or absolute path to the file.
path: '@opentelemetry/plugin-xxx',
}
};
```

We recommend using [`shimmer`][shimmer] to modify function properties on objects.

Please refer to the [HTTP instrumentation][http-plugin] or [gRPC instrumentation][grpc-plugin] for more comprehensive examples.

[shimmer]: https://github.com/othiym23/shimmer
[builtin-instrumentations]: https://github.com/open-telemetry/opentelemetry-js#instrumentations&plugins
[base-plugin]: https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-core/src/platform/node/BasePlugin.ts
[http-plugin]: https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-plugin-http/src/http.ts#L44
[grpc-plugin]: https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-plugin-grpc/src/grpc.ts#L52
[DEFAULT_INSTRUMENTATION_PLUGINS]: https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-node/src/config.ts#L29
[base-instrumentation]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-instrumentation
[http-instrumentation]: https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-instrumentation-http/src/http.ts#L59
[grpc-instrumentation]: https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-instrumentation-grpc/src/instrumentation.ts#L28
[xhr-instrumentation]: https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts#L71
25 changes: 14 additions & 11 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,30 @@ module.exports = {
"header"
],
extends: [
"./node_modules/gts",
"./node_modules/gts",
],
parser: "@typescript-eslint/parser",
parserOptions: {
"project": "./tsconfig.json"
"project": "./tsconfig.json"
},
rules: {
"@typescript-eslint/no-floating-promises": 2,
"@typescript-eslint/no-this-alias": "off",
"eqeqeq": [
"error",
"smart"
],
"prefer-rest-params": "off",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "memberLike",
"modifiers": ["private", "protected"],
"format": ["camelCase"],
"leadingUnderscore": "require"
}
"error",
{
"selector": "memberLike",
"modifiers": ["private", "protected"],
"format": ["camelCase"],
"leadingUnderscore": "require"
}
],
"no-console": "error",
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["warn"],
"@typescript-eslint/no-unused-vars": ["error", {"argsIgnorePattern": "^_", "args": "after-used"}],
Expand All @@ -34,8 +36,8 @@ module.exports = {
"prettier/prettier": ["error", { "singleQuote": true, "arrowParens": "avoid" }],
"node/no-deprecated-api": ["warn"],
"header/header": [2, "block", [{
pattern: / \* Copyright The OpenTelemetry Authors[\r\n]+ \*[\r\n]+ \* Licensed under the Apache License, Version 2\.0 \(the \"License\"\);[\r\n]+ \* you may not use this file except in compliance with the License\.[\r\n]+ \* You may obtain a copy of the License at[\r\n]+ \*[\r\n]+ \* https:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0[\r\n]+ \*[\r\n]+ \* Unless required by applicable law or agreed to in writing, software[\r\n]+ \* distributed under the License is distributed on an \"AS IS\" BASIS,[\r\n]+ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.[\r\n]+ \* See the License for the specific language governing permissions and[\r\n]+ \* limitations under the License\./gm,
template:
pattern: / \* Copyright The OpenTelemetry Authors[\r\n]+ \*[\r\n]+ \* Licensed under the Apache License, Version 2\.0 \(the \"License\"\);[\r\n]+ \* you may not use this file except in compliance with the License\.[\r\n]+ \* You may obtain a copy of the License at[\r\n]+ \*[\r\n]+ \* https:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0[\r\n]+ \*[\r\n]+ \* Unless required by applicable law or agreed to in writing, software[\r\n]+ \* distributed under the License is distributed on an \"AS IS\" BASIS,[\r\n]+ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.[\r\n]+ \* See the License for the specific language governing permissions and[\r\n]+ \* limitations under the License\./gm,
template:
`\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n `
}]]
},
Expand All @@ -47,6 +49,7 @@ module.exports = {
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-floating-promises": 1,
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-shadow": ["off"],
Expand Down
8 changes: 4 additions & 4 deletions examples/basic-tracer-node/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "example-basic-tracer-node",
"private": true,
"version": "0.18.0",
"version": "0.19.0",
"description": "Example of using @opentelemetry/tracing in Node.js",
"main": "index.js",
"scripts": {
Expand All @@ -24,9 +24,9 @@
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
},
"dependencies": {
"@opentelemetry/api": "^0.18.0",
"@opentelemetry/exporter-jaeger": "^0.18.0",
"@opentelemetry/tracing": "^0.18.0"
"@opentelemetry/api": "^1.0.0-rc.0",
"@opentelemetry/exporter-jaeger": "0.19.0",
"@opentelemetry/tracing": "0.19.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js#readme"
}
5 changes: 2 additions & 3 deletions examples/collector-exporter-node/docker/collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ exporters:

processors:
batch:
queued_retry:

service:
pipelines:
traces:
receivers: [otlp]
exporters: [zipkin]
processors: [batch, queued_retry]
processors: [batch]
metrics:
receivers: [otlp]
exporters: [prometheus]
processors: [batch, queued_retry]
processors: [batch]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"
services:
# Collector
collector:
image: otel/opentelemetry-collector:0.16.0
image: otel/opentelemetry-collector:0.25.0
# image: otel/opentelemetry-collector:latest
command: ["--config=/conf/collector-config.yaml", "--log-level=DEBUG"]
volumes:
Expand Down
16 changes: 8 additions & 8 deletions examples/collector-exporter-node/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "example-collector-exporter-node",
"private": true,
"version": "0.18.0",
"version": "0.19.0",
"description": "Example of using @opentelemetry/collector-exporter in Node.js",
"main": "index.js",
"scripts": {
Expand All @@ -28,13 +28,13 @@
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
},
"dependencies": {
"@opentelemetry/api": "^0.18.0",
"@opentelemetry/core": "^0.18.0",
"@opentelemetry/exporter-collector": "^0.18.0",
"@opentelemetry/exporter-collector-grpc": "^0.18.0",
"@opentelemetry/exporter-collector-proto": "^0.18.0",
"@opentelemetry/metrics": "^0.18.0",
"@opentelemetry/tracing": "^0.18.0"
"@opentelemetry/api": "^1.0.0-rc.0",
"@opentelemetry/core": "0.19.0",
"@opentelemetry/exporter-collector": "0.19.0",
"@opentelemetry/exporter-collector-grpc": "0.19.0",
"@opentelemetry/exporter-collector-proto": "0.19.0",
"@opentelemetry/metrics": "0.19.0",
"@opentelemetry/tracing": "0.19.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js#readme"
}
18 changes: 9 additions & 9 deletions examples/grpc-js/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grpc-js-example",
"private": true,
"version": "0.18.0",
"version": "0.19.0",
"description": "Example of @grpc/grpc-js integration with OpenTelemetry",
"main": "index.js",
"scripts": {
Expand All @@ -28,14 +28,14 @@
"url": "https://github.com/open-telemetry/opentelemetry-js/issues"
},
"dependencies": {
"@grpc/grpc-js": "^1.0.5",
"@opentelemetry/api": "^0.18.0",
"@opentelemetry/exporter-jaeger": "^0.18.0",
"@opentelemetry/exporter-zipkin": "^0.18.0",
"@opentelemetry/instrumentation": "^0.18.0",
"@opentelemetry/node": "^0.18.0",
"@opentelemetry/plugin-grpc-js": "^0.18.0",
"@opentelemetry/tracing": "^0.18.0",
"@grpc/grpc-js": "^1.2.12",
"@opentelemetry/api": "^1.0.0-rc.0",
"@opentelemetry/exporter-jaeger": "0.19.0",
"@opentelemetry/exporter-zipkin": "0.19.0",
"@opentelemetry/instrumentation": "0.19.0",
"@opentelemetry/instrumentation-grpc": "0.19.0",
"@opentelemetry/node": "0.19.0",
"@opentelemetry/tracing": "0.19.0",
"google-protobuf": "^3.9.2"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js#readme",
Expand Down

0 comments on commit 82525a8

Please sign in to comment.