-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(dashboards): Add Node.js runtime metrics prebuilt dashboard UI #113517
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
Open
chargome
wants to merge
10
commits into
master
Choose a base branch
from
cg/nodejs-health-dashboard-frontend
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e4812b2
add dashboard
chargome fcfb0a9
fix test
chargome e6e6985
rm test file
chargome bb790f5
extract trace metric field
chargome 22209fe
event loop delay table
chargome 5ed23c0
rm event loop delay tables
chargome 46cedba
Merge branch 'master' into cg/nodejs-health-dashboard-frontend
chargome 1d159e0
use types
chargome 184996d
replace placeholder
chargome 86eebba
Merge branch 'master' into cg/nodejs-health-dashboard-frontend
chargome File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
214 changes: 214 additions & 0 deletions
214
static/app/views/dashboards/utils/prebuiltConfigs/nodeRuntimeMetrics/nodeRuntimeMetrics.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,214 @@ | ||
| import {t} from 'sentry/locale'; | ||
| import {DurationUnit, SizeUnit} from 'sentry/utils/discover/fields'; | ||
| import {DisplayType, WidgetType, type Widget} from 'sentry/views/dashboards/types'; | ||
| import type {PrebuiltDashboard} from 'sentry/views/dashboards/utils/prebuiltConfigs'; | ||
| import {DASHBOARD_TITLE} from 'sentry/views/dashboards/utils/prebuiltConfigs/nodeRuntimeMetrics/settings'; | ||
| import {spaceWidgetsEquallyOnRow} from 'sentry/views/dashboards/utils/prebuiltConfigs/utils/spaceWidgetsEquallyOnRow'; | ||
| import {traceMetricField} from 'sentry/views/dashboards/utils/prebuiltConfigs/utils/traceMetricField'; | ||
| import {SpanFields} from 'sentry/views/insights/types'; | ||
|
|
||
| const INTERVAL = '5m'; | ||
|
|
||
| const KPI_WIDGETS = spaceWidgetsEquallyOnRow( | ||
| [ | ||
| { | ||
| id: 'node-runtime-event-loop-utilization-kpi', | ||
| title: t('Event Loop Utilization'), | ||
| description: t( | ||
| 'Average fraction of time the Node.js event loop is active (0-100%) across the selected time range. High utilization means less capacity to handle new work and may indicate CPU-bound processing or blocking operations.' | ||
| ), | ||
| displayType: DisplayType.BIG_NUMBER, | ||
| widgetType: WidgetType.TRACEMETRICS, | ||
| interval: INTERVAL, | ||
| queries: [ | ||
| { | ||
| name: '', | ||
| fields: [ | ||
| traceMetricField('avg', 'node.runtime.event_loop.utilization', 'gauge', null), | ||
| ], | ||
| aggregates: [ | ||
| traceMetricField('avg', 'node.runtime.event_loop.utilization', 'gauge', null), | ||
| ], | ||
| columns: [], | ||
| conditions: '', | ||
| orderby: '', | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| id: 'node-runtime-cpu-utilization-kpi', | ||
| title: t('CPU Utilization'), | ||
| description: t( | ||
| 'Average CPU usage across all cores over the selected time range. Values above 1.0 (100%) are possible on multi-core systems. Sustained high utilization may indicate compute-bound workloads or insufficient scaling.' | ||
|
chargome marked this conversation as resolved.
|
||
| ), | ||
| displayType: DisplayType.BIG_NUMBER, | ||
| widgetType: WidgetType.TRACEMETRICS, | ||
| interval: INTERVAL, | ||
| queries: [ | ||
| { | ||
| name: '', | ||
| fields: [ | ||
| traceMetricField('avg', 'node.runtime.cpu.utilization', 'gauge', null), | ||
| ], | ||
| aggregates: [ | ||
| traceMetricField('avg', 'node.runtime.cpu.utilization', 'gauge', null), | ||
| ], | ||
| columns: [], | ||
| conditions: '', | ||
| orderby: '', | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| id: 'node-runtime-process-uptime-kpi', | ||
| title: t('Process Uptime'), | ||
| description: t( | ||
| 'Total process uptime summed across instances. Sudden resets indicate process crashes or restarts. Useful for detecting instability and correlating with deployment events.' | ||
| ), | ||
| displayType: DisplayType.BIG_NUMBER, | ||
| widgetType: WidgetType.TRACEMETRICS, | ||
| interval: INTERVAL, | ||
| queries: [ | ||
| { | ||
| name: '', | ||
| fields: [ | ||
| traceMetricField( | ||
| 'sum', | ||
| 'node.runtime.process.uptime', | ||
| 'counter', | ||
| DurationUnit.SECOND | ||
| ), | ||
| ], | ||
| aggregates: [ | ||
| traceMetricField( | ||
| 'sum', | ||
| 'node.runtime.process.uptime', | ||
| 'counter', | ||
| DurationUnit.SECOND | ||
| ), | ||
| ], | ||
| columns: [], | ||
| conditions: '', | ||
| orderby: '', | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| 0, | ||
| {h: 1, minH: 1} | ||
| ); | ||
|
|
||
| const MEMORY_WIDGETS = spaceWidgetsEquallyOnRow( | ||
| [ | ||
| { | ||
| id: 'node-runtime-memory-usage', | ||
| title: t('Memory Usage'), | ||
| description: t( | ||
| 'Resident Set Size (RSS, total memory footprint), V8 heap total (allocated), and heap used (in-use). Growing RSS without matching heap growth may indicate native memory leaks. Heap used approaching heap total triggers more frequent garbage collection.' | ||
| ), | ||
| displayType: DisplayType.AREA, | ||
| widgetType: WidgetType.TRACEMETRICS, | ||
| interval: INTERVAL, | ||
| queries: [ | ||
| { | ||
| name: '', | ||
| fields: [ | ||
| traceMetricField('avg', 'node.runtime.mem.rss', 'gauge', SizeUnit.BYTE), | ||
| traceMetricField( | ||
| 'avg', | ||
| 'node.runtime.mem.heap_total', | ||
| 'gauge', | ||
| SizeUnit.BYTE | ||
| ), | ||
| traceMetricField('avg', 'node.runtime.mem.heap_used', 'gauge', SizeUnit.BYTE), | ||
| ], | ||
| aggregates: [ | ||
| traceMetricField('avg', 'node.runtime.mem.rss', 'gauge', SizeUnit.BYTE), | ||
| traceMetricField( | ||
| 'avg', | ||
| 'node.runtime.mem.heap_total', | ||
| 'gauge', | ||
| SizeUnit.BYTE | ||
| ), | ||
| traceMetricField('avg', 'node.runtime.mem.heap_used', 'gauge', SizeUnit.BYTE), | ||
| ], | ||
| columns: [], | ||
| conditions: '', | ||
| orderby: '', | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| 1 | ||
| ); | ||
|
|
||
| const CORRELATION_WIDGETS = spaceWidgetsEquallyOnRow( | ||
| [ | ||
| { | ||
| id: 'node-runtime-cpu-utilization-over-time', | ||
| title: t('CPU Utilization Over Time'), | ||
| description: t( | ||
| 'CPU utilization trend over time. Correlate spikes with deployments, traffic changes, or event loop delay increases to identify compute-bound bottlenecks.' | ||
| ), | ||
| displayType: DisplayType.LINE, | ||
| widgetType: WidgetType.TRACEMETRICS, | ||
|
chargome marked this conversation as resolved.
|
||
| interval: INTERVAL, | ||
| queries: [ | ||
| { | ||
| name: '', | ||
| fields: [ | ||
| traceMetricField('avg', 'node.runtime.cpu.utilization', 'gauge', null), | ||
| ], | ||
| aggregates: [ | ||
| traceMetricField('avg', 'node.runtime.cpu.utilization', 'gauge', null), | ||
| ], | ||
| columns: [], | ||
| conditions: '', | ||
| orderby: '', | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| id: 'node-runtime-http-request-duration', | ||
| title: t('HTTP Request Duration'), | ||
| description: t( | ||
| 'Server-side HTTP request latency (p50 and p95). Compare with event loop delay and CPU utilization to determine if slow responses are caused by runtime bottlenecks or application logic.' | ||
| ), | ||
| displayType: DisplayType.LINE, | ||
| widgetType: WidgetType.SPANS, | ||
| interval: INTERVAL, | ||
| queries: [ | ||
| { | ||
| name: '', | ||
| fields: [ | ||
| `p50(${SpanFields.SPAN_DURATION})`, | ||
| `p95(${SpanFields.SPAN_DURATION})`, | ||
| ], | ||
| aggregates: [ | ||
| `p50(${SpanFields.SPAN_DURATION})`, | ||
| `p95(${SpanFields.SPAN_DURATION})`, | ||
| ], | ||
| columns: [], | ||
| conditions: `${SpanFields.SPAN_OP}:http.server`, | ||
| orderby: '', | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| 3 | ||
| ); | ||
|
|
||
| const WIDGETS: Widget[] = [...KPI_WIDGETS, ...MEMORY_WIDGETS, ...CORRELATION_WIDGETS]; | ||
|
|
||
| export const NODE_RUNTIME_METRICS_PREBUILT_CONFIG: PrebuiltDashboard = { | ||
| dateCreated: '', | ||
| filters: {}, | ||
| projects: [], | ||
| title: DASHBOARD_TITLE, | ||
| widgets: WIDGETS, | ||
| onboarding: { | ||
| type: 'custom', | ||
| componentId: 'node-runtime-metrics', | ||
| requiredProjectFlags: ['firstTransactionEvent'], | ||
| }, | ||
| }; | ||
3 changes: 3 additions & 0 deletions
3
static/app/views/dashboards/utils/prebuiltConfigs/nodeRuntimeMetrics/settings.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import {t} from 'sentry/locale'; | ||
|
|
||
| export const DASHBOARD_TITLE = t('Node.js Runtime Metrics'); |
14 changes: 14 additions & 0 deletions
14
static/app/views/dashboards/utils/prebuiltConfigs/utils/traceMetricField.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import type {DataUnit} from 'sentry/utils/discover/fields'; | ||
| import type {TraceMetricTypeValue} from 'sentry/views/explore/metrics/types'; | ||
|
|
||
| type TraceMetricAggregation = 'avg' | 'sum' | 'max'; | ||
|
|
||
| // Trace metric field format: `aggregation(value,metric_name,metric_type,unit)` | ||
| export function traceMetricField( | ||
| aggregation: TraceMetricAggregation, | ||
| name: string, | ||
| metricType: TraceMetricTypeValue, | ||
| unit: DataUnit | ||
| ) { | ||
| return `${aggregation}(value,${name},${metricType},${unit ?? '-'})`; | ||
| } | ||
|
cursor[bot] marked this conversation as resolved.
|
||
36 changes: 36 additions & 0 deletions
36
static/app/views/insights/pages/nodeRuntime/onboarding.spec.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import {render, screen} from 'sentry-test/reactTestingLibrary'; | ||
|
|
||
| import {NodeRuntimeMetricsOnboarding} from 'sentry/views/insights/pages/nodeRuntime/onboarding'; | ||
|
|
||
| describe('NodeRuntimeMetricsOnboarding', () => { | ||
| it('renders setup instructions with the SDK version requirement', () => { | ||
| render(<NodeRuntimeMetricsOnboarding />); | ||
|
|
||
| expect( | ||
| screen.getByRole('heading', {name: 'Monitor Node.js Runtime Metrics'}) | ||
| ).toBeInTheDocument(); | ||
| expect(screen.getByText('@sentry/node 10.47.0')).toBeInTheDocument(); | ||
| expect(screen.getByText(/or later/)).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByText(/Data appears after the first collection interval/) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('includes the integration code snippet', () => { | ||
| render(<NodeRuntimeMetricsOnboarding />); | ||
|
|
||
| expect( | ||
| screen.getByText(/Sentry\.nodeRuntimeMetricsIntegration\(\)/) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('links to the integration docs', () => { | ||
| render(<NodeRuntimeMetricsOnboarding />); | ||
|
|
||
| const docsLink = screen.getByRole('button', {name: 'Read the Docs'}); | ||
| expect(docsLink).toHaveAttribute( | ||
| 'href', | ||
| expect.stringContaining('noderuntimemetrics') | ||
| ); | ||
| }); | ||
| }); |
64 changes: 64 additions & 0 deletions
64
static/app/views/insights/pages/nodeRuntime/onboarding.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import emptyStateImg from 'sentry-images/spot/performance-waiting-for-span.svg'; | ||
|
|
||
| import {LinkButton} from '@sentry/scraps/button'; | ||
| import {CodeBlock, InlineCode} from '@sentry/scraps/code'; | ||
| import {Image} from '@sentry/scraps/image'; | ||
| import {Flex} from '@sentry/scraps/layout'; | ||
| import {Heading, Text} from '@sentry/scraps/text'; | ||
|
|
||
| import {Panel} from 'sentry/components/panels/panel'; | ||
| import {t, tct} from 'sentry/locale'; | ||
|
|
||
| const DOCS_URL = | ||
| 'https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/noderuntimemetrics/'; | ||
|
|
||
| const CODE_SNIPPET = `import * as Sentry from '@sentry/node'; | ||
|
|
||
| Sentry.init({ | ||
| dsn: '__YOUR_DSN__', | ||
| integrations: [Sentry.nodeRuntimeMetricsIntegration()], | ||
| });`; | ||
|
|
||
| export function NodeRuntimeMetricsOnboarding() { | ||
| return ( | ||
| <Panel> | ||
| <Flex justify="center"> | ||
| <Flex padding="xl" align="center" wrap="wrap-reverse" gap="3xl" maxWidth="1000px"> | ||
| <Flex direction="column" gap="xl" flex="5" align="start"> | ||
| <Heading as="h3" size="xl"> | ||
| {t('Monitor Node.js Runtime Metrics')} | ||
| </Heading> | ||
|
|
||
| <Text as="p" size="md"> | ||
| {t( | ||
| 'Track CPU utilization, memory usage, and event loop health for your Node.js processes. Enable the runtime metrics integration to start collecting data.' | ||
| )} | ||
| </Text> | ||
|
|
||
| <Text as="p" size="md"> | ||
| {tct('Requires [pkg] or later.', { | ||
| pkg: <InlineCode>@sentry/node 10.47.0</InlineCode>, | ||
| })} | ||
| </Text> | ||
|
|
||
| <CodeBlock language="javascript">{CODE_SNIPPET}</CodeBlock> | ||
|
|
||
| <Text as="p" size="sm" variant="muted"> | ||
| {t( | ||
| 'Data appears after the first collection interval (default 30 seconds).' | ||
| )} | ||
| </Text> | ||
|
|
||
| <LinkButton priority="primary" external href={DOCS_URL}> | ||
| {t('Read the Docs')} | ||
| </LinkButton> | ||
| </Flex> | ||
|
|
||
| <Flex flex="3" justify="center"> | ||
| <Image src={emptyStateImg} alt="" width="100%" /> | ||
| </Flex> | ||
| </Flex> | ||
| </Flex> | ||
| </Panel> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.