Repository navigation
chore: pyroscope default sampling rates - #4596
Conversation
Summary by CodeRabbit
WalkthroughUpdated Pyroscope initialization defaults and added env-driven tags in Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Process
participant Env as Env Vars
participant Pyro as Pyroscope SDK
Process->>Env: Read PYROSCOPE_SERVER_ADDRESS
alt Address present
Process->>Env: Read NAMESPACE / INSTANCE_ID / CLUSTER
note over Process,Env: Build tags { namespace, instance, cluster } (defaults "")
Process->>Pyro: Initialize with updated defaults
note right of Pyro: flushIntervalMs=60000\nheap.samplingIntervalBytes=524288\nwall.samplingDurationMs=60000\nwall.samplingIntervalMicros=10000\ncollectCpuTime default true (unless 'false')
Pyro-->>Process: pyroscopeStart / initialized flag
else No address
note over Process: Skip Pyroscope initialization
end
sequenceDiagram
autonumber
actor Client
participant Koa as Middleware
participant Ctx as ctx
participant Util as getDestTypeFromContext
participant Wrap as wrapWithLabels
participant Next as Downstream Handler
Client->>Koa: HTTP request
Koa->>Ctx: Inspect ctx.path
alt ctx.path includes "/source"
Koa-->>Koa: integration_type = "source"
else
Koa-->>Koa: integration_type = "destination"
end
Koa->>Util: getDestTypeFromContext(ctx)
Util-->>Koa: name or falsy
Koa-->>Koa: integration_name = result || "unknown"
Koa->>Wrap: Apply labels {type, name}
Wrap->>Next: Invoke next middleware/handler
Next-->>Client: Response
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Suggestions
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/middleware.js (2)
57-57: Anchor the path check to avoid false positives.
includes('/source')may misclassify paths such as/internal/source-cacheassource. Prefer an anchored test that matches our API shape.- integration_type: ctx.path.includes('/source') ? 'source' : 'destination', + // Match `/v{n}/source` or `/v{n}/sources` at the start of the path + integration_type: /^\/v\d+\/sources?\b/.test(ctx.path) ? 'source' : 'destination',
58-58: Clarify fallback behavior for empty strings.If
getDestTypeFromContext(ctx)returns'',|| 'unknown'assigns'unknown'. If that’s intentional, keep as-is. If you only want to fallback on null/undefined, switch to??.- integration_name: getDestTypeFromContext(ctx) || 'unknown', + // Use `??` if you only want to fallback for null/undefined + integration_name: getDestTypeFromContext(ctx) ?? 'unknown',ESLint focus (JS file):
- Warning: prefer-nullish-coalescing (if enabled) for nullish-only fallback.
src/index.ts (1)
50-54: Avoid emitting empty-string tags; build tags dynamically.Empty values can bloat label cardinality and clutter Pyroscope UI. Emit only tags that are set.
- tags: { - namespace: process.env.NAMESPACE || '', - instance: process.env.INSTANCE_ID || '', - cluster: process.env.CLUSTER || '', - } + tags: buildPyroscopeTags(),Add this helper (outside the shown range, e.g., above the
if (process.env.PYROSCOPE_SERVER_ADDRESS) {block):function buildPyroscopeTags(): Record<string, string> { const tags: Record<string, string> = {}; if (process.env.NAMESPACE) tags.namespace = process.env.NAMESPACE!; if (process.env.INSTANCE_ID) tags.instance = process.env.INSTANCE_ID!; if (process.env.CLUSTER) tags.cluster = process.env.CLUSTER!; return tags; }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/index.ts(1 hunks)src/middleware.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.js
⚙️ CodeRabbit configuration file
Focus on ESLint errors (max 3) and warnings (max 5).
Files:
src/middleware.js
🧬 Code graph analysis (1)
src/middleware.js (1)
src/testRouter.js (1)
ctx(179-179)
🪛 GitHub Actions: Verify
src/index.ts
[error] 49-50: git diff --exit-code failed with exit code 1 due to unstaged changes in src/index.ts (collectCpuTime line change).
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (2)
src/index.ts (2)
34-46: Defaults change looks good for lowering overhead.The higher intervals (flush: 60s, heap sampling: 512 KiB, wall: 60s/10,000 µs) align with the PR goal to reduce CPU/memory. No functional concerns here.
48-48: Simplify the boolean and eliminate CI formatting diffs
- Change the ternary to a direct inequality:
- collectCpuTime: process.env.PYROSCOPE_WALL_COLLECT_CPU_TIME === 'false' ? false : true, + collectCpuTime: process.env.PYROSCOPE_WALL_COLLECT_CPU_TIME !== 'false',- After applying that change, re-run Prettier and commit any resulting formatting updates so CI passes without unstaged diffs.
|
Allure Test reports for this run are available at:
|
1 similar comment
|
Allure Test reports for this run are available at:
|
2ce4892 to
9be4b2c
Compare
|
Allure Test reports for this run are available at:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/index.ts (1)
50-54: Avoid emitting empty tag values; send only populated tagsEmpty-string tag values add noise/cardinality without value. Filter them out.
- tags: { - namespace: process.env.NAMESPACE || '', - instance: process.env.INSTANCE_ID || '', - cluster: process.env.CLUSTER || '', - } + tags: Object.fromEntries( + Object.entries({ + namespace: process.env.NAMESPACE, + instance: process.env.INSTANCE_ID, + cluster: process.env.CLUSTER, + }).filter(([, v]) => v && v.trim() !== '') + ) as Record<string, string>Optional: if INSTANCE_ID isn’t provided, consider defaulting to
${process.pid}or a hostname+pid to distinguish workers.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/index.ts(1 hunks)src/middleware.js(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/middleware.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image ARM64
- GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4596 +/- ##
===========================================
- Coverage 91.79% 91.78% -0.01%
===========================================
Files 642 642
Lines 33928 33931 +3
Branches 8040 8041 +1
===========================================
+ Hits 31143 31145 +2
- Misses 2533 2534 +1
Partials 252 252 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|



What are the changes introduced in this PR?
What is the related Linear task?
Resolves INT-3894
Please explain the objectives of your changes below
Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here
Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?
No
Any new dependencies introduced with this change?
No
Any new generic utility introduced or modified. Please explain the changes.
No
Any technical or performance related pointers to consider with the change?
Yes ( Improves performance - pyroscope's aggressive defaults were consuming too much CPU and memory earlier )
@coderabbitai review
Developer checklist
My code follows the style guidelines of this project
No breaking changes are being introduced.
All related docs linked with the PR?
All changes manually tested?
Any documentation changes needed with this change?
Is the PR limited to 10 file changes?
Is the PR limited to one linear task?
Are relevant unit and component test-cases added in new readability format?
Reviewer checklist
Is the type of change in the PR title appropriate as per the changes?
Verified that there are no credentials or confidential data exposed with the changes.