SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
feat: display HTTP status badge in trace details v2 spans (#8699)
Shaheer Kochai32410baa72b7
diff --git a/frontend/package.json b/frontend/package.jsonindex 3f61dd568c..a82c1305ec 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -43,6 +43,7 @@"@radix-ui/react-tooltip": "1.0.7","@sentry/react": "8.41.0","@sentry/webpack-plugin": "2.22.6",+ "@signozhq/badge": "0.0.2","@signozhq/calendar": "0.0.0","@signozhq/design-tokens": "1.1.4","@signozhq/input": "0.0.2",diff --git a/frontend/src/components/HttpStatusBadge/HttpStatusBadge.tsx b/frontend/src/components/HttpStatusBadge/HttpStatusBadge.tsxnew file mode 100644index 0000000000..97a3eb0809--- /dev/null+++ b/frontend/src/components/HttpStatusBadge/HttpStatusBadge.tsx@@ -0,0 +1,50 @@+import { Badge } from '@signozhq/badge';++type BadgeColor =+ | 'vanilla'+ | 'robin'+ | 'forest'+ | 'amber'+ | 'sienna'+ | 'cherry'+ | 'sakura'+ | 'aqua';++interface HttpStatusBadgeProps {+ statusCode: string | number;+}++function getStatusCodeColor(statusCode: number): BadgeColor {+ if (statusCode >= 200 && statusCode < 300) {+ return 'forest'; // Success - green+ }+ if (statusCode >= 300 && statusCode < 400) {+ return 'robin'; // Redirect - blue+ }+ if (statusCode >= 400 && statusCode < 500) {+ return 'amber'; // Client error - amber+ }+ if (statusCode >= 500) {+ return 'cherry'; // Server error - red+ }+ if (statusCode >= 100 && statusCode < 200) {+ return 'vanilla'; // Informational - neutral+ }+ return 'robin'; // Default fallback+}++function HttpStatusBadge({+ statusCode,+}: HttpStatusBadgeProps): JSX.Element | null {+ const numericStatusCode = Number(statusCode);++ if (!numericStatusCode || numericStatusCode <= 0) {+ return null;+ }++ const color = getStatusCodeColor(numericStatusCode);++ return <Badge color={color}>{statusCode}</Badge>;+}++export default HttpStatusBadge;diff --git a/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/Success.styles.scss b/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/Success.styles.scssindex afff69ee58..a2400a188e 100644--- a/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/Success.styles.scss+++ b/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/Success.styles.scss@@ -149,6 +149,11 @@background-color: #0b0c0e;height: 100%;justify-content: center;+ &:not(:first-child) {+ .first-row {+ width: calc(100% - 28px);+ }+ }.first-row {display: flex;@@ -161,6 +166,7 @@display: flex;gap: 6px;flex-shrink: 0;+ align-items: center;.collapse-uncollapse-button {display: flex;diff --git a/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/Success.tsx b/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/Success.tsxindex 5e8d536d62..2ea43fb8a9 100644--- a/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/Success.tsx+++ b/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/Success.tsx@@ -6,6 +6,7 @@ import { ColumnDef, createColumnHelper } from '@tanstack/react-table';import { Virtualizer } from '@tanstack/react-virtual';import { Button, Tooltip, Typography } from 'antd';import cx from 'classnames';+import HttpStatusBadge from 'components/HttpStatusBadge/HttpStatusBadge';import { TableV3 } from 'components/TableV3/TableV3';import { themeColors } from 'constants/theme';import { convertTimeToRelevantUnit } from 'container/TraceDetail/utils';@@ -144,6 +145,7 @@ function SpanOverview({)}<Typography.Text className="span-name">{span.name}</Typography.Text></div>+ <HttpStatusBadge statusCode={span.tagMap?.['http.status_code']} /></section><section className="second-row"><div style={{ width: '2px', background: color, height: '100%' }} />diff --git a/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/__tests__/SpanDuration.test.tsx b/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/__tests__/SpanDuration.test.tsxindex 0ab067837a..6ba02dc5a3 100644--- a/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/__tests__/SpanDuration.test.tsx+++ b/frontend/src/container/TraceWaterfall/TraceWaterfallStates/Success/__tests__/SpanDuration.test.tsx@@ -9,6 +9,9 @@ import { SpanDuration } from '../Success';// Mock the hooksjest.mock('hooks/useSafeNavigate');jest.mock('hooks/useUrlQuery');+jest.mock('@signozhq/badge', () => ({+ Badge: jest.fn(),+}));const mockSpan: Span = {spanId: 'test-span-id',diff --git a/frontend/src/pages/TraceDetail/__test__/TraceDetail.test.tsx b/frontend/src/pages/TraceDetail/__test__/TraceDetail.test.tsxindex ad2e050566..a1e27d7cc1 100644--- a/frontend/src/pages/TraceDetail/__test__/TraceDetail.test.tsx+++ b/frontend/src/pages/TraceDetail/__test__/TraceDetail.test.tsx@@ -8,6 +8,10 @@ import TraceDetail from '..';window.HTMLElement.prototype.scrollIntoView = jest.fn();+jest.mock('@signozhq/badge', () => ({+ Badge: jest.fn(),+}));+jest.mock('react-router-dom', () => ({...jest.requireActual('react-router-dom'),useLocation: (): { pathname: string; search: string } => ({diff --git a/frontend/yarn.lock b/frontend/yarn.lockindex b7755b736f..25751922fc 100644--- a/frontend/yarn.lock+++ b/frontend/yarn.lock@@ -3793,7 +3793,7 @@"@babel/runtime" "^7.13.10""@radix-ui/react-compose-refs" "1.0.1"-"@radix-ui/[email protected]", "@radix-ui/react-slot@^1.1.0", "@radix-ui/react-slot@^1.2.3":+"@radix-ui/[email protected]", "@radix-ui/react-slot@^1.1.0", "@radix-ui/react-slot@^1.2.0", "@radix-ui/react-slot@^1.2.3":version "1.2.3"resolved "https://registry.yarnpkg.com/@radix-ui/react-slot/-/react-slot-1.2.3.tgz#502d6e354fc847d4169c3bc5f189de777f68cfe1"integrity sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==@@ -4191,6 +4191,19 @@unplugin "1.0.1"uuid "^9.0.0"+"@signozhq/[email protected]":+ version "0.0.2"+ resolved "https://registry.yarnpkg.com/@signozhq/badge/-/badge-0.0.2.tgz#7fab5ce43ee2f48c9c4fddf082c0e91cd0c34ed1"+ integrity sha512-JibNUs/aewIxFQei0JOm+AUpROu0ykbzIQsQ4wvfYGxr1TaIWjxR2thjFCa7Vt82f6pCJAcH+UiMmZkNjMxLyA==+ dependencies:+ "@radix-ui/react-icons" "^1.3.0"+ "@radix-ui/react-slot" "^1.2.0"+ class-variance-authority "^0.7.0"+ clsx "^2.1.1"+ lucide-react "^0.445.0"+ tailwind-merge "^2.5.2"+ tailwindcss-animate "^1.0.7"+"@signozhq/[email protected]":version "0.0.1"resolved "https://registry.yarnpkg.com/@signozhq/button/-/button-0.0.1.tgz#7d3204454b0361bd3fdf91fa6604af01a481a9db"