-
Notifications
You must be signed in to change notification settings - Fork 320
chore: split json otel collector to enable both during dev #1247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
E2E Test Results✅ All tests passed • 25 passed • 3 skipped • 223s
|
Pull Request Review: Split JSON OTel Collector for Dev EnvironmentThis PR introduces a second OTel collector instance (otel-collector-json) to run alongside the standard collector during development. Strengths
Critical Issues1. Server Startup Logic Bug (HIGH PRIORITY) 2. Missing Tests (HIGH PRIORITY) 3. Missing Documentation (MEDIUM PRIORITY) Other IssuesOPAMP_PORT Validation (LOW) Redundant Conditional (LOW) Hardcoded Port (MEDIUM) API Key Handling (INFO) Performance Note Concurrency Colors (LOW) RecommendationsMust Fix:
Should Fix: Nice to Have: OverallWell-structured PR that achieves its goal. Main blockers are the logic bug and missing tests. Once addressed, ready to merge! Reviewed per CLAUDE.md conventions |
Pull Request ReviewSummaryThis PR adds support for running a separate JSON-enabled OpenTelemetry collector instance in development mode alongside the standard collector. This allows testing both JSON and non-JSON schemas simultaneously during development. Code Quality & Best Practices ✅Positive aspects:
Areas for improvement: 1. Logic Clarity in server.ts:49if (!(config.IS_DEV && !config.IS_OPAMP_ONLY)) {This double-negative condition is confusing. Consider refactoring for readability: // Start app server unless we're in dev mode running OPAMP only
const shouldStartAppServer = !(config.IS_DEV && config.IS_OPAMP_ONLY);
if (shouldStartAppServer) {
// ...
}2. Potential Issue: Server Property AccessIn server.ts:49-60, this.appServer is only conditionally initialized. If the condition is false, this.appServer will be undefined, which could cause issues if any code tries to access it later. Consider initializing it as nullable: protected appServer?: http.Server; // Make it optional3. Magic Number in opampController.ts:160authorization: apiKeys.length > 0 ? apiKeys[0] : '',Silently using an empty string when no API keys exist could lead to authentication failures that are hard to debug. Consider adding a warning log or comment explaining this behavior. 4. Type Safety in opampController.ts:263...(otlpExporter ? otlpExporter : {})This can be simplified or better yet, initialize otlpExporter as an empty object and conditionally add the property. Performance Considerations ⚡
Security Concerns 🔒1. Development-Only Hardcoded EndpointIn opampController.ts:158: endpoint: 'http://host.docker.internal:14318',✅ Good: This is properly gated behind config.IS_DEV 2. API Key HandlingIn opampController.ts:160: authorization: apiKeys.length > 0 ? apiKeys[0] : '',
3. Port ConflictsThe new otel-collector-json service uses remapped ports (13134, 24226, 14317, 14318, 18888). Ensure these ports are documented to avoid developer confusion when troubleshooting connection issues. Potential Bugs 🐛1. Uninitialized Server in Edge CasesIf config.IS_DEV && config.IS_OPAMP_ONLY is true, this.appServer won't be initialized but isn't marked as optional. This could cause runtime errors if any shutdown or cleanup code tries to access it. Recommendation: Update the type definition: protected appServer?: http.Server; // Make optional
protected opampServer!: http.Server; // This is always initialized2. Missing Port Configuration ValidationThe OPAMP_PORT is used directly without validation. If it's undefined or invalid, Number.parseInt will return NaN, causing the server to fail silently. Recommendation: Add validation in config.ts Test Coverage 🧪Missing test coverage:
Recommendations:
Documentation 📝Missing:
Recommendations:
Additional SuggestionsDocker Compose ConfigurationIn docker-compose.dev.yml, consider:
Environment VariablesConsider adding to .env.example or documentation:
VerdictOverall Assessment: This is a well-structured change that follows the codebase patterns. The main concerns are around:
Recommendation: ✅ Approve with suggestions - The code is functional and safe for development use, but would benefit from the improvements listed above before merging. Priority Issues to Address:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding OTEL_AGENT_FEATURE_GATE_ARG should be sufficient. We can let developers decide whether to switch over and test the JSON columns to minimize code changes. If we are going to test JSON features more, imo we should just enable it by default
Gets us closer to a staging instance of json