Skip to content

🎨 Improved otel code, cleaned up cjs polyfills - #810

Merged
cmraible merged 1 commit into
mainfrom
feat/docker-optimize
Aug 11, 2026
Merged

cmraible merged 1 commit into
mainfrom
feat/docker-optimize

Conversation

@acburdine

Copy link
Copy Markdown
Member

ref https://linear.app/ghost/issue/PLA-280/optimize-traffic-analytics-docker-buildself-hosting-execution

  • remove unused cjs polyfills, only referenced in a few spots that don't affect running behavior
  • fix otel tracing for pubsub + fastify
  • remove blanket node auto otel registration in favor of lighter-weight individual plugins

@acburdine
acburdine requested a review from cmraible as a code owner July 30, 2026 16:14
@acburdine
acburdine requested a review from JoeeGrigg July 30, 2026 16:14
@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@cmraible, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 56 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6a18c2bf-67bd-4cd0-b44b-c22063c00e33

📥 Commits

Reviewing files that changed from the base of the PR and between 050812c and 8197232.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (1)
  • package.json

Walkthrough

The project replaces automatic Node instrumentation with explicit HTTP and Undici packages, adds Fastify OpenTelemetry integration, and ignores selected health and informational paths. Both application variants register tracing before other plugins and routes, while Pub/Sub clients enable tracing. Server startup now uses dynamic application imports and import.meta.main.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: cmraible, joeegrigg

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the OpenTelemetry improvements and CommonJS polyfill cleanup in the changeset.
Description check ✅ Passed The description directly covers the CommonJS cleanup, Pub/Sub and Fastify tracing fixes, and targeted OpenTelemetry instrumentation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/docker-optimize

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/utils/instrumentation.ts`:
- Around line 30-34: Correct the service-name selection expression in the
instrumentation initialization so K_SERVICE is used when present, otherwise the
worker name is selected only when WORKER_MODE is strictly enabled, matching the
check in server.ts. Preserve the existing service-name values while fixing the
operator precedence that currently classifies every Cloud Run deployment as
analytics-worker.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ba60ce69-caab-4a41-a745-2c38b269a2ca

📥 Commits

Reviewing files that changed from the base of the PR and between 40cdf91 and 23bc810.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (9)
  • package.json
  • server.ts
  • src/app.ts
  • src/services/events/publisher.ts
  • src/services/events/subscriber.ts
  • src/utils/cjs-polyfill.ts
  • src/utils/fastify-otel.ts
  • src/utils/instrumentation.ts
  • src/worker-app.ts
💤 Files with no reviewable changes (1)
  • src/utils/cjs-polyfill.ts

Comment thread src/utils/instrumentation.ts Resolved
@acburdine
acburdine force-pushed the feat/docker-optimize branch 2 times, most recently from b81d714 to 8696f7b Compare July 30, 2026 16:53
@acburdine

Copy link
Copy Markdown
Member Author

NOTE: we'll need to remove the required node 20 check before this can be merged.

@cmraible

Copy link
Copy Markdown
Collaborator

FYI: Just rebased, resolved conflicts and force-pushed so I can deploy this to staging to test

@cmraible

Copy link
Copy Markdown
Collaborator

NOTE: we'll need to remove the required node 20 check before this can be merged.

This is done — I've also pulled out the change to remove node 20 from the CI matrix into its own PR and merged it.

@github-actions

Copy link
Copy Markdown

✅ Deployed to staging (tree: 1f226d4b88dbddb0ea110a2cf987c1ac93b5cd77)

@github-actions

Copy link
Copy Markdown

✅ Deployed to staging (tree: 1f226d4b88dbddb0ea110a2cf987c1ac93b5cd77)

@cmraible cmraible left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice one! Approved with one small nit.

Tested in staging, and confirmed we can see the pub/sub spans:

Image

Comment thread server.ts Resolved
Comment thread .github/workflows/ci.yml Resolved
@acburdine
acburdine force-pushed the feat/docker-optimize branch from c4de090 to 050812c Compare August 11, 2026 13:37

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@vite.config.ts`:
- Around line 23-26: Update the Vite production bundling configuration around
the banner that defines globalThis.__filename and globalThis.__dirname so
google-gax common-proto assets remain available at their package-relative
runtime paths. Either externalize the affected clients and include their runtime
dependencies, or package the required assets at the paths resolved from
/app/dist; also add a built-server smoke test covering common-proto loading or a
gRPC error path.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 511e1e87-44bf-4aeb-9067-64ecee7dd50f

📥 Commits

Reviewing files that changed from the base of the PR and between 23bc810 and 050812c.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (2)
  • package.json
  • vite.config.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

Comment thread vite.config.ts Resolved
@github-actions

Copy link
Copy Markdown

✅ Deployed to staging (tree: be575f18e1764308e2d7346795efdecf71f4181b)

ref https://linear.app/ghost/issue/PLA-280/optimize-traffic-analytics-docker-buildself-hosting-execution
- remove unused cjs polyfills, only referenced in a few spots that don't affect running behavior
- fix otel tracing for pubsub + fastify
- remove blanket node auto otel registration in favor of lighter-weight individual plugins
- dropped node 20 from test matrix
@github-actions

Copy link
Copy Markdown

✅ Deployed to staging (tree: 5a35d2e3252c44f69ad12acffb69e858f634a13b)

@cmraible
cmraible merged commit 4f4d065 into main Aug 11, 2026
16 checks passed
@cmraible
cmraible deleted the feat/docker-optimize branch August 11, 2026 15:18
cmraible added a commit that referenced this pull request Aug 11, 2026
ref
https://linear.app/ghost/issue/PLA-280/optimize-traffic-analytics-docker-buildself-hosting-execution
- pino-logging-gcp-config pulled in the entire @google-cloud/logging
dependency just to lookup a project id. the full dependency pulls in
google-gax + protobufs which bloats the bundle + start time
significantly.
- replace logging index import with a shim that replicates the relevant
parts
- add LOG_FORMAT env var to disable GCP-formatted logs in non-gcp
environments

adding the shim shrinks the final output bundle by almost 2mb, and
improves cold-start time (on local APFS at least) by ~30%)

related to #810, but can be merged independently
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