-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Split metric and trace exporters into new experimental packages (
#2485) Co-authored-by: Daniel Dyla <dyladan@users.noreply.github.com> Co-authored-by: Valentin Marchaud <contact@vmarchaud.fr> Co-authored-by: Rauno Viskus <Rauno56@users.noreply.github.com>
- Loading branch information
1 parent
4e311bd
commit c307949
Showing
157 changed files
with
2,911 additions
and
889 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
[submodule "experimental/packages/opentelemetry-exporter-otlp-proto/protos"] | ||
path = experimental/packages/opentelemetry-exporter-otlp-proto/protos | ||
[submodule "experimental/packages/opentelemetry-exporter-trace-otlp-proto/protos"] | ||
path = experimental/packages/opentelemetry-exporter-trace-otlp-proto/protos | ||
url = https://github.com/open-telemetry/opentelemetry-proto.git | ||
[submodule "experimental/packages/opentelemetry-exporter-otlp-grpc/protos"] | ||
path = experimental/packages/opentelemetry-exporter-otlp-grpc/protos | ||
[submodule "experimental/packages/opentelemetry-exporter-trace-otlp-grpc/protos"] | ||
path = experimental/packages/opentelemetry-exporter-trace-otlp-grpc/protos | ||
url = https://github.com/open-telemetry/opentelemetry-proto.git | ||
[submodule "experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/protos"] | ||
path = experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/protos | ||
url = https://github.com/open-telemetry/opentelemetry-proto.git | ||
[submodule "experimental/packages/opentelemetry-exporter-metrics-otlp-proto/protos"] | ||
path = experimental/packages/opentelemetry-exporter-metrics-otlp-proto/protos | ||
url = https://github.com/open-telemetry/opentelemetry-proto.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
77 changes: 77 additions & 0 deletions
77
experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# OpenTelemetry Collector Metrics Exporter for node with grpc | ||
|
||
[![NPM Published Version][npm-img]][npm-url] | ||
[![dependencies][dependencies-image]][dependencies-url] | ||
[![devDependencies][devDependencies-image]][devDependencies-url] | ||
[![Apache License][license-image]][license-image] | ||
|
||
This module provides exporter for web and node to be used with [opentelemetry-collector][opentelemetry-collector-url] - last tested with version **0.25.0**. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install --save @opentelemetry/exporter-metrics-otlp-grpc | ||
``` | ||
|
||
## Service Name | ||
|
||
The OpenTelemetry Collector Exporter does not have a service name configuration. | ||
In order to set the service name, use the `service.name` resource attribute as prescribed in the [OpenTelemetry Resource Semantic Conventions][semconv-resource-service-name]. | ||
To see sample code and documentation for the traces exporter, as well as instructions for using TLS, visit the [Collector Trace Exporter for web and node][trace-exporter-url]. | ||
|
||
## Metrics in Node - GRPC | ||
|
||
The OTLPTraceExporter in Node expects the URL to only be the hostname. It will not work with `/v1/metrics`. All options that work with trace also work with metrics. | ||
|
||
```js | ||
const { MeterProvider } = require('@opentelemetry/sdk-metrics-base'); | ||
const { OTLPMetricExporter } = require('@opentelemetry/exporter-metrics-otlp-grpc'); | ||
const collectorOptions = { | ||
// url is optional and can be omitted - default is grpc://localhost:4317 | ||
url: 'grpc://<collector-hostname>:<port>', | ||
}; | ||
const exporter = new OTLPMetricExporter(collectorOptions); | ||
|
||
// Register the exporter | ||
const provider = new MeterProvider({ | ||
exporter, | ||
interval: 60000, | ||
}) | ||
['SIGINT', 'SIGTERM'].forEach(signal => { | ||
process.on(signal, () => provider.shutdown().catch(console.error)); | ||
}); | ||
|
||
// Now, start recording data | ||
const meter = provider.getMeter('example-meter'); | ||
const counter = meter.createCounter('metric_name'); | ||
counter.add(10, { 'key': 'value' }); | ||
``` | ||
|
||
## Running opentelemetry-collector locally to see the metrics | ||
|
||
1. Go to examples/otlp-exporter-node | ||
2. run `npm run docker:start` | ||
3. Open page at `http://localhost:9411/zipkin/` to observe the metrics | ||
|
||
## Useful links | ||
|
||
- For more information on OpenTelemetry, visit: <https://opentelemetry.io/> | ||
- For more about OpenTelemetry JavaScript: <https://github.com/open-telemetry/opentelemetry-js> | ||
- For help or feedback on this project, join us in [GitHub Discussions][discussions-url] | ||
|
||
## License | ||
|
||
Apache 2.0 - See [LICENSE][license-url] for more information. | ||
|
||
[discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions | ||
[license-url]: https://github.com/open-telemetry/opentelemetry-js/blob/main/LICENSE | ||
[license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat | ||
[dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=experimental%2Fpackages%2Fopentelemetry-exporter-metrics-otlp-grpc | ||
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=experimental%2Fpackages%2Fopentelemetry-exporter-metrics-otlp-grpc | ||
[devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js.svg?path=experimental%2Fpackages%2Fopentelemetry-exporter-metrics-otlp-grpc&type=dev | ||
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=experimental%2Fpackages%2Fopentelemetry-exporter-metrics-otlp-grpc&type=dev | ||
[npm-url]: https://www.npmjs.com/package/@opentelemetry/exporter-metrics-otlp-grpc | ||
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fexporter-metrics-otlp-grpc.svg | ||
[opentelemetry-collector-url]: https://github.com/open-telemetry/opentelemetry-collector | ||
[semconv-resource-service-name]: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#service | ||
[trace-exporter-url]: https://github.com/open-telemetry/opentelemetry-js/tree/main/packages/opentelemetry-exporter-trace-otlp-grpc |
79 changes: 79 additions & 0 deletions
79
experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"name": "@opentelemetry/exporter-metrics-otlp-grpc", | ||
"version": "0.26.0", | ||
"description": "OpenTelemetry Collector Metrics Exporter allows user to send collected metrics to the OpenTelemetry Collector", | ||
"main": "build/src/index.js", | ||
"types": "build/src/index.d.ts", | ||
"repository": "open-telemetry/opentelemetry-js", | ||
"scripts": { | ||
"compile": "tsc --build", | ||
"clean": "tsc --build --clean", | ||
"lint": "eslint . --ext .ts", | ||
"lint:fix": "eslint . --ext .ts --fix", | ||
"postcompile": "npm run submodule && npm run protos:copy", | ||
"protos:copy": "cpx protos/opentelemetry/**/*.* build/protos/opentelemetry", | ||
"submodule": "git submodule sync --recursive && git submodule update --init --recursive", | ||
"tdd": "npm run test -- --watch-extensions ts --watch", | ||
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'", | ||
"version": "node ../../../scripts/version-update.js", | ||
"watch": "npm run protos:copy && tsc -w", | ||
"precompile": "lerna run version --scope $(npm pkg get name) --include-filtered-dependencies", | ||
"prewatch": "npm run precompile" | ||
}, | ||
"keywords": [ | ||
"opentelemetry", | ||
"nodejs", | ||
"grpc", | ||
"tracing", | ||
"profiling", | ||
"metrics", | ||
"stats" | ||
], | ||
"author": "OpenTelemetry Authors", | ||
"license": "Apache-2.0", | ||
"engines": { | ||
"node": ">=8.0.0" | ||
}, | ||
"files": [ | ||
"build/src/**/*.js", | ||
"build/src/**/*.js.map", | ||
"build/src/**/*.d.ts", | ||
"build/protos/**/*.proto", | ||
"doc", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.15.0", | ||
"@opentelemetry/api": "^1.0.3", | ||
"@opentelemetry/api-metrics": "0.26.0", | ||
"@types/mocha": "8.2.3", | ||
"@types/node": "14.17.11", | ||
"@types/sinon": "10.0.2", | ||
"codecov": "3.8.3", | ||
"cpx": "1.5.0", | ||
"mocha": "7.2.0", | ||
"nyc": "15.1.0", | ||
"rimraf": "3.0.2", | ||
"sinon": "11.1.2", | ||
"ts-loader": "8.3.0", | ||
"ts-mocha": "8.0.0", | ||
"typescript": "4.3.5" | ||
}, | ||
"peerDependencies": { | ||
"@opentelemetry/api": "^1.0.3" | ||
}, | ||
"dependencies": { | ||
"@grpc/grpc-js": "^1.3.7", | ||
"@grpc/proto-loader": "^0.6.4", | ||
"@opentelemetry/core": "1.0.0", | ||
"@opentelemetry/exporter-metrics-otlp-http": "0.26.0", | ||
"@opentelemetry/exporter-trace-otlp-http": "0.26.0", | ||
"@opentelemetry/exporter-trace-otlp-grpc": "0.26.0", | ||
"@opentelemetry/sdk-metrics-base": "0.26.0", | ||
"@opentelemetry/resources": "1.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,4 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
export * from './OTLPTraceExporter'; | ||
export * from './OTLPMetricExporter'; |
45 changes: 45 additions & 0 deletions
45
experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/submodule.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Important | ||
|
||
**Submodule is always pointing to certain revision number. So updating the submodule repo will not have impact on your code. | ||
Knowing this if you want to change the submodule to point to a different version (when for example proto has changed) here is how to do it:** | ||
|
||
## Updating submodule to point to certain revision number | ||
|
||
1. Make sure you are in the same folder as this instruction | ||
|
||
2. Update your submodules by running this command | ||
|
||
```shell script | ||
git submodule sync --recursive | ||
git submodule update --init --recursive | ||
``` | ||
|
||
3. Find the commit SHA which you want to update to and copy it (the long one) | ||
|
||
4. Enter a submodule directory from this directory | ||
|
||
```shell script | ||
cd protos | ||
``` | ||
|
||
5. Updates files in the submodule tree to given commit: | ||
|
||
```shell script | ||
git checkout -q <sha> | ||
``` | ||
|
||
6. Return to the main directory: | ||
|
||
```shell script | ||
cd ../ | ||
``` | ||
|
||
7. Please run `git status` you should see something like `Head detached at`. This is correct, go to next step | ||
|
||
8. Now thing which is very important. You have to commit this to apply these changes | ||
|
||
```shell script | ||
git commit -am "chore: updating submodule for opentelemetry-proto" | ||
``` | ||
|
||
9. If you look now at git log you will notice that the folder `protos` has been changed and it will show what was the previous sha and what is current one. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.