Skip to content

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

Open
acburdine wants to merge 1 commit into
mainfrom
feat/docker-optimize
Open

🎨 Improved otel code, cleaned up cjs polyfills#810
acburdine wants to merge 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: 16 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: af50bc95-05c6-4010-8300-ccac7d7d900a

📥 Commits

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

⛔ 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

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 reflects the main changes: OpenTelemetry improvements and removal of CJS polyfills.
Description check ✅ Passed The description is directly related to the PR changes, covering CJS polyfills and OpenTelemetry tracing updates.
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
@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.

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
@cmraible
cmraible force-pushed the feat/docker-optimize branch from 8696f7b to c4de090 Compare August 10, 2026 15:28
@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)

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