File tree Expand file tree Collapse file tree
packages/dd-trace/src/profiling/profilers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,7 +14,23 @@ const pprofValueUnit = 'nanoseconds'
1414const dateOffset = BigInt ( Math . round ( performance . timeOrigin * MS_TO_NS ) )
1515
1616function labelFromStr ( stringTable , key , valStr ) {
17- return new Label ( { key, str : stringTable . dedup ( valStr ) } )
17+ return new Label ( { key, str : stringTable . dedup ( safeToString ( valStr ) ) } )
18+ }
19+
20+ // We don't want to invoke toString for objects and functions, rather we'll
21+ // provide dummy values. These values are not meant to emulate built-in toString
22+ // behavior.
23+ function safeToString ( val ) {
24+ switch ( typeof val ) {
25+ case 'string' :
26+ return val
27+ case 'object' :
28+ return '[object]'
29+ case 'function' :
30+ return '[function]'
31+ default :
32+ return String ( val )
33+ }
1834}
1935
2036function labelFromStrStr ( stringTable , keyStr , valStr ) {
You can’t perform that action at this time.
0 commit comments