Skip to content

fix(search): compute provider average latency correctly - #17

Open
Mahika-web wants to merge 3 commits into
mainfrom
fix/provider-latency-average
Open

fix(search): compute provider average latency correctly#17
Mahika-web wants to merge 3 commits into
mainfrom
fix/provider-latency-average

Conversation

@Mahika-web

Copy link
Copy Markdown
Collaborator

Summary

This PR fixes the provider average latency calculation in the multi-provider search service.

Changes

  • Add 'total_latency' to provider statistics.
  • Compute average latency using cumulative latency divided by successful requests.
  • Preserve the existing request-counting behaviour.

Why?

The previous implementation updated the average by repeatedly averaging the previous average with the latest latency value:

(previous_avg + current_latency) / 2

This does not produce the true arithmetic mean as more requests are processed. By maintaining cumulative latency and dividing by the total number of successful search requests, the reported average latency remains mathematically correct.

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.

1 participant