Skip to content
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

Log error if missing bytecode instrumentation method #1520

Conversation

pjanotti
Copy link
Contributor

Why

If the bytecode instrumentation type doesn't have any of the expected instrumentation methods the bytecode instrumentation is injected during ReJIT but since there are no instrumentation methods it has no practical effect and no error/warning message is logged in any of the logs.

Fixes #1499

What

  • Logs an error msg if none of the expected bytecode instrumentation methods are present on the instrumentation type.

Tests

  • Added a bytecode instrumentation target that exercises the new log statement to the StrongNamedTests.
  • I considered inspecting the native log to ensure the message is there but it seemed non-reliable to depend on the process id (that can be reused) and time window to open the file. I opted to not do it now and see if we can add that validation if we implement Use OTel SDK's self-diagnostics - native code #960 (this will be a subscription to the event which should be more reliable).

Checklist

  • CHANGELOG.md is updated.
    - [] Documentation is updated.
  • New features are covered by tests.

@pjanotti pjanotti requested a review from a team October 29, 2022 00:00
@github-actions github-actions bot requested a review from theletterf October 29, 2022 00:01
@@ -2494,14 +2494,47 @@ HRESULT CorProfiler::CallTarget_RewriterCallback(RejitHandlerModule* moduleHandl
&wrapper_type_def);
if (FAILED(hr) || wrapper_type_def == mdTypeDefNil)
{
Logger::Warn("*** CallTarget_RewriterCallback() Failed for: ", caller->type.name, ".", caller->name,
Logger::Error("*** CallTarget_RewriterCallback() Failed for: ", caller->type.name, ".", caller->name,
Copy link
Member

@pellared pellared Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it not be a warning? It is an oddity, but the application and instrumentation would continue to work without any bad side-effects. Should the user react when he notices such an error?

Maybe we should even "accept" such behavior so that we could use e.g. #if NETFRAMEWORK on a whole instrumentation class? Then we could even change this level to debug.

Leaving it for a discussion + potentially separate PR.


if (!found_wrapper_method)
{
Logger::Error("*** CallTarget_RewriterCallback() Failed for: ", caller->type.name, ".", caller->name,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comment as above.

@pellared pellared merged commit 63a5236 into open-telemetry:main Nov 2, 2022
@pjanotti pjanotti deleted the log-error-if-missing-instrumentation-method branch June 2, 2023 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Silent failure if bytecode instrumentation is missing all expected methods
4 participants