Skip to content

Add latency metrics #4472

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

Merged
merged 3 commits into from
Apr 8, 2025
Merged

Add latency metrics #4472

merged 3 commits into from
Apr 8, 2025

Conversation

pablonyx
Copy link
Contributor

@pablonyx pablonyx commented Apr 7, 2025

Description

Fixes https://linear.app/danswer/issue/DAN-1777/track-latency-metrics

These should give us enough information to construct latency metrics in Grafana

How Has This Been Tested?

[Describe the tests you ran to verify your changes]

Backporting (check the box to trigger backport action)

Note: You have to check that the action passes, otherwise resolve the conflicts manually and tag the patches.

  • This PR should be backported (make sure to check that the backport attempt succeeds)
  • [Optional] Override Linear Check

Copy link

vercel bot commented Apr 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
internal-search ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 8, 2025 8:42pm

@pablonyx pablonyx force-pushed the monitoring_metrics branch from e0993ff to 8c42f46 Compare April 7, 2025 20:28
@pablonyx pablonyx marked this pull request as ready for review April 7, 2025 20:28
@pablonyx pablonyx requested a review from a team as a code owner April 7, 2025 20:28
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR integrates latency metrics across the chat and authentication flows to support monitoring in Grafana.

  • backend/onyx/server/query_and_chat/chat_backend.py: Introduces start-time tracking and logs document retrieval latency when a 'top_documents' key is present; ensure duplicate logs aren’t triggered inadvertently.
  • backend/onyx/auth/users.py: Applies log_function_time on crucial async methods (e.g., oauth_callback and authenticate) to capture performance data.
  • backend/onyx/chat/process_message.py: Removes inline timing calls to streamline measurement via centralized telemetry.

3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@@ -448,6 +449,10 @@ def stream_generator() -> Generator[str, None, None]:
),
is_connected=is_connected_func,
):
if isinstance(packet, dict) and "top_documents" in packet:
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems problematic, no? stream_chat_message yields strs not dicts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it does!

Copy link
Contributor

@evan-danswer evan-danswer left a comment

Choose a reason for hiding this comment

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

one minor nit

@pablonyx pablonyx added this pull request to the merge queue Apr 8, 2025
@evan-danswer evan-danswer removed this pull request from the merge queue due to a manual request Apr 8, 2025
@evan-danswer evan-danswer enabled auto-merge April 8, 2025 20:37
@evan-danswer evan-danswer added this pull request to the merge queue Apr 8, 2025
Merged via the queue into main with commit 8db80a6 Apr 8, 2025
10 of 11 checks passed
tim-dim pushed a commit to grantgpteu/grantgpt-dev that referenced this pull request Apr 9, 2025
* k

* update

* Update chat_backend.py

nit

---------

Co-authored-by: evan-danswer <[email protected]>
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.

2 participants