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

[ENH]: add grpc python client interceptor #1802

Merged
merged 3 commits into from
Mar 4, 2024

Conversation

nicolasgere
Copy link
Contributor

@nicolasgere nicolasgere commented Mar 1, 2024

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • Add grpc client interceptor to propagate trace information for distributed tracing.

Test plan

How are these changes tested?

Tested locally using tilt and golang rpc

Copy link
Contributor Author

nicolasgere commented Mar 1, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @nicolasgere and the rest of your teammates on Graphite Graphite

Copy link

github-actions bot commented Mar 1, 2024

Please tag your PR title with one of: [ENH | BUG | DOC | TST | BLD | PERF | TYP | CLN | CHORE]. See https://docs.trychroma.com/contributing#contributing-code-and-ideas

Copy link

github-actions bot commented Mar 1, 2024

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@nicolasgere nicolasgere marked this pull request as ready for review March 1, 2024 18:32
@nicolasgere nicolasgere changed the title nicolas/add-grpc-python-interceptor [ENH]: add grpc python client interceptor Mar 1, 2024
chromadb/telemetry/opentelemetry/grpc.py Outdated Show resolved Hide resolved
new_client_details = _ClientCallDetails(
client_call_details.method,
client_call_details.timeout,
tuple(metadata), # Ensure metadata is a tuple
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a chance metadata can contain things that cannot be properly serialized, e.g. nested or non-basic types?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't expect anyone to add things to metadata.

# Log exception details and re-raise
span.set_attribute("rpc.error", str(e))
span.set_status(StatusCode.ERROR, description=str(e))
raise
Copy link
Contributor

Choose a reason for hiding this comment

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

Would that not cause a failure of the GRPC message if we fail to process the trace? Should we differentiate between processing errors and GRPC invocation-related errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

otel should never raise, even if span is empty as far as I know

# 1. Instantiate the interceptor: interceptors = [OtelInterceptor()]
# 2. Intercept the channel: channel = grpc.intercept_channel(channel, *interceptors)

class OtelInterceptor(
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would be nice to have control over this, to help with integration with go/rust, distributed tracing, metrics etc

@nicolasgere nicolasgere merged commit 3fb5c1e into main Mar 4, 2024
120 checks passed
atroyn pushed a commit to csbasil/chroma that referenced this pull request Apr 3, 2024
## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
- Add grpc client interceptor to propagate trace information for
distributed tracing.

## Test plan
*How are these changes tested?*

Tested locally using tilt and golang rpc
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.

None yet

2 participants