Skip to content

Commit

Permalink
feat: add basic tracer usage (open-telemetry#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 authored Sep 11, 2019
1 parent 260a5e6 commit 66da9a4
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions packages/opentelemetry-basic-tracer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,28 @@ npm install --save @opentelemetry/basic-tracer
## Usage

```
const opentelemetry = require('@opentelemetry/basic-tracer');
const opentelemetry = require('@opentelemetry/core');
const { BasicTracer } = require('@opentelemetry/basic-tracer');
const { NoopScopeManager } = require('@opentelemetry/scope-base');
// To start a trace, you first need to initialize the Tracer.
// NOTE: the default OpenTelemetry tracer does not record any tracing information.
const tracer = new BasicTracer({
scopeManager: new NoopScopeManager()
});
// Initialize the OpenTelemetry APIs to use the BasicTracer bindings
opentelemetry.initGlobalTracer(tracer);
// To create a span in a trace, we used the global singleton tracer to start a new span.
const span = opentelemetry.getTracer().startSpan('foo');
// Create an Attributes
span.setAttribute('key', 'value');
// We must end the spans so they becomes available for exporting.
span.end();
// TODO: DEMONSTRATE API
```

## Useful links
Expand Down

0 comments on commit 66da9a4

Please sign in to comment.