Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Export SpanOptions (#94)
Browse files Browse the repository at this point in the history
* expose span options

* only improt index.ts in the tests + use SpanOptions type in mock_tracer
  • Loading branch information
eli-jordan authored and yurishkuro committed Feb 26, 2018
1 parent 1b32dfd commit caffd2d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as Noop from './noop';
import Reference from './reference';
import Span from './span';
import SpanContext from './span_context';
import Tracer from './tracer';
import {SpanOptions, Tracer} from './tracer';

import {MockTracer} from './mock_tracer';

Expand All @@ -14,6 +14,7 @@ export {
SpanContext,
Span,
Tracer,
SpanOptions,
Tags,
MockTracer
};
Expand Down
6 changes: 3 additions & 3 deletions src/mock_tracer/mock_tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class MockTracer extends opentracing.Tracer {
// OpenTracing implementation
//------------------------------------------------------------------------//

protected _startSpan(name: string, fields: { [key: string]: any }): MockSpan {
protected _startSpan(name: string, fields: opentracing.SpanOptions): MockSpan {
// _allocSpan is given it's own method so that derived classes can
// allocate any type of object they want, but not have to duplicate
// the other common logic in startSpan().
Expand All @@ -24,8 +24,8 @@ export class MockTracer extends opentracing.Tracer {
this._spans.push(span);

if (fields.references) {
for (let i = 0; i < fields.references; i++) {
span.addReference(fields.references[i]);
for (const ref of fields.references) {
span.addReference(ref);
}
}

Expand Down
10 changes: 4 additions & 6 deletions src/test/opentracing_api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

import { expect } from 'chai';
import * as opentracing from '../index';
import Span from '../span';
import { SpanOptions, Tracer } from '../tracer';

export function opentracingAPITests(): void {
describe('Opentracing API', () => {
Expand Down Expand Up @@ -42,10 +40,10 @@ export function opentracingAPITests(): void {
}

describe('global tracer', () => {
const dummySpan = new Span();
const dummySpan = new opentracing.Span();

afterEach(() => {
opentracing.initGlobalTracer(new Tracer());
opentracing.initGlobalTracer(new opentracing.Tracer());
});

it('should use the global tracer', () => {
Expand All @@ -55,8 +53,8 @@ export function opentracingAPITests(): void {
expect(span).to.equal(dummySpan);
});

class TestTracer extends Tracer {
protected _startSpan(name: string, fields: SpanOptions): Span {
class TestTracer extends opentracing.Tracer {
protected _startSpan(name: string, fields: opentracing.SpanOptions): opentracing.Span {
return dummySpan;
}
}
Expand Down

0 comments on commit caffd2d

Please sign in to comment.