@@ -208,6 +208,108 @@ describe('BasicTracerProvider', () => {
208208 } ) ;
209209 } ) ;
210210
211+ describe ( 'when attribute value length limit is defined via env' , ( ) => {
212+ it ( 'should have general attribute value length limits value as defined with env' , ( ) => {
213+ envSource . OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '115' ;
214+ const tracer = new BasicTracerProvider ( ) . getTracer ( 'default' ) ;
215+ const generalLimits = tracer . getGeneralLimits ( ) ;
216+ assert . strictEqual ( generalLimits . attributeValueLengthLimit , 115 ) ;
217+ delete envSource . OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT ;
218+ } ) ;
219+ it ( 'should have span attribute value length limit value same as general limit value' , ( ) => {
220+ envSource . OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '125' ;
221+ const tracer = new BasicTracerProvider ( ) . getTracer ( 'default' ) ;
222+ const generalLimits = tracer . getGeneralLimits ( ) ;
223+ const spanLimits = tracer . getSpanLimits ( ) ;
224+ assert . strictEqual ( generalLimits . attributeValueLengthLimit , 125 ) ;
225+ assert . strictEqual ( spanLimits . attributeValueLengthLimit , 125 ) ;
226+ delete envSource . OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT ;
227+ } ) ;
228+ it ( 'should have span and general attribute value length limits as defined in env' , ( ) => {
229+ envSource . OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '125' ;
230+ envSource . OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT = '109' ;
231+ const tracer = new BasicTracerProvider ( ) . getTracer ( 'default' ) ;
232+ const spanLimits = tracer . getSpanLimits ( ) ;
233+ const generalLimits = tracer . getGeneralLimits ( ) ;
234+ assert . strictEqual ( generalLimits . attributeValueLengthLimit , 125 ) ;
235+ assert . strictEqual ( spanLimits . attributeValueLengthLimit , 109 ) ;
236+ delete envSource . OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT ;
237+ delete envSource . OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT ;
238+ } ) ;
239+ it ( 'should have span attribute value length limit as deafult of Infinity' , ( ) => {
240+ envSource . OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT = '125' ;
241+ envSource . OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT = 'Infinity' ;
242+ const tracer = new BasicTracerProvider ( ) . getTracer ( 'default' ) ;
243+ const spanLimits = tracer . getSpanLimits ( ) ;
244+ const generalLimits = tracer . getGeneralLimits ( ) ;
245+ assert . strictEqual ( generalLimits . attributeValueLengthLimit , 125 ) ;
246+ assert . strictEqual ( spanLimits . attributeValueLengthLimit , Infinity ) ;
247+ delete envSource . OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT ;
248+ delete envSource . OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT ;
249+ } ) ;
250+ } ) ;
251+
252+ describe ( 'when attribute value length limit is not defined via env' , ( ) => {
253+ it ( 'should use default value of Infinity' , ( ) => {
254+ const tracer = new BasicTracerProvider ( ) . getTracer ( 'default' ) ;
255+ const spanLimits = tracer . getSpanLimits ( ) ;
256+ const generalLimits = tracer . getGeneralLimits ( ) ;
257+ assert . strictEqual ( generalLimits . attributeValueLengthLimit , Infinity ) ;
258+ assert . strictEqual ( spanLimits . attributeValueLengthLimit , Infinity ) ;
259+ } ) ;
260+ } ) ;
261+
262+ describe ( 'when attribute count limit is defined via env' , ( ) => {
263+ it ( 'should general attribute count limit as defined with env' , ( ) => {
264+ envSource . OTEL_ATTRIBUTE_COUNT_LIMIT = '25' ;
265+ const tracer = new BasicTracerProvider ( { } ) . getTracer ( 'default' ) ;
266+ const generalLimits = tracer . getGeneralLimits ( ) ;
267+ assert . strictEqual ( generalLimits . attributeCountLimit , 25 ) ;
268+ delete envSource . OTEL_ATTRIBUTE_COUNT_LIMIT ;
269+ } ) ;
270+ it ( 'should have span attribute count limit value same as general limit value' , ( ) => {
271+ envSource . OTEL_ATTRIBUTE_COUNT_LIMIT = '20' ;
272+ const tracer = new BasicTracerProvider ( ) . getTracer ( 'default' ) ;
273+ const generalLimits = tracer . getGeneralLimits ( ) ;
274+ const spanLimits = tracer . getSpanLimits ( ) ;
275+ assert . strictEqual ( generalLimits . attributeCountLimit , 20 ) ;
276+ assert . strictEqual ( spanLimits . attributeCountLimit , 20 ) ;
277+ delete envSource . OTEL_ATTRIBUTE_COUNT_LIMIT ;
278+ } ) ;
279+ it ( 'should have span and general attribute count limits as defined in env' , ( ) => {
280+ envSource . OTEL_ATTRIBUTE_COUNT_LIMIT = '20' ;
281+ envSource . OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = '35' ;
282+ const tracer = new BasicTracerProvider ( ) . getTracer ( 'default' ) ;
283+ const spanLimits = tracer . getSpanLimits ( ) ;
284+ const generalLimits = tracer . getGeneralLimits ( ) ;
285+ assert . strictEqual ( generalLimits . attributeCountLimit , 20 ) ;
286+ assert . strictEqual ( spanLimits . attributeCountLimit , 35 ) ;
287+ delete envSource . OTEL_ATTRIBUTE_COUNT_LIMIT ;
288+ delete envSource . OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT ;
289+ } ) ;
290+ it ( 'should have span attribute count limit as default of 128' , ( ) => {
291+ envSource . OTEL_ATTRIBUTE_COUNT_LIMIT = '20' ;
292+ envSource . OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT = '128' ;
293+ const tracer = new BasicTracerProvider ( ) . getTracer ( 'default' ) ;
294+ const spanLimits = tracer . getSpanLimits ( ) ;
295+ const generalLimits = tracer . getGeneralLimits ( ) ;
296+ assert . strictEqual ( generalLimits . attributeCountLimit , 20 ) ;
297+ assert . strictEqual ( spanLimits . attributeCountLimit , 128 ) ;
298+ delete envSource . OTEL_ATTRIBUTE_COUNT_LIMIT ;
299+ delete envSource . OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT ;
300+ } ) ;
301+ } ) ;
302+
303+ describe ( 'when attribute count limit is not defined via env' , ( ) => {
304+ it ( 'should use default value of 128' , ( ) => {
305+ const tracer = new BasicTracerProvider ( ) . getTracer ( 'default' ) ;
306+ const spanLimits = tracer . getSpanLimits ( ) ;
307+ const generalLimits = tracer . getGeneralLimits ( ) ;
308+ assert . strictEqual ( generalLimits . attributeCountLimit , 128 ) ;
309+ assert . strictEqual ( spanLimits . attributeCountLimit , 128 ) ;
310+ } ) ;
311+ } ) ;
312+
211313 describe ( 'when "eventCountLimit" is defined' , ( ) => {
212314 it ( 'should have tracer with defined value' , ( ) => {
213315 const tracer = new BasicTracerProvider ( {
0 commit comments