-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkg/run: Don't rely on GADGET_TRACER as it is optional #2518
Conversation
GetTracerInfo gets the tracer information from what was defined by the GADGET_TRACER macro. However, such macro is optional, so we must not rely on it. Additionally, by the time handleTracerMapDefinition() is called, the metadata was already built (either from the metadata file or from the eBPF code), so we can get the tracer information from there. Signed-off-by: Jose Blanquicet <josebl@microsoft.com>
Signed-off-by: Jose Blanquicet <josebl@microsoft.com>
This reverts commit 4ffe89c. It is not necessary anymore to export neither TracerInfo nor GetTracerInfo() because we don't need to use it outside the gadgets/run/types pakage. Signed-off-by: Jose Blanquicet <josebl@microsoft.com>
36bbeb2
to
752b58b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi.
From code inspection, this looks OK.
However, I would question the whole existence of this macro.
If it is optional, we should just drop it and not add another level of complexity.
Otherwise, we should document in which case it is mandatory to use it. I suspect this documentation to no more be up to date:
inspektor-gadget/docs/devel/hello-world-gadget.md
Lines 284 to 285 in 1072df2
> The `tracers` and `structs` sections will only be generated if the eBPF program defined a tracer | |
> using the `GADGET_TRACER` macro. |
Best regards.
Hola Francis 🙂
The macro
... no, it is up to date. Actually, I recently updated it in this PR the documentation to make this optionality clearer: inspektor-gadget/docs/devel/hello-world-gadget.md Lines 86 to 92 in 1072df2
If you consider it is not yet clear enough, would you mind opening a PR to improve the documentation? |
If this metadata file is optional, then why do we need it? |
The metadata file allows to define extra attributes for the gadget as the format used to print the fields, and in the future documentation and all other stuff we can't put directly in the eBPF code. It's optional because the gadget can work without it, we don't want to force gadget developers creating this file if they don't want to define any of these extra attributes. |
I agree the metadata file should be optional, but I'm not fully convinced about the Let's discuss it in IG Developer Sync meeting today. |
Don't rely on GADGET_TRACER as it is optional