MINOR - React and Java telemetry#27773
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds server-side placeholder substitution to the UI index.html payload so telemetry-related configuration (e.g., Sentry settings), cluster name, and application version can be injected at render time.
Changes:
- Populate additional
index.htmlplaceholders (sentryDsn,sentryEnvironment,sentryTraceSampleRate) from environment variables. - Populate
clusterNamefromOPENMETADATA_CLUSTER_NAME. - Populate
appVersionfromVersionResource’s catalog version.
| CONFIG_PROCESSED_HTML = | ||
| RAW_INDEX_HTML | ||
| .replace("${sentryDsn}", escapeJs(System.getenv().getOrDefault("SENTRY_UI_DSN", ""))) | ||
| .replace( | ||
| "${sentryEnvironment}", | ||
| escapeJs(System.getenv().getOrDefault("SENTRY_ENVIRONMENT", "development"))) | ||
| .replace( | ||
| "${sentryTraceSampleRate}", | ||
| escapeJs(System.getenv().getOrDefault("SENTRY_TRACE_SAMPLE_RATE", "0.5"))) | ||
| .replace( | ||
| "${clusterName}", | ||
| escapeJs(System.getenv().getOrDefault("OPENMETADATA_CLUSTER_NAME", "openmetadata"))) | ||
| .replace( | ||
| "${appVersion}", escapeJs(new VersionResource().getCatalogVersion().getVersion())); |
There was a problem hiding this comment.
New logic injects multiple telemetry-related placeholders into the index HTML, but there are no tests asserting that these new placeholders are correctly replaced and safely escaped. Adding a test fixture /assets/index.html that includes the new tokens (or updating the existing test resource) and asserting the output of getIndexFile(...) contains the resolved values would prevent regressions (e.g., placeholders leaking to the client).
| CONFIG_PROCESSED_HTML = | ||
| RAW_INDEX_HTML | ||
| .replace("${sentryDsn}", escapeJs(System.getenv().getOrDefault("SENTRY_UI_DSN", ""))) | ||
| .replace( | ||
| "${sentryEnvironment}", | ||
| escapeJs(System.getenv().getOrDefault("SENTRY_ENVIRONMENT", "development"))) | ||
| .replace( | ||
| "${sentryTraceSampleRate}", | ||
| escapeJs(System.getenv().getOrDefault("SENTRY_TRACE_SAMPLE_RATE", "0.5"))) | ||
| .replace( | ||
| "${clusterName}", | ||
| escapeJs(System.getenv().getOrDefault("OPENMETADATA_CLUSTER_NAME", "openmetadata"))) | ||
| .replace( | ||
| "${appVersion}", escapeJs(new VersionResource().getCatalogVersion().getVersion())); |
There was a problem hiding this comment.
The static HTML preprocessing replaces ${sentryDsn}, ${sentryEnvironment}, ${sentryTraceSampleRate}, ${clusterName}, and ${appVersion}. In the current repo, neither openmetadata-ui/src/main/resources/ui/index.html nor the test /assets/index.html contains these placeholders, so these replacements will be no-ops unless the built /assets/index.html template is also updated during the UI build/packaging. Please ensure the served /assets/index.html actually includes these tokens (or adjust the replacement keys accordingly), otherwise the telemetry config won’t be injected.
…NOR-Sentry-UI-Backend
Code Review 👍 Approved with suggestions 4 resolved / 5 findingsRefactored telemetry to ensure proper Sentry placeholder replacement and secure HTML injection, though the lazy initialization in getSentryConfiguration() requires synchronization for thread safety. 💡 Bug: Lazy getSentryConfiguration() is not thread-safeThe ✅ 4 resolved✅ Bug: Sentry placeholders not replaced in getIndex() endpoint path
✅ Performance: Env vars and VersionResource re-evaluated on every request
✅ Security: Env var values injected into HTML without escaping
✅ Bug: NPE if getIndexFile() called before initialize()
🤖 Prompt for agentsOptionsDisplay: compact → Showing less information. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|
|
* chore: added sentry for UI * chore: added sentry for UI * chore: added sentry for UI * chore: added sentry for UI and backend * chore: move setup to config * Update generated TypeScript types * chore: addressed CI comments * chore: handle no ui startup in IndexResource --------- Co-authored-by: IceS2 <pablo.takara@getcollate.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> (cherry picked from commit 457afab)
* chore: added sentry for UI * chore: added sentry for UI * chore: added sentry for UI * chore: added sentry for UI and backend * chore: move setup to config * Update generated TypeScript types * chore: addressed CI comments * chore: handle no ui startup in IndexResource --------- Co-authored-by: IceS2 <pablo.takara@getcollate.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* chore: added sentry for UI * chore: added sentry for UI * chore: added sentry for UI * chore: added sentry for UI and backend * chore: move setup to config * Update generated TypeScript types * chore: addressed CI comments * chore: handle no ui startup in IndexResource --------- Co-authored-by: IceS2 <pablo.takara@getcollate.io> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>



Describe your changes:
Added telemetry for UI and Java
Type of change:
Checklist:
Fixes <issue-number>: <short explanation>Summary by Gitar
SentryConfigurationschema to manage error tracking and performance monitoring settings.OpenMetadataApplicationConfigto include the new Sentry configuration block.IndexResourceon application startup to inject Sentry configuration details into the UIindex.html.IndexResourcefor safe JavaScript variable escaping.This will update automatically on new commits.