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

Add gRPC filter #1241

Merged
merged 48 commits into from
Sep 20, 2022
Merged

Add gRPC filter #1241

merged 48 commits into from
Sep 20, 2022

Conversation

ymotongpoo
Copy link

@ymotongpoo ymotongpoo commented Aug 24, 2022

Description

This pull request adds section to handle filter in client and server interceptors and provides pre-defined commonly used filters.

Fixes #373

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • tox -e py39-test-instrumentation-grpc (test_filters.py and test_xxx_filters.py)

Does This PR Require a Core Repo Change?

  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@ymotongpoo ymotongpoo marked this pull request as ready for review August 25, 2022 12:09
@ymotongpoo ymotongpoo requested a review from a team August 25, 2022 12:09
@aabmass
Copy link
Member

aabmass commented Aug 25, 2022

Thanks for the PR! In the issue you mentioned environment variables, something like OTEL_PYTHON_FLASK_EXCLUDED_URLS but for gRPC. These are nice for auto instrumentation. Is the plan to implement similar environment variables on top of these predicates? Is there an easy way to specify the filters for auto instrumentation?

@ymotongpoo
Copy link
Author

ymotongpoo commented Aug 25, 2022

@aabmass thanks for the comment! though I tried to look up the implementation for OTEL_PYTHON_FLASK_EXCLUDED_URLS, I couldn't find the point where it is implemented. Could you tell the pointer where the environment variable is handled?

@ymotongpoo
Copy link
Author

Ok, now I understand this part is referencing the environment variable via get_excluded_urls. I think this function introduces unnecessary complexity into the repo, tho.

@ymotongpoo
Copy link
Author

@aabmass ok, I added the support in the global interceptor to exclude requests to services specified in OTEL_PYTHON_GRPC_EXCLUDED_SERVICES in comma separated format.

@aabmass aabmass self-assigned this Sep 8, 2022
@aabmass
Copy link
Member

aabmass commented Sep 8, 2022

Tox is the right way. They are probably flakes or maybe an already known issue. I'll review this PR :)

Copy link
Member

@aabmass aabmass left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, sorry for all the comments

Yoshi Yamaguchi and others added 13 commits September 9, 2022 09:07
…emetry/instrumentation/grpc/__init__.py

Co-authored-by: Aaron Abbott <[email protected]>
…emetry/instrumentation/grpc/__init__.py

Co-authored-by: Aaron Abbott <[email protected]>
…emetry/instrumentation/grpc/__init__.py

Co-authored-by: Aaron Abbott <[email protected]>
…emetry/instrumentation/grpc/__init__.py

Co-authored-by: Aaron Abbott <[email protected]>
…emetry/instrumentation/grpc/filters/__init__.py

Co-authored-by: Aaron Abbott <[email protected]>
…emetry/instrumentation/grpc/filters/__init__.py

Co-authored-by: Aaron Abbott <[email protected]>
…emetry/instrumentation/grpc/filters/__init__.py

Co-authored-by: Aaron Abbott <[email protected]>
Copy link
Author

@ymotongpoo ymotongpoo left a comment

Choose a reason for hiding this comment

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

adopted the suggestions and replied to the questions

@ymotongpoo
Copy link
Author

I updated the option name from filters to filter_. The tests kicked by GitHub Action are flaky and failing with arbitrary unexpected errors.

Copy link
Member

@aabmass aabmass left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +23 to +48
class _HandlerCallDetails(
collections.namedtuple(
"_HanlderCallDetails",
(
"method",
"invocation_metadata",
),
),
grpc.HandlerCallDetails,
):
pass


class _UnaryClientInfo(
collections.namedtuple("_UnaryClientInfo", ("full_method", "timeout"))
):
pass


class _StreamClientInfo(
collections.namedtuple(
"_StreamClientInfo",
("full_method", "is_client_stream", "is_server_stream", "timeout"),
)
):
pass
Copy link
Member

Choose a reason for hiding this comment

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

nit I would prefer @dataclass over named tuple

Copy link
Author

Choose a reason for hiding this comment

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

@lzchen lzchen merged commit 2ce0b69 into open-telemetry:main Sep 20, 2022
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.

Filter out health check request in grpc
4 participants