interpreter: Support multiple interpreters for single ELF object#702
interpreter: Support multiple interpreters for single ELF object#702christos68k merged 7 commits intoopen-telemetry:mainfrom
Conversation
4a0f12a to
a7e9f0b
Compare
fabled
left a comment
There was a problem hiding this comment.
Overall this looks good! Thanks! Few changes requested to MultiInstance.Symbolize implementation.
| if err == nil && len(*frames) > initialLen { | ||
| // Successfully symbolized by this interpreter | ||
| return nil | ||
| } | ||
| // If symbolization didn't add any frames, reset and try next interpreter | ||
| if len(*frames) == initialLen { | ||
| continue | ||
| } | ||
| // If frames were added but there was an error, keep them and return | ||
| if err != nil { | ||
| return err | ||
| } |
There was a problem hiding this comment.
| if err == nil && len(*frames) > initialLen { | |
| // Successfully symbolized by this interpreter | |
| return nil | |
| } | |
| // If symbolization didn't add any frames, reset and try next interpreter | |
| if len(*frames) == initialLen { | |
| continue | |
| } | |
| // If frames were added but there was an error, keep them and return | |
| if err != nil { | |
| return err | |
| } | |
| if err != ErrMismatchInterpreterType { | |
| return err | |
| } |
The contract for Symbolizehas been to return interpreter.ErrMismatchInterpreterType if it did not recognize the frame. I think we can just return err here if it does not match this, because then this host.Frame belonged to this interpreter and something went wrong, or it successfully handled the frame.
| return err | ||
| } | ||
| } | ||
| return nil |
There was a problem hiding this comment.
| return nil | |
| return ErrMismatchInterpreterType |
If none of the interpreters succeeds to handle the frame, this function should report this as an error.
- Add MultiData and MultiInstance types to handle multiple interpreters - Modify detectAndLoadInterpData to try all loaders instead of stopping at first match - Use errors.Join for proper compound error handling - Enables concurrent use of Go tracer and GoLabels on same binary Fixes issue where only the first matching interpreter loader would be used, preventing multiple interpreters from handling the same ELF object. Fixes open-telemetry#687
a7e9f0b to
c4ed413
Compare
|
Thanks for the review @fabled, should be good to go! |
| allMetrics = append(allMetrics, metrics...) | ||
| } | ||
|
|
||
| return allMetrics, errors.Join(errs...) |
There was a problem hiding this comment.
This breaks the existing caller assumption that no useful metrics are returned if error != nil, so we should probably also update the caller to process the metrics regardless of error.
| // This is a valid state - return nil, nil | ||
| return nil, nil | ||
| } | ||
|
|
There was a problem hiding this comment.
We're potentially swallowing/hiding an error here (if len(instances) > 0 && len(errs) > 0)), maybe we should log the latter case.
| } | ||
|
|
||
| // Update metrics even if there was an error, because its possible ii is a multi-instance | ||
| // and some of the instances may have returned metrics. |
There was a problem hiding this comment.
| // and some of the instances may have returned metrics. | |
| // and some of the underlying instances may have returned metrics. |
|
Thanks, added some nits and simplifications, LGTM otherwise! |
Co-authored-by: Christos Kalkanis <christos.kalkanis@elastic.co>
Co-authored-by: Christos Kalkanis <christos.kalkanis@elastic.co>
Co-authored-by: Christos Kalkanis <christos.kalkanis@elastic.co>
…n-telemetry#702) Co-authored-by: Christos Kalkanis <christos.kalkanis@elastic.co>
…n-telemetry#702) Co-authored-by: Christos Kalkanis <christos.kalkanis@elastic.co>
…n-telemetry#702) Co-authored-by: Christos Kalkanis <christos.kalkanis@elastic.co>
…n-telemetry#702) Co-authored-by: Christos Kalkanis <christos.kalkanis@elastic.co>
…n-telemetry#702) Co-authored-by: Christos Kalkanis <christos.kalkanis@elastic.co>
…n-telemetry#702) Co-authored-by: Christos Kalkanis <christos.kalkanis@elastic.co>
Fixes issue where only the first matching interpreter loader would be used,
preventing multiple interpreters from handling the same ELF object.
Fixes #687