fix(tool): support path helpers for call rules#482
Conversation
Add path parsing and helper file materialization for call rules so wrapper replacements can reference helper functions outside the target source file. Assisted-by: ChatGPT 5
|
|
|
Thank you for the contribution. We already support helper usage through the existing |
|
That makes sense to me. I agree that broadening For call rules specifically, it seems cleaner to reference helpers through an imported package alias in So I think the better fix may be limited to golden-test infrastructure: either teach |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #482 +/- ##
=========================================
+ Coverage 0 63.60% +63.60%
=========================================
Files 0 62 +62
Lines 0 4927 +4927
=========================================
+ Hits 0 3134 +3134
- Misses 0 1528 +1528
- Partials 0 265 +265
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Extends createImportCfg to dynamically resolve import paths declared in rule imports fields, not just standard library packages. This fixes the gap identified in issue open-telemetry#475 where call rules that reference helper packages through the imports field could not be validated in golden tests. Changes: - Extract collectRuleImports to gather import paths from all rule types - Extend createImportCfg to resolve additional packages via go list - Factor out resolvePackageExport for reuse across stdlib and rule imports - Add call-rule-local-import golden test demonstrating the imports pattern - Add testhelper/wrapper package as a reusable helper for golden tests This addresses the maintainer feedback on PR open-telemetry#482 and issue open-telemetry#475: call rules should use the existing imports mechanism rather than adding a path field. The test infrastructure now supports this pattern. Closes open-telemetry#475
Description
Adds
pathsupport to call rules so replacement wrappers can reference helper functions that live outside the target source file.This change:
Pathparsing toInstCallRulereplace/append_argspathinto the target package during instrumentationwrap_sizeof_callandwrap_sizeof_with_stringspathbehaviorMotivation
Call-rule YAML fixtures can specify wrapper expressions such as
Wrapper({{ . }}), butInstCallRulepreviously had noPathfield. As a result, addingpath:to YAML would be silently ignored, and call-rule replacements could only reference helpers already defined in the target source file or symbols available through imports.This fixes the missing code path so helper functions can be located and compiled into the target package when a call rule needs them.
Fixes #
Checklist
make formatmake lintmake test