-
Notifications
You must be signed in to change notification settings - Fork 591
Add support for custom UI configuration in development mode #3194
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
Conversation
- Add Vite plugin to inject local config files into index.html during development - Support both JSON and JavaScript config formats (matching query-service behavior) - Add example config file (jaeger-ui.config.example.json) - Update .gitignore to exclude local config files - Update README.md with documentation for local development configuration Co-authored-by: yurishkuro <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3194 +/- ##
=======================================
Coverage 97.92% 97.92%
=======================================
Files 260 260
Lines 8144 8144
Branches 2146 2060 -86
=======================================
Hits 7975 7975
Misses 169 169 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| if (fs.existsSync(jsConfigPath)) { | ||
| try { | ||
| const jsContent = fs.readFileSync(jsConfigPath, 'utf-8'); | ||
| // Replace the JAEGER_CONFIG_JS comment with UIConfig function | ||
| // This mimics the Go server behavior for .js config files | ||
| const uiConfigFn = `function UIConfig() { ${jsContent} }`; | ||
| html = html.replace('// JAEGER_CONFIG_JS', uiConfigFn); | ||
| console.log('[jaeger-ui-config] Loaded config from jaeger-ui.config.js'); | ||
| return html; | ||
| } catch (err) { | ||
| console.error('[jaeger-ui-config] Error loading jaeger-ui.config.js:', err); | ||
| } | ||
| } |
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.
Critical Bug: Incorrect fallback behavior when JS config fails to load
When jaeger-ui.config.js exists but fails to load (e.g., syntax error, read error), the code logs the error but continues execution, potentially falling through to load jaeger-ui.config.json instead. This violates the documented priority rule that "JS takes priority".
Impact: If a developer creates a JS config file with a syntax error and also has a JSON config file, the plugin will silently use the JSON config instead of failing fast. This masks the JS config error and causes unexpected behavior.
Fix:
if (fs.existsSync(jsConfigPath)) {
try {
const jsContent = fs.readFileSync(jsConfigPath, 'utf-8');
const uiConfigFn = `function UIConfig() { ${jsContent} }`;
html = html.replace('// JAEGER_CONFIG_JS', uiConfigFn);
console.log('[jaeger-ui-config] Loaded config from jaeger-ui.config.js');
return html;
} catch (err) {
console.error('[jaeger-ui-config] Error loading jaeger-ui.config.js:', err);
return html; // Return without trying JSON config
}
}| if (fs.existsSync(jsConfigPath)) { | |
| try { | |
| const jsContent = fs.readFileSync(jsConfigPath, 'utf-8'); | |
| // Replace the JAEGER_CONFIG_JS comment with UIConfig function | |
| // This mimics the Go server behavior for .js config files | |
| const uiConfigFn = `function UIConfig() { ${jsContent} }`; | |
| html = html.replace('// JAEGER_CONFIG_JS', uiConfigFn); | |
| console.log('[jaeger-ui-config] Loaded config from jaeger-ui.config.js'); | |
| return html; | |
| } catch (err) { | |
| console.error('[jaeger-ui-config] Error loading jaeger-ui.config.js:', err); | |
| } | |
| } | |
| if (fs.existsSync(jsConfigPath)) { | |
| try { | |
| const jsContent = fs.readFileSync(jsConfigPath, 'utf-8'); | |
| // Replace the JAEGER_CONFIG_JS comment with UIConfig function | |
| // This mimics the Go server behavior for .js config files | |
| const uiConfigFn = `function UIConfig() { ${jsContent} }`; | |
| html = html.replace('// JAEGER_CONFIG_JS', uiConfigFn); | |
| console.log('[jaeger-ui-config] Loaded config from jaeger-ui.config.js'); | |
| return html; | |
| } catch (err) { | |
| console.error('[jaeger-ui-config] Error loading jaeger-ui.config.js:', err); | |
| return html; // Return without trying JSON config | |
| } | |
| } |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
The Jaeger UI config is normally injected by the Go query-service into
index.html. When running locally vianpm start, there was no way to provide custom configuration.Changes
vite.config.mts): AddedjaegerUiConfigPluginthat transformsindex.htmlto inject local config files, mimicking the query-service behaviorjaeger-ui.config.jsonandjaeger-ui.config.js(JS takes priority, same as query-service)README.md): Added "Configuration for Local Development" sectionjaeger-ui.config.example.jsonas a starting template.gitignoreUsage
Create
packages/jaeger-ui/jaeger-ui.config.json:{ "dependencies": { "menuEnabled": true }, "monitor": { "menuEnabled": false } }Or for dynamic config,
jaeger-ui.config.js:Then run
npm start- the plugin logs which config file is loaded.Screenshot
Custom menu injected via local config file:
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
iojs.org/usr/bin/curl curl -q --fail --compressed -L -s REDACTED -o -(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.