Skip to content

Commit

Permalink
fix: don't re-add metrics to x-goog-api-client header
Browse files Browse the repository at this point in the history
  • Loading branch information
arithmetic1728 committed Jun 21, 2024
1 parent cb98227 commit 29c7b97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion google/auth/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,5 @@ def add_metric_header(headers, metric_header_value):
return
if API_CLIENT_HEADER not in headers:
headers[API_CLIENT_HEADER] = metric_header_value
else:
elif metric_header_value not in headers[API_CLIENT_HEADER]:
headers[API_CLIENT_HEADER] += " " + metric_header_value
4 changes: 4 additions & 0 deletions tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def test_add_metric_header():
metrics.add_metric_header(headers, "bar")
assert headers == {"x-goog-api-client": "foo bar"}

headers = {"x-goog-api-client": "foo"}
metrics.add_metric_header(headers, "foo")
assert headers == {"x-goog-api-client": "foo"}

headers = {}
metrics.add_metric_header(headers, "bar")
assert headers == {"x-goog-api-client": "bar"}
Expand Down

0 comments on commit 29c7b97

Please sign in to comment.