Skip to content

Commit

Permalink
fix importing the library with typescript (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
rochdev authored Feb 22, 2019
1 parent e06ea71 commit 8a5e633
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,5 @@ package-lock.json
yarn.lock
out
versions
docs/test.js
!test/node_modules
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "typedoc.js",
"scripts": {
"build": "typedoc",
"test": "tsc --noEmit test"
"test": "tsc test && node test"
},
"license": "BSD-3-Clause",
"private": true,
Expand Down
17 changes: 10 additions & 7 deletions docs/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { HTTP_HEADERS } from '../ext/formats';

let span: Span;
let context: SpanContext;
let scope: Scope;
let traceId: string;
let spanId: string;

Expand Down Expand Up @@ -92,12 +91,6 @@ tracer.use('router');
tracer.use('when');
tracer.use('winston');

tracer.inject(span || span.context(), HTTP_HEADERS, {});
context = tracer.extract(HTTP_HEADERS, {});

traceId = context.toTraceId();
spanId = context.toSpanId();

span = tracer.startSpan('test');
span = tracer.startSpan('test', {});
span = tracer.startSpan('test', {
Expand All @@ -109,6 +102,16 @@ span = tracer.startSpan('test', {
}
});

const carrier = {}

tracer.inject(span || span.context(), HTTP_HEADERS, carrier);
context = tracer.extract(HTTP_HEADERS, carrier);

traceId = context.toTraceId();
spanId = context.toSpanId();

const scope = tracer.scope()

span = scope.active();

scope.activate(span, () => {});
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ const TracerProxy = require('./src/proxy')
platform.use(node)

module.exports = new TracerProxy()
module.exports.default = module.exports
module.exports.tracer = module.exports

0 comments on commit 8a5e633

Please sign in to comment.