chroma icon indicating copy to clipboard operation
chroma copied to clipboard

[CHORE] Move posthog to rust

Open jairad26 opened this issue 8 months ago • 4 comments

Description of changes

This PR moves posthog logic to rust for all events. Captures occur on service_based_frontend, and for now only occur when users use via rust bindings.

Test plan

How are these changes tested?

  • [ ] Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs repository?

jairad26 avatar Apr 03 '25 15:04 jairad26

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)

github-actions[bot] avatar Apr 03 '25 15:04 github-actions[bot]

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

jairad26 avatar Apr 03 '25 15:04 jairad26

claiming a review slot

HammadB avatar Apr 04 '25 20:04 HammadB

Consolidate PostHog Telemetry Logic in Rust and Remove Per-Language Implementations

This PR removes all scattered PostHog code in Python, JavaScript, and server layers and re-implements telemetry entirely in a new Rust crate. All telemetry events are now defined as a single strongly-typed enum and sent through an async Rust client. Python and JS bindings simply forward events to the Rust layer via FFI, so every language shares one source of truth. The change eliminates drift in event schemas, reduces duplicated code, and sets the stage for adding new language bindings with minimal effort.

Key Changes

• Created rust/telemetry crate with events.rs (typed enum), posthog.rs & client.rs (async batching HTTP client), and public capture() API. • Added PostHog config options (host, project key, opt-out flag) to rust/frontend/config.rs and exposed via CHROMA_COLLECT_TELEMETRY / CHROMA_TELEMETRY env vars. • Rewired all Rust, Python, and JS call sites to use telemetry::capture(); deleted legacy PostHog helpers in chromadb/*.py, clients/js, and FastAPI server code. • Updated Cargo.toml files and workspace members; added dependencies (reqwest, uuid, chrono, once_cell). • Adjusted build pipeline to compile new telemetry feature by default and updated tests/docs accordingly.

Affected Areas

• rust/telemetry (new) • rust/frontend and config handling • Python bindings (pyo3 layer) • JavaScript/TypeScript bindings • CI/CD build images and Cargo.lock

This summary was automatically generated by @propel-code-bot

propel-code-bot[bot] avatar May 28 '25 19:05 propel-code-bot[bot]