Skip to content

Commit

Permalink
Instrument analytics for invoke_user_worker_ahead_of_assets
Browse files Browse the repository at this point in the history
  • Loading branch information
WillTaylorDev committed Dec 5, 2024
1 parent 5ea9d8e commit 87004bd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/funny-impalas-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/workers-shared": minor
---

Instrument analytics around assets.serve_directly
5 changes: 5 additions & 0 deletions packages/workers-shared/router-worker/src/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type Data = {
metalId?: number;
// double4 - Colo tier (e.g. tier 1, tier 2, tier 3)
coloTier?: number;
// double5 - Run user worker ahead of assets
userWorkerAhead?: boolean;

// -- Blobs --
// blob1 - Hostname of the request
Expand Down Expand Up @@ -63,6 +65,9 @@ export class Analytics {
this.data.coloId ?? -1, // double2
this.data.metalId ?? -1, // double3
this.data.coloTier ?? -1, // double4
this.data.userWorkerAhead === undefined // double5
? -1
: Number(this.data.userWorkerAhead),
],
blobs: [
this.data.hostname?.substring(0, 256), // blob1 - trim to 256 bytes
Expand Down
3 changes: 2 additions & 1 deletion packages/workers-shared/router-worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ export default {
sentry.setTag("metal", env.COLO_METADATA.metalId);
}

if (env.COLO_METADATA && env.VERSION_METADATA) {
if (env.COLO_METADATA && env.VERSION_METADATA && env.CONFIG) {
analytics.setData({
coloId: env.COLO_METADATA.coloId,
metalId: env.COLO_METADATA.metalId,
coloTier: env.COLO_METADATA.coloTier,
coloRegion: env.COLO_METADATA.coloRegion,
hostname: url.hostname,
version: env.VERSION_METADATA.id,
userWorkerAhead: env.CONFIG.invoke_user_worker_ahead_of_assets,
});
}

Expand Down

0 comments on commit 87004bd

Please sign in to comment.