From 1b79a9bf35a1ebb0e99f729d81ab125435cde0e1 Mon Sep 17 00:00:00 2001 From: Pranshu Chittora Date: Thu, 24 Mar 2022 11:44:38 +0530 Subject: [PATCH] feat: unit label on graph tooltip --- frontend/src/components/Graph/index.tsx | 15 +++++++++++++++ .../MetricsApplication/Tabs/Application.tsx | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Graph/index.tsx b/frontend/src/components/Graph/index.tsx index 0659f686e1..ca97298f20 100644 --- a/frontend/src/components/Graph/index.tsx +++ b/frontend/src/components/Graph/index.tsx @@ -103,6 +103,21 @@ function Graph({ legend: { display: false, }, + tooltip: { + callbacks: { + label(context) { + let label = context.dataset.label || ''; + + if (label) { + label += ': '; + } + if (context.parsed.y !== null) { + label += getYAxisFormattedValue(context.parsed.y, yAxisUnit); + } + return label; + }, + }, + }, }, layout: { padding: 0, diff --git a/frontend/src/container/MetricsApplication/Tabs/Application.tsx b/frontend/src/container/MetricsApplication/Tabs/Application.tsx index bc072d5c97..774d8d7118 100644 --- a/frontend/src/container/MetricsApplication/Tabs/Application.tsx +++ b/frontend/src/container/MetricsApplication/Tabs/Application.tsx @@ -187,7 +187,7 @@ function Application({ getWidget }: DashboardProps): JSX.Element { widget={getWidget([ { query: `sum(rate(signoz_latency_count{service_name="${servicename}", span_kind="SPAN_KIND_SERVER"}[2m]))`, - legend: 'Request per second', + legend: 'Requests', }, ])} yAxisUnit="reqps" @@ -222,7 +222,7 @@ function Application({ getWidget }: DashboardProps): JSX.Element { widget={getWidget([ { query: `max(sum(rate(signoz_calls_total{service_name="${servicename}", span_kind="SPAN_KIND_SERVER", status_code="STATUS_CODE_ERROR"}[1m]) OR rate(signoz_calls_total{service_name="${servicename}", span_kind="SPAN_KIND_SERVER", http_status_code=~"5.."}[1m]))*100/sum(rate(signoz_calls_total{service_name="${servicename}", span_kind="SPAN_KIND_SERVER"}[1m]))) < 1000 OR vector(0)`, - legend: 'Error Percentage (%)', + legend: 'Error Percentage', }, ])} yAxisUnit="%"