@@ -4,82 +4,13 @@ import {
44 _INTERNAL_captureMetric ,
55 _INTERNAL_flushMetricsBuffer ,
66 _INTERNAL_getMetricBuffer ,
7- metricAttributeToSerializedMetricAttribute ,
87} from '../../../src/metrics/internal' ;
98import type { Metric } from '../../../src/types-hoist/metric' ;
109import * as loggerModule from '../../../src/utils/debug-logger' ;
1110import { getDefaultTestClientOptions , TestClient } from '../../mocks/client' ;
1211
1312const PUBLIC_DSN = 'https://username@domain/123' ;
1413
15- describe ( 'metricAttributeToSerializedMetricAttribute' , ( ) => {
16- it ( 'serializes integer values' , ( ) => {
17- const result = metricAttributeToSerializedMetricAttribute ( 42 ) ;
18- expect ( result ) . toEqual ( {
19- value : 42 ,
20- type : 'integer' ,
21- } ) ;
22- } ) ;
23-
24- it ( 'serializes double values' , ( ) => {
25- const result = metricAttributeToSerializedMetricAttribute ( 42.34 ) ;
26- expect ( result ) . toEqual ( {
27- value : 42.34 ,
28- type : 'double' ,
29- } ) ;
30- } ) ;
31-
32- it ( 'serializes boolean values' , ( ) => {
33- const result = metricAttributeToSerializedMetricAttribute ( true ) ;
34- expect ( result ) . toEqual ( {
35- value : true ,
36- type : 'boolean' ,
37- } ) ;
38- } ) ;
39-
40- it ( 'serializes string values' , ( ) => {
41- const result = metricAttributeToSerializedMetricAttribute ( 'endpoint' ) ;
42- expect ( result ) . toEqual ( {
43- value : 'endpoint' ,
44- type : 'string' ,
45- } ) ;
46- } ) ;
47-
48- it ( 'serializes object values as JSON strings' , ( ) => {
49- const obj = { name : 'John' , age : 30 } ;
50- const result = metricAttributeToSerializedMetricAttribute ( obj ) ;
51- expect ( result ) . toEqual ( {
52- value : JSON . stringify ( obj ) ,
53- type : 'string' ,
54- } ) ;
55- } ) ;
56-
57- it ( 'serializes array values as JSON strings' , ( ) => {
58- const array = [ 1 , 2 , 3 , 'test' ] ;
59- const result = metricAttributeToSerializedMetricAttribute ( array ) ;
60- expect ( result ) . toEqual ( {
61- value : JSON . stringify ( array ) ,
62- type : 'string' ,
63- } ) ;
64- } ) ;
65-
66- it ( 'serializes undefined values as empty strings' , ( ) => {
67- const result = metricAttributeToSerializedMetricAttribute ( undefined ) ;
68- expect ( result ) . toEqual ( {
69- value : '' ,
70- type : 'string' ,
71- } ) ;
72- } ) ;
73-
74- it ( 'serializes null values as JSON strings' , ( ) => {
75- const result = metricAttributeToSerializedMetricAttribute ( null ) ;
76- expect ( result ) . toEqual ( {
77- value : 'null' ,
78- type : 'string' ,
79- } ) ;
80- } ) ;
81- } ) ;
82-
8314describe ( '_INTERNAL_captureMetric' , ( ) => {
8415 it ( 'captures and sends metrics' , ( ) => {
8516 const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN } ) ;
0 commit comments