@@ -64,74 +64,97 @@ describe('BasicTracerProvider', () => {
64
64
} ) ;
65
65
66
66
describe ( 'constructor' , ( ) => {
67
- it ( 'should construct an instance without any options' , ( ) => {
68
- const provider = new BasicTracerProvider ( ) ;
69
- assert . ok ( provider instanceof BasicTracerProvider ) ;
70
- } ) ;
67
+ describe ( 'when options not defined' , ( ) => {
68
+ it ( 'should construct an instance' , ( ) => {
69
+ const tracer = new BasicTracerProvider ( ) ;
70
+ assert . ok ( tracer instanceof BasicTracerProvider ) ;
71
+ } ) ;
71
72
72
- it ( 'should construct an instance with sampler ' , ( ) => {
73
- const provider = new BasicTracerProvider ( {
74
- sampler : new AlwaysOnSampler ( ) ,
73
+ it ( 'should use noop span processor by default ' , ( ) => {
74
+ const tracer = new BasicTracerProvider ( ) ;
75
+ assert . ok ( tracer . activeSpanProcessor instanceof NoopSpanProcessor ) ;
75
76
} ) ;
76
- assert . ok ( provider instanceof BasicTracerProvider ) ;
77
77
} ) ;
78
78
79
- it ( 'should construct an instance with default span limits ', ( ) => {
80
- const tracer = new BasicTracerProvider ( { } ) . getTracer ( 'default' ) ;
81
- assert . deepStrictEqual ( tracer . getSpanLimits ( ) , {
82
- attributeCountLimit : 128 ,
83
- eventCountLimit : 128 ,
84
- linkCountLimit : 128 ,
79
+ describe ( 'when "sampler" option defined ', ( ) => {
80
+ it ( 'should have an instance with sampler' , ( ) => {
81
+ const tracer = new BasicTracerProvider ( {
82
+ sampler : new AlwaysOnSampler ( ) ,
83
+ } ) ;
84
+ assert . ok ( tracer instanceof BasicTracerProvider ) ;
85
85
} ) ;
86
86
} ) ;
87
87
88
- it ( 'should construct an instance with customized attributeCountLimit span limits' , ( ) => {
89
- const tracer = new BasicTracerProvider ( {
90
- spanLimits : {
91
- attributeCountLimit : 100 ,
92
- } ,
93
- } ) . getTracer ( 'default' ) ;
94
- assert . deepStrictEqual ( tracer . getSpanLimits ( ) , {
95
- attributeCountLimit : 100 ,
96
- eventCountLimit : 128 ,
97
- linkCountLimit : 128 ,
88
+ describe ( 'spanLimits' , ( ) => {
89
+ describe ( 'when not defined default values' , ( ) => {
90
+ it ( 'should have tracer with default values' , ( ) => {
91
+ const tracer = new BasicTracerProvider ( { } ) . getTracer ( 'default' ) ;
92
+ assert . deepStrictEqual ( tracer . getSpanLimits ( ) , {
93
+ attributeValueLengthLimit : Infinity ,
94
+ attributeCountLimit : 128 ,
95
+ eventCountLimit : 128 ,
96
+ linkCountLimit : 128 ,
97
+ } ) ;
98
+ } ) ;
98
99
} ) ;
99
- } ) ;
100
100
101
- it ( 'should construct an instance with customized eventCountLimit span limits ', ( ) => {
102
- const tracer = new BasicTracerProvider ( {
103
- spanLimits : {
104
- eventCountLimit : 300 ,
105
- } ,
106
- } ) . getTracer ( 'default' ) ;
107
- assert . deepStrictEqual ( tracer . getSpanLimits ( ) , {
108
- attributeCountLimit : 128 ,
109
- eventCountLimit : 300 ,
110
- linkCountLimit : 128 ,
101
+ describe ( 'when "attributeCountLimit" is defined ', ( ) => {
102
+ it ( 'should have tracer with defined value' , ( ) => {
103
+ const tracer = new BasicTracerProvider ( {
104
+ spanLimits : {
105
+ attributeCountLimit : 100 ,
106
+ } ,
107
+ } ) . getTracer ( 'default' ) ;
108
+ const spanLimits = tracer . getSpanLimits ( ) ;
109
+ assert . strictEqual ( spanLimits . attributeCountLimit , 100 ) ;
110
+ } ) ;
111
111
} ) ;
112
- } ) ;
113
112
114
- it ( 'should construct an instance with customized linkCountLimit span limits' , ( ) => {
115
- const tracer = new BasicTracerProvider ( {
116
- spanLimits : {
117
- linkCountLimit : 10 ,
118
- } ,
119
- } ) . getTracer ( 'default' ) ;
120
- assert . deepStrictEqual ( tracer . getSpanLimits ( ) , {
121
- attributeCountLimit : 128 ,
122
- eventCountLimit : 128 ,
123
- linkCountLimit : 10 ,
113
+ describe ( 'when "attributeValueLengthLimit" is defined' , ( ) => {
114
+ it ( 'should have tracer with defined value' , ( ) => {
115
+ const tracer = new BasicTracerProvider ( {
116
+ spanLimits : {
117
+ attributeValueLengthLimit : 10 ,
118
+ } ,
119
+ } ) . getTracer ( 'default' ) ;
120
+ const spanLimits = tracer . getSpanLimits ( ) ;
121
+ assert . strictEqual ( spanLimits . attributeValueLengthLimit , 10 ) ;
122
+ } ) ;
123
+
124
+ it ( 'should have tracer with negative "attributeValueLengthLimit" value' , ( ) => {
125
+ const tracer = new BasicTracerProvider ( {
126
+ spanLimits : {
127
+ attributeValueLengthLimit : - 10 ,
128
+ } ,
129
+ } ) . getTracer ( 'default' ) ;
130
+ const spanLimits = tracer . getSpanLimits ( ) ;
131
+ assert . strictEqual ( spanLimits . attributeValueLengthLimit , - 10 ) ;
132
+ } ) ;
124
133
} ) ;
125
- } ) ;
126
134
127
- it ( 'should construct an instance of BasicTracerProvider' , ( ) => {
128
- const tracer = new BasicTracerProvider ( ) ;
129
- assert . ok ( tracer instanceof BasicTracerProvider ) ;
130
- } ) ;
135
+ describe ( 'when "eventCountLimit" is defined' , ( ) => {
136
+ it ( 'should have tracer with defined value' , ( ) => {
137
+ const tracer = new BasicTracerProvider ( {
138
+ spanLimits : {
139
+ eventCountLimit : 300 ,
140
+ } ,
141
+ } ) . getTracer ( 'default' ) ;
142
+ const spanLimits = tracer . getSpanLimits ( ) ;
143
+ assert . strictEqual ( spanLimits . eventCountLimit , 300 ) ;
144
+ } ) ;
145
+ } ) ;
131
146
132
- it ( 'should use noop span processor by default' , ( ) => {
133
- const tracer = new BasicTracerProvider ( ) ;
134
- assert . ok ( tracer . activeSpanProcessor instanceof NoopSpanProcessor ) ;
147
+ describe ( 'when "linkCountLimit" is defined' , ( ) => {
148
+ it ( 'should have tracer with defined value' , ( ) => {
149
+ const tracer = new BasicTracerProvider ( {
150
+ spanLimits : {
151
+ linkCountLimit : 10 ,
152
+ } ,
153
+ } ) . getTracer ( 'default' ) ;
154
+ const spanLimits = tracer . getSpanLimits ( ) ;
155
+ assert . strictEqual ( spanLimits . linkCountLimit , 10 ) ;
156
+ } ) ;
157
+ } ) ;
135
158
} ) ;
136
159
} ) ;
137
160
0 commit comments