✨(summary) add hostname to analytics properties - #1597
Conversation
PR Summary by QodoAdd hostname to summary analytics event properties
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. Hostname errors escape wrapper
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/summary/summary/core/analytics.py | Adds a cached hostname property and merges it into each enabled analytics event. |
| CHANGELOG.md | Records the new summary analytics hostname property. |
Reviews (3): Last reviewed commit: "fixup! ✨(summary) add hostname to analyt..." | Re-trigger Greptile
| # We add hostname to help track down the source of events | ||
| properties = properties or {} | ||
| if not properties.get("hostname"): | ||
| properties["hostname"] = socket.gethostname() |
There was a problem hiding this comment.
This helps track down what was the source of events. This can be usefull when checking perf of different workers for instance.
07b8b35 to
13c7569
Compare
| # We add hostname to help track down the source of events | ||
| properties = properties or {} | ||
| if not properties.get("hostname"): | ||
| properties = {**properties, "hostname": socket.gethostname()} | ||
|
|
There was a problem hiding this comment.
A few remarks:
-
I’m not sure we should allow the
hostnameto be overridden externally. Withif not properties.get("hostname"), two different sources can populate the same field, and from PostHog it becomes unclear which one actually produced the value. Having a single way to set it would make the data much easier to reason about and analyze. -
Why not resolve the value once at initialization? It doesn’t change between two
capture()calls, so there’s no need to make the call for every event. -
We’re currently using the low-level socket API here. I think we can get this information through an abstraction closer to Celery:
- At a minimum,
from celery.utils.nodenames import gethostname, which is Celery’s own (already memoized) wrapper. - Even better, use the worker’s node name (
celery@host, ortranscribe@%hif we name workers by queue). This is what Flower andinspect activedisplay, so it would correlate nicely with the rest of our observability. We can retrieve it from theceleryd_initsignal, wheresenderis the node name. That also addresses point 2: the value is resolved once when the worker starts, before the fork.
- At a minimum,
(We do have Flower deployed in grafana)
There was a problem hiding this comment.
So I thought about it.
First of all, this helper is used outside of celery, so I wouldn't stick too much to it.
Secondly, the default celery node name is still celery@ so it would still be coherent in terms of infra (in our case / docker case).
Tbh, I was hoping posthog would automatically include the host name in its events.
If we wanted more fined grained analytics on celery related stuff I think we should make it explicit.
I have tweaked things regarding 1 & caching.
|



This helps track down what was the source of events. This can be useful when checking perf of different workers for instance.