File tree Expand file tree Collapse file tree 1 file changed +19
-12
lines changed
src/services/languages/python Expand file tree Collapse file tree 1 file changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -75,24 +75,31 @@ export class PythonSpanExtractor implements ISpanExtractor {
7575 continue ;
7676 }
7777 const tracerName = match [ 1 ] ;
78-
79- const instrumentationLibrary = tracerName === '__name__'
80- ? ( mainDeclared ? '__main__' : await this . extractNameTypeTrace ( tracerDefinition . document . fileName ) )
81- : tracerName ;
78+
79+ let instLibraryOptions = [ ]
80+ if ( tracerName === '__name__' && mainDeclared ) {
81+ instLibraryOptions . push ( '__main__' ) ;
82+
83+ let fileName = await this . extractNameTypeTrace ( tracerDefinition . document . fileName ) ;
84+ instLibraryOptions . push ( fileName ) ;
85+ if ( fileName . includes ( "." ) ) {
86+ let unrootedForm = fileName . split ( "." ) . slice ( 1 ) . join ( "." ) ;
87+ instLibraryOptions . push ( unrootedForm ) ;
88+ }
89+ }
90+ else {
91+ instLibraryOptions . push ( tracerName ) ;
92+ }
8293 //Add the unrooted form
83- if ( instrumentationLibrary . includes ( "." ) ) {
84- let unrootedForm = instrumentationLibrary . split ( "." ) . slice ( 1 ) . join ( "." ) ;
94+ for ( let i = 0 ; i < instLibraryOptions . length ; i ++ ) {
95+
8596 results . push ( new SpanInfo (
86- unrootedForm + '$_$' + spanName ,
97+ instLibraryOptions [ i ] + '$_$' + spanName ,
8798 spanName ,
8899 token . range ,
89100 document . uri ) ) ;
90101 }
91- results . push ( new SpanInfo (
92- instrumentationLibrary + '$_$' + spanName ,
93- spanName ,
94- token . range ,
95- document . uri ) ) ;
102+
96103 }
97104
98105 return results ;
You can’t perform that action at this time.
0 commit comments