1717import * as assert from 'assert' ;
1818import { NoopSpan , Sampler , SamplingDecision } from '@opentelemetry/api' ;
1919import { BasicTracerProvider , Tracer , Span } from '../src' ;
20- import { NoopLogger , ALWAYS_SAMPLER , NEVER_SAMPLER } from '@opentelemetry/core' ;
20+ import {
21+ InstrumentationLibrary ,
22+ NoopLogger ,
23+ ALWAYS_SAMPLER ,
24+ NEVER_SAMPLER ,
25+ } from '@opentelemetry/core' ;
2126
2227describe ( 'Tracer' , ( ) => {
2328 const tracerProvider = new BasicTracerProvider ( {
@@ -36,28 +41,52 @@ describe('Tracer', () => {
3641 }
3742
3843 it ( 'should create a Tracer instance' , ( ) => {
39- const tracer = new Tracer ( { } , tracerProvider ) ;
44+ const tracer = new Tracer ( 'default' , '0.0.1' , { } , tracerProvider ) ;
4045 assert . ok ( tracer instanceof Tracer ) ;
4146 } ) ;
4247
4348 it ( 'should respect NO_RECORD sampling result' , ( ) => {
44- const tracer = new Tracer ( { sampler : NEVER_SAMPLER } , tracerProvider ) ;
49+ const tracer = new Tracer (
50+ 'default' ,
51+ '0.0.1' ,
52+ { sampler : NEVER_SAMPLER } ,
53+ tracerProvider
54+ ) ;
4555 const span = tracer . startSpan ( 'span1' ) ;
4656 assert . ok ( span instanceof NoopSpan ) ;
4757 span . end ( ) ;
4858 } ) ;
4959
5060 it ( 'should respect RECORD_AND_SAMPLE sampling result' , ( ) => {
51- const tracer = new Tracer ( { sampler : ALWAYS_SAMPLER } , tracerProvider ) ;
61+ const tracer = new Tracer (
62+ 'default' ,
63+ '0.0.1' ,
64+ { sampler : ALWAYS_SAMPLER } ,
65+ tracerProvider
66+ ) ;
5267 const span = tracer . startSpan ( 'span2' ) ;
5368 assert . ok ( ! ( span instanceof NoopSpan ) ) ;
5469 span . end ( ) ;
5570 } ) ;
5671
5772 it ( 'should start a span with attributes in sampling result' , ( ) => {
58- const tracer = new Tracer ( { sampler : new TestSampler ( ) } , tracerProvider ) ;
73+ const tracer = new Tracer (
74+ 'default' ,
75+ '0.0.1' ,
76+ { sampler : new TestSampler ( ) } ,
77+ tracerProvider
78+ ) ;
5979 const span = tracer . startSpan ( 'span3' ) ;
6080 assert . strictEqual ( ( span as Span ) . attributes . testAttribute , 'foobar' ) ;
6181 span . end ( ) ;
6282 } ) ;
83+
84+ it ( 'should have an instrumentationLibrary' , ( ) => {
85+ const tracer = new Tracer ( 'default' , '0.0.1' , { } , tracerProvider ) ;
86+
87+ const lib : InstrumentationLibrary = tracer . instrumentationLibrary ;
88+
89+ assert . strictEqual ( lib . name , 'default' ) ;
90+ assert . strictEqual ( lib . version , '0.0.1' ) ;
91+ } ) ;
6392} ) ;
0 commit comments