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

GRPC Instrumentation #1703

Merged
merged 9 commits into from
Dec 14, 2022
Merged

GRPC Instrumentation #1703

merged 9 commits into from
Dec 14, 2022

Conversation

beniwohli
Copy link
Contributor

@beniwohli beniwohli commented Nov 30, 2022

What does this pull request do?

Instrument GRPC using interceptors. We use our instrumentation to insert our server and client interceptors, the interceptors take care of creating transactions and spans.

Testing is somewhat... interesting. We spawn a subprocess that runs the GRPC server, giving it the URL to our fake APM Server that runs in a thread of the main process. The GRPC client runs in the main thread. This allows for a full end-to-end test and introspection of all events (spans, transactions) from both the client and server.

Related issues

Closes #645

@apmmachine
Copy link
Contributor

apmmachine commented Dec 2, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-12-13T11:10:26.974+0000

  • Duration: 18 min 26 sec

Test stats 🧪

Test Results
Failed 0
Passed 5079
Skipped 3600
Total 8679

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /test linters : Run the Python linters only.

  • /test full : Run the full matrix of tests.

  • /test benchmark : Run the APM Agent Python benchmarks tests.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@apmmachine
Copy link
Contributor

apmmachine commented Dec 2, 2022

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (71/71) 💚
Files 100.0% (236/236) 💚
Classes 100.0% (236/236) 💚
Lines 92.073% (18677/20285) 👎 -0.115
Conditionals 75.163% (2878/3829) 👎 -0.067

Copy link
Contributor

@basepi basepi left a comment

Choose a reason for hiding this comment

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

A few nits and questions, but looks excellent overall!

docs/grpc.asciidoc Show resolved Hide resolved
docs/grpc.asciidoc Show resolved Hide resolved


Once you have configured the agent, it will automatically track transactions
and capture uncaught exceptions within sanic.
Copy link
Contributor

Choose a reason for hiding this comment

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

sanic copy pasta

elasticapm/contrib/grpc/client_interceptor.py Show resolved Hide resolved
args[2] = interceptors
else:
kwargs["interceptors"] = interceptors
return wrapper(*args, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a typo? Usually we use wrapped not wrapper, right?

tests/fixtures.py Show resolved Hide resolved
elasticapm/contrib/grpc/server_interceptor.py Show resolved Hide resolved
@basepi basepi mentioned this pull request Dec 5, 2022
Copy link
Contributor

@basepi basepi left a comment

Choose a reason for hiding this comment

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

Excellent work! 👍

@beniwohli beniwohli merged commit a7f44ac into elastic:main Dec 14, 2022
@beniwohli beniwohli deleted the grpc-interceptor branch December 14, 2022 12:51
This was referenced Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] gRPC support
4 participants