Skip to content
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

[DISCO-3209] metrics to include user agent tags #828

Merged
merged 2 commits into from
Mar 11, 2025
Merged

Conversation

tiftran
Copy link
Contributor

@tiftran tiftran commented Mar 10, 2025

References

JIRA: DISCO-3209

Description

Adding tags to metrics so that we can separate by user agent

PR Review Checklist

Put an x in the boxes that apply

  • This PR conforms to the Contribution Guidelines
  • The PR title starts with the JIRA issue reference, format example [DISCO-####], and has the same title (if applicable)
  • [load test: (abort|skip|warn)] keywords are applied to the last commit message (if applicable)
  • Documentation has been updated (if applicable)
  • Functional and performance test coverage has been expanded and maintained (if applicable)

@tiftran tiftran requested a review from a team March 10, 2025 20:51
"Gecko/20100101 Firefox/103.0"
),
},
)

# TODO: Remove reliance on internal details of aiodogstatsd
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll be attempting to address this TODO as a follow up, since I'm already here 🙂

Copy link
Contributor

@ncloudioj ncloudioj left a comment

Choose a reason for hiding this comment

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

r+wc.

@@ -39,6 +39,7 @@ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
loop = get_event_loop()
request = Request(scope=scope)
started_at = loop.time()
user_agent = scope[ScopeKey.USER_AGENT]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: let's dump it once here and use the result below. Also, make sure the user agent middleware is ahead of the metrics middleware as scope[ScopeKey.USER_AGENT] is set by the former.

    tags = scope[ScopeKey.USER_AGENT].model_dump()

@tiftran tiftran added this pull request to the merge queue Mar 11, 2025
Merged via the queue into main with commit 8bdd397 Mar 11, 2025
11 checks passed
@tiftran tiftran deleted the user-agent-metrics branch March 11, 2025 16:37
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