Analysis of commit 694a71fbc34d56871dbf9e0ae00699e045fd30ad
Assignee: @copilot
Summary
A near-identical block constructs an IEventSampler for IdCompressor telemetry sampling (~5% of sessions) in multiple modules. This is real logic duplication (not boilerplate) and risks future divergence (e.g., sampling rate changes, semantics of “session” sampling, logger wiring).
Duplication Details
Pattern: “IdCompressor telemetry session sampler”
Impact Analysis
- Maintainability: Any future updates (e.g., tuning 5% rate, sampling strategy, or adding telemetry dimensions) must be applied in multiple places.
- Bug Risk: It’s easy for one site to drift (e.g., different sampling % or sampler lifetime), causing inconsistent telemetry and confusing analysis.
- Code Bloat: Small but repeated logic block.
Refactoring Recommendations
-
Extract a shared helper for “fixed-per-session” sampling
- Example API:
createFixedSessionSampler(probability: number): IEventSampler
- Suggested location: a shared utilities package already depended on by both call sites (e.g.,
packages/utils/telemetry-utils/ or a small helper co-located with createSampledLogger if appropriate).
- Benefits: single source of truth for sampling semantics and rate.
-
(Optional) Consider deterministic sampling
- If desired, base sampling on a stable session identifier hash rather than
Math.random() to improve reproducibility across restarts.
Implementation Checklist
Analysis Metadata
- Analyzed Files: Focused semantic scan of high-churn changed
.ts/.cjs/.mjs files in the commit
- Detection Method: Serena symbol inspection + normalized duplicate-window scan
- Commit:
694a71fbc34d56871dbf9e0ae00699e045fd30ad
- Analysis Date: 2026-04-09T21:51:31.360Z
Generated by Duplicate Code Detector · ◷
To install this agentic workflow, run
gh aw add github/gh-aw/.github/workflows/duplicate-code-detector.md@94662b1dee8ce96c876ba9f33b3ab8be32de82a4
Analysis of commit
694a71fbc34d56871dbf9e0ae00699e045fd30adAssignee:
@copilotSummary
A near-identical block constructs an
IEventSamplerfor IdCompressor telemetry sampling (~5% of sessions) in multiple modules. This is real logic duplication (not boilerplate) and risks future divergence (e.g., sampling rate changes, semantics of “session” sampling, logger wiring).Duplication Details
Pattern: “IdCompressor telemetry session sampler”
Severity: Medium
Occurrences: 2
Locations:
packages/runtime/container-runtime/src/containerRuntime.ts(around lines 1192–1203; constant body 1193–1200)experimental/dds/tree/src/SharedTree.ts(around lines 570–581; constant body 571–578)Code Sample (duplicated):
Impact Analysis
Refactoring Recommendations
Extract a shared helper for “fixed-per-session” sampling
createFixedSessionSampler(probability: number): IEventSamplerpackages/utils/telemetry-utils/or a small helper co-located withcreateSampledLoggerif appropriate).(Optional) Consider deterministic sampling
Math.random()to improve reproducibility across restarts.Implementation Checklist
Analysis Metadata
.ts/.cjs/.mjsfiles in the commit694a71fbc34d56871dbf9e0ae00699e045fd30ad