cohere-toolkit icon indicating copy to clipboard operation
cohere-toolkit copied to clipboard

metrics: env secret in auth header

Open mtanzim opened this issue 1 year ago • 1 comments

Thank you for contributing to the Cohere Toolkit!

  • [ ] PR title: "area: description"

    • Where "area" is whichever of interface, frontend, model, tools, backend, etc. is being modified. Use "docs: ..." for purely docs changes, "infra: ..." for CI changes.
    • Example: "deployment: add Azure model option"
  • [ ] PR message: Delete this entire checklist and replace with

    • Description: a description of the change
    • Issue: the issue # it fixes, if applicable
    • Dependencies: any dependencies required for this change
  • [ ] Add tests and docs: Please include testing and documentation for your changes

  • [ ] Lint and test: Run make lint and make run-tests

AI Description

This pull request updates the code responsible for reporting metrics by removing the attachment of secrets to the metrics data.

Summary

The changes in this PR primarily involve the removal of the _attach_secret method and related code, which was responsible for attaching the report secret to the metrics data. This method is no longer necessary as the secret is now included in the headers of the client.post request as "Authorization": "Bearer {REPORT_SECRET}".

Changes

  • Remove the secret: str = "" line from the MetricsDataBase class in src/backend/schemas/metrics.py.
  • Remove the _attach_secret method and its usage from MetricsMiddleware in src/backend/services/metrics.py.
  • Update the report_metrics function in src/backend/services/metrics.py to include headers with the client.post request, adding the "Authorization" and "Content-Type" headers.
  • Remove the addition of "secret" to the signal data in the log_signal_curl method of MetricsHelper in src/backend/services/metrics.py.

mtanzim avatar Aug 12 '24 18:08 mtanzim

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 83.76%. Comparing base (4edacee) to head (2a5bb54). Report is 137 commits behind head on main.

Files Patch % Lines
src/backend/services/metrics.py 0.00% 2 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #647      +/-   ##
==========================================
+ Coverage   81.38%   83.76%   +2.37%     
==========================================
  Files         199      239      +40     
  Lines        8354    10846    +2492     
==========================================
+ Hits         6799     9085    +2286     
- Misses       1555     1761     +206     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Aug 12 '24 18:08 codecov-commenter