Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(devex): select the node lane for usage_ingestion proto changes (#88410)

Julian Bez28ed441de25f
diff --git a/.github/scripts/trunk-impacted-targets.js b/.github/scripts/trunk-impacted-targets.js
index 4c3171594d74..57e6613f182f 100644
--- a/.github/scripts/trunk-impacted-targets.js
+++ b/.github/scripts/trunk-impacted-targets.js
@@ -1350,7 +1350,7 @@ const PROTO_TREES = new Map([
['kafka_assigner', { crates: ['kafka-assigner-proto'], domains: [] }],
['personhog', { crates: ['personhog-proto'], domains: [PYTHON, NODE] }],
['prometheus', { crates: ['prometheus-rw-proto'], domains: [] }],
- ['usage_ingestion', { crates: ['usage-ingestion-proto'], domains: [] }],
+ ['usage_ingestion', { crates: ['usage-ingestion-proto'], domains: [NODE], stubDir: 'usage-ingestion' }],
])
// A file directly under proto/ is treated as impacting all trees, since it's not
diff --git a/.github/scripts/trunk-impacted-targets.test.js b/.github/scripts/trunk-impacted-targets.test.js
index 1174a3f3b162..bf133474c9be 100644
--- a/.github/scripts/trunk-impacted-targets.test.js
+++ b/.github/scripts/trunk-impacted-targets.test.js
@@ -118,6 +118,7 @@ const PROTO_CONTEXT = {
['personhog-proto', []],
['personhog-consumer', ['personhog-proto']],
['prometheus-rw-proto', []],
+ ['usage-ingestion-proto', []],
['unrelated', []],
]),
byDir: [
@@ -127,6 +128,7 @@ const PROTO_CONTEXT = {
{ dir: 'personhog-proto', name: 'personhog-proto' },
{ dir: 'personhog-consumer', name: 'personhog-consumer' },
{ dir: 'prometheus-rw-proto', name: 'prometheus-rw-proto' },
+ { dir: 'usage-ingestion-proto', name: 'usage-ingestion-proto' },
{ dir: 'unrelated', name: 'unrelated' },
],
},
@@ -338,6 +340,11 @@ test('every proto tree is declared, with the crate that compiles it', () => {
// land in today, so a tree that starts generating into one of them without
// declaring the domain fails here. A consumer that generates into a root
// neither of these names is still only caught by review.
+//
+// The equality runs both ways. Reading only from the table cannot see a stub
+// directory no tree claims, because a tree whose directory name differs from
+// its own name (usage_ingestion generates into usage-ingestion) reads as "no
+// stubs" and agrees with an empty domain list. The directory side catches that.
test('every proto tree declaring a stub consumer has stubs there, and no other tree does', () => {
const stubRoots = [
['posthog/personhog_client/proto/generated', PYTHON],
@@ -347,14 +354,25 @@ test('every proto tree declaring a stub consumer has stubs there, and no other t
const generated = fs
.readdirSync(path.join(REPO_ROOT, root), { withFileTypes: true })
.filter((entry) => entry.isDirectory())
+ // __pycache__ is a build artifact of the python root, not a stub tree.
+ .filter((entry) => !entry.name.startsWith('__'))
.map((entry) => entry.name)
+ const claimed = new Set()
for (const [tree, { domains, stubDir }] of PROTO_TREES) {
assert.equal(
generated.includes(stubDir || tree),
domains.includes(domain),
`proto/${tree} stubs in ${root} must match its declared ${domain} consumer`
)
+ if (domains.includes(domain)) {
+ claimed.add(stubDir || tree)
+ }
}
+ assert.deepEqual(
+ generated.filter((dir) => !claimed.has(dir)),
+ [],
+ `every directory in ${root} must belong to a proto tree declaring its ${domain} consumer`
+ )
}
})
diff --git a/proto/README.md b/proto/README.md
index d3cdba328b2d..b4eaac163ccf 100644
--- a/proto/README.md
+++ b/proto/README.md
@@ -16,19 +16,22 @@ proto/
│ ├── types/v1/
│ ├── replica/v1/
│ └── service/v1/
-└── prometheus/ # Prometheus remote write
- └── v1/ # Remote write transport
+├── prometheus/ # Prometheus remote write
+│ └── v1/ # Remote write transport
+└── usage_ingestion/ # Usage ingestion service
+ └── v1/ # Billing usage record ingest
```
## Consumers
-| Proto | Rust | Python | Node.js |
-| ----------------- | ---------------------------------------------- | -------------------------------------------------------- | ----------------------------------------------------------- |
-| `cymbal/` | `rust/cymbal-proto` (auto via tonic) | — | — |
-| `ingestion/` | `rust/ingestion-worker-proto` (auto via tonic) | — | `nodejs/src/common/generated/ingestion-worker` (checked in) |
-| `personhog/` | `rust/personhog-proto` (auto via tonic) | `posthog/personhog_client/proto/generated/` (checked in) | `nodejs/src/common/generated/personhog` (checked in) |
-| `kafka_assigner/` | `rust/kafka-assigner-proto` (auto via tonic) | — | — |
-| `prometheus/` | `rust/prometheus-rw-proto` (auto via tonic) | — | — |
+| Proto | Rust | Python | Node.js |
+| ------------------ | ---------------------------------------------- | -------------------------------------------------------- | ----------------------------------------------------------- |
+| `cymbal/` | `rust/cymbal-proto` (auto via tonic) | — | — |
+| `ingestion/` | `rust/ingestion-worker-proto` (auto via tonic) | — | `nodejs/src/common/generated/ingestion-worker` (checked in) |
+| `personhog/` | `rust/personhog-proto` (auto via tonic) | `posthog/personhog_client/proto/generated/` (checked in) | `nodejs/src/common/generated/personhog` (checked in) |
+| `kafka_assigner/` | `rust/kafka-assigner-proto` (auto via tonic) | — | — |
+| `prometheus/` | `rust/prometheus-rw-proto` (auto via tonic) | — | — |
+| `usage_ingestion/` | `rust/usage-ingestion-proto` (auto via tonic) | — | `nodejs/src/common/generated/usage-ingestion` (checked in) |
## Updating protos