-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into add-express-plugin
- Loading branch information
Showing
216 changed files
with
873 additions
and
447 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
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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Overview | ||
|
||
OpenTelemetry IORedis Instrumentation allows the user to automatically collect trace data and export them to the backend(s) of choice (Jaeger in this example). | ||
|
||
## Tracing backend setup | ||
|
||
### Jaeger | ||
|
||
- Setup [Jaeger Tracing](https://www.jaegertracing.io/docs/latest/getting-started/#all-in-one) | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install | ||
``` | ||
|
||
## Run the Application | ||
|
||
- Start redis via docker | ||
|
||
```sh | ||
npm run docker:start | ||
``` | ||
|
||
- Run the main program | ||
|
||
```sh | ||
npm run start | ||
``` | ||
|
||
- Cleanup docker | ||
|
||
```sh | ||
npm run docker:stop | ||
``` | ||
|
||
## LICENSE | ||
|
||
Apache License 2.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
// Require tracer before any other modules | ||
require('./tracer'); | ||
const Redis = require('ioredis'); | ||
|
||
const redis = new Redis(); | ||
|
||
async function main() { | ||
try { | ||
await redis.set('test', 'data'); | ||
process.exit(0); | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
main(); |
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,40 @@ | ||
{ | ||
"name": "ioredis-example", | ||
"private": true, | ||
"version": "0.3.3", | ||
"description": "Example of HTTP integration with OpenTelemetry", | ||
"main": "index.js", | ||
"scripts": { | ||
"docker:start": "docker run -d -p 6379:6379 --name otjsredis redis:alpine", | ||
"docker:stop": "docker stop otjsredis && docker rm otjsredis", | ||
"start": "node index.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://[email protected]/open-telemetry/opentelemetry-js.git" | ||
}, | ||
"keywords": [ | ||
"opentelemetry", | ||
"redis", | ||
"ioredis", | ||
"tracing" | ||
], | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"author": "OpenTelemetry Authors", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/open-telemetry/opentelemetry-js/issues" | ||
}, | ||
"dependencies": { | ||
"@opentelemetry/core": "^0.3.3", | ||
"@opentelemetry/exporter-jaeger": "^0.3.3", | ||
"@opentelemetry/node": "^0.3.3", | ||
"@opentelemetry/plugin-ioredis": "^0.3.3", | ||
"@opentelemetry/tracing": "^0.3.3", | ||
"ioredis": "^4.14.1" | ||
}, | ||
"homepage": "https://github.com/open-telemetry/opentelemetry-js#readme", | ||
"devDependencies": {} | ||
} |
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,17 @@ | ||
'use strict'; | ||
|
||
const opentelemetry = require('@opentelemetry/core'); | ||
const { NodeTracerRegistry } = require('@opentelemetry/node'); | ||
const { SimpleSpanProcessor } = require('@opentelemetry/tracing'); | ||
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger'); | ||
|
||
const tracerRegistry = new NodeTracerRegistry(); | ||
|
||
const exporter = new JaegerExporter({ serviceName: 'ioredis-example' }); | ||
|
||
tracerRegistry.addSpanProcessor(new SimpleSpanProcessor(exporter)); | ||
|
||
// Initialize the OpenTelemetry APIs to use the BasicTracer bindings | ||
opentelemetry.initGlobalTracerRegistry(tracerRegistry); | ||
|
||
module.exports = opentelemetry.getTracer(); |
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
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.
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,123 @@ | ||
# OpenTelemetry API for JavaScript | ||
[![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 everything needed to interact with the OpenTelemetry API, including all TypeScript interfaces, enums, and no-op implementations. It is intended for use both on the server and in the browser. | ||
|
||
## Basic Use | ||
|
||
### API Entry Point | ||
|
||
API entry points are defined as global singleton objects `trace` and `metrics` which contain methods used to initialize SDK implementations and acquire resources from the API. | ||
|
||
- [Trace API Documentation][trace-api-docs] | ||
- [Metrics API Documentation][metrics-api-docs] | ||
|
||
```javascript | ||
const api = require("@opentelemetry/api") | ||
|
||
/* Initialize TraceRegistry */ | ||
api.trace.initGlobalTracerRegistry(traceRegistry); | ||
/* returns traceRegistry (no-op if a working registry has not been initialized) */ | ||
api.trace.getTracerRegistry(); | ||
/* returns a tracer from the registered global tracer registry (no-op if a working registry has not been initialized); */ | ||
api.trace.getTracer(name, version); | ||
|
||
/* Initialize MeterRegistry */ | ||
api.metrics.initGlobalMeterRegistry(meterRegistry); | ||
/* returns meterRegistry (no-op if a working registry has not been initialized) */ | ||
api.metrics.getMeterRegistry(); | ||
/* returns a meter from the registered global meter registry (no-op if a working registry has not been initialized); */ | ||
api.metrics.getMeter(name, version); | ||
``` | ||
|
||
### Application Owners | ||
|
||
Application owners will also need a working OpenTelemetry SDK implementation. OpenTelemetry provides working SDK implementations for [web] and [node] for both [tracing] and [metrics]. | ||
|
||
#### Simple NodeJS Example | ||
|
||
Before any other module in your application is loaded, you must initialize the global tracer and meter registries. If you fail to initialize a registry, no-op implementations will be provided to any library which acquires them from the API. | ||
|
||
```javascript | ||
const api = require("@opentelemetry/api"); | ||
const sdk = require("@opentelemetry/node"); | ||
|
||
const { SimpleSpanProcessor } = require('@opentelemetry/tracing'); | ||
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger'); | ||
|
||
// Initialize an exporter | ||
const exporter = new JaegerExporter({ | ||
serviceName: 'basic-service' | ||
}); | ||
|
||
// Create a registry which we will configure as the global tracer registry | ||
const registry = new sdk.NodeTracerRegistry(); | ||
|
||
// Configure span processor to send spans to the exporter | ||
registry.addSpanProcessor(new SimpleSpanProcessor(exporter)); | ||
|
||
// Initialize the OpenTelemetry APIs to use the NodeTracerRegistry bindings | ||
api.trace.initGlobalTracerRegistry(registry); | ||
|
||
// your application code below this line | ||
``` | ||
|
||
### Library Authors | ||
|
||
Library authors need only to depend on the `@opentelemetry/api` package and trust that the application owners which use their library will initialize an appropriate SDK. | ||
|
||
```javascript | ||
const api = require("@opentelemetry/api"); | ||
|
||
const tracer = api.trace.getTracer("my-library-name", "0.2.3"); | ||
|
||
async function doSomething() { | ||
const span = tracer.startSpan("doSomething", { parent: tracer.getCurrentSpan() }); | ||
try { | ||
const result = await doSomethingElse(); | ||
span.end(); | ||
return result; | ||
} catch (err) { | ||
span.setStatus({ | ||
// use an appropriate status code here | ||
code: api.CanonicalCode.INTERNAL, | ||
message: err.message, | ||
}); | ||
span.end(); | ||
return null; | ||
} | ||
} | ||
``` | ||
|
||
|
||
## 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 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-api | ||
[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-api | ||
[devDependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js/dev-status.svg?path=packages/opentelemetry-api | ||
[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js?path=packages%2Fopentelemetry-api&type=dev | ||
[npm-url]: https://www.npmjs.com/package/@opentelemetry/api | ||
[npm-img]: https://badge.fury.io/js/%40opentelemetry%2Ftypes.svg | ||
|
||
[trace-api-docs]: https://open-telemetry.github.io/opentelemetry-js/classes/traceapi.html | ||
[metrics-api-docs]: https://open-telemetry.github.io/opentelemetry-js/classes/metricsapi.html | ||
|
||
[web]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-web | ||
[tracing]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-tracing | ||
[node]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-node | ||
[metrics]: https://github.com/open-telemetry/opentelemetry-js/tree/master/packages/opentelemetry-metrics |
Oops, something went wrong.