@@ -108,9 +108,10 @@ func (t *Tracer) AttachOpenSslUprobes(pid uint32) []link.Link {
108
108
return links
109
109
}
110
110
111
- func (t * Tracer ) AttachGoTlsUprobes (pid uint32 ) []link.Link {
111
+ func (t * Tracer ) AttachGoTlsUprobes (pid uint32 ) ([]link.Link , bool ) {
112
+ isGolangApp := false
112
113
if t .disableL7Tracing {
113
- return nil
114
+ return nil , isGolangApp
114
115
}
115
116
116
117
path := proc .Path (pid , "exe" )
@@ -133,53 +134,54 @@ func (t *Tracer) AttachGoTlsUprobes(pid uint32) []link.Link {
133
134
bi , err := buildinfo .ReadFile (path )
134
135
if err != nil {
135
136
log ("failed to read build info" , err )
136
- return nil
137
+ return nil , isGolangApp
137
138
}
139
+ isGolangApp = true
138
140
139
141
name , err = os .Readlink (path )
140
142
if err != nil {
141
143
log ("failed to read name" , err )
142
- return nil
144
+ return nil , isGolangApp
143
145
}
144
146
version = strings .Replace (bi .GoVersion , "go" , "v" , 1 )
145
147
if semver .Compare (version , minSupportedGoVersion ) < 0 {
146
148
log (fmt .Sprintf ("go_versions below %s are not supported" , minSupportedGoVersion ), nil )
147
- return nil
149
+ return nil , isGolangApp
148
150
}
149
151
150
152
ef , err := elf .Open (path )
151
153
if err != nil {
152
154
log ("failed to open as elf binary" , err )
153
- return nil
155
+ return nil , isGolangApp
154
156
}
155
157
defer ef .Close ()
156
158
157
159
symbols , err := ef .Symbols ()
158
160
if err != nil {
159
161
if errors .Is (err , elf .ErrNoSymbols ) {
160
162
log ("no symbol section" , nil )
161
- return nil
163
+ return nil , isGolangApp
162
164
}
163
165
log ("failed to read symbols" , err )
164
- return nil
166
+ return nil , isGolangApp
165
167
}
166
168
167
169
textSection := ef .Section (".text" )
168
170
if textSection == nil {
169
171
log ("no text section" , nil )
170
- return nil
172
+ return nil , isGolangApp
171
173
}
172
174
textSectionData , err := textSection .Data ()
173
175
if err != nil {
174
176
log ("failed to read text section" , err )
175
- return nil
177
+ return nil , isGolangApp
176
178
}
177
179
textSectionLen := uint64 (len (textSectionData ) - 1 )
178
180
179
181
exe , err := link .OpenExecutable (path )
180
182
if err != nil {
181
183
log ("failed to open executable" , err )
182
- return nil
184
+ return nil , isGolangApp
183
185
}
184
186
185
187
var links []link.Link
@@ -208,14 +210,14 @@ func (t *Tracer) AttachGoTlsUprobes(pid uint32) []link.Link {
208
210
l , err := exe .Uprobe (s .Name , t .uprobes ["go_crypto_tls_write_enter" ], & link.UprobeOptions {Address : address })
209
211
if err != nil {
210
212
log ("failed to attach write_enter uprobe" , err )
211
- return nil
213
+ return nil , isGolangApp
212
214
}
213
215
links = append (links , l )
214
216
case goTlsReadSymbol :
215
217
l , err := exe .Uprobe (s .Name , t .uprobes ["go_crypto_tls_read_enter" ], & link.UprobeOptions {Address : address })
216
218
if err != nil {
217
219
log ("failed to attach read_enter uprobe" , err )
218
- return nil
220
+ return nil , isGolangApp
219
221
}
220
222
links = append (links , l )
221
223
sStart := s .Value - textSection .Addr
@@ -227,23 +229,23 @@ func (t *Tracer) AttachGoTlsUprobes(pid uint32) []link.Link {
227
229
returnOffsets := getReturnOffsets (ef .Machine , sBytes )
228
230
if len (returnOffsets ) == 0 {
229
231
log ("failed to attach read_exit uprobe" , fmt .Errorf ("no return offsets found" ))
230
- return nil
232
+ return nil , isGolangApp
231
233
}
232
234
for _ , offset := range returnOffsets {
233
235
l , err := exe .Uprobe (s .Name , t .uprobes ["go_crypto_tls_read_exit" ], & link.UprobeOptions {Address : address , Offset : uint64 (offset )})
234
236
if err != nil {
235
237
log ("failed to attach read_exit uprobe" , err )
236
- return nil
238
+ return nil , isGolangApp
237
239
}
238
240
links = append (links , l )
239
241
}
240
242
}
241
243
}
242
244
if len (links ) == 0 {
243
- return nil
245
+ return nil , isGolangApp
244
246
}
245
247
log ("crypto/tls uprobes attached" , nil )
246
- return links
248
+ return links , isGolangApp
247
249
}
248
250
249
251
func getSslLibPathAndVersion (pid uint32 ) (string , string ) {
0 commit comments