From be8419b3842e17fceea6be52bc14b1846b71659e Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 27 Apr 2022 09:45:37 -0400 Subject: [PATCH] Notifications: Hide display of trace ID behind feature flag (#48057) (#48273) * Notifications: Hide display of trace ID behind feature flag (cherry picked from commit 3b4d237ade03e67a971ca8899e8e0371e1d83f2a) Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com> --- packages/grafana-data/src/types/featureToggles.gen.ts | 1 + pkg/services/featuremgmt/registry.go | 6 ++++++ pkg/services/featuremgmt/toggles_gen.go | 4 ++++ .../components/AppNotifications/AppNotificationItem.tsx | 5 ++++- .../components/AppNotifications/StoredNotificationItem.tsx | 4 +++- 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/grafana-data/src/types/featureToggles.gen.ts b/packages/grafana-data/src/types/featureToggles.gen.ts index a2e41442a57..992709d7fe6 100644 --- a/packages/grafana-data/src/types/featureToggles.gen.ts +++ b/packages/grafana-data/src/types/featureToggles.gen.ts @@ -53,5 +53,6 @@ export interface FeatureToggles { storageLocalUpload?: boolean; azureMonitorResourcePickerForMetrics?: boolean; explore2Dashboard?: boolean; + tracing?: boolean; persistNotifications?: boolean; } diff --git a/pkg/services/featuremgmt/registry.go b/pkg/services/featuremgmt/registry.go index 69c753113a6..e82868faeeb 100644 --- a/pkg/services/featuremgmt/registry.go +++ b/pkg/services/featuremgmt/registry.go @@ -207,6 +207,12 @@ var ( State: FeatureStateBeta, FrontendOnly: true, }, + { + Name: "tracing", + Description: "Adds trace ID to error notifications", + State: FeatureStateAlpha, + FrontendOnly: true, + }, { Name: "persistNotifications", Description: "PoC Notifications page", diff --git a/pkg/services/featuremgmt/toggles_gen.go b/pkg/services/featuremgmt/toggles_gen.go index ac2050005a1..c431e6e5231 100644 --- a/pkg/services/featuremgmt/toggles_gen.go +++ b/pkg/services/featuremgmt/toggles_gen.go @@ -155,6 +155,10 @@ const ( // Experimental Explore to Dashboard workflow FlagExplore2Dashboard = "explore2Dashboard" + // FlagTracing + // Adds trace ID to error notifications + FlagTracing = "tracing" + // FlagPersistNotifications // PoC Notifications page FlagPersistNotifications = "persistNotifications" diff --git a/public/app/core/components/AppNotifications/AppNotificationItem.tsx b/public/app/core/components/AppNotifications/AppNotificationItem.tsx index 3ec1a2b59a2..a02b1e2edb6 100644 --- a/public/app/core/components/AppNotifications/AppNotificationItem.tsx +++ b/public/app/core/components/AppNotifications/AppNotificationItem.tsx @@ -3,6 +3,7 @@ import React from 'react'; import { useEffectOnce } from 'react-use'; import { GrafanaTheme2 } from '@grafana/data'; +import { config } from '@grafana/runtime'; import { Alert, useStyles2 } from '@grafana/ui'; import { AppNotification, timeoutMap } from 'app/types'; @@ -20,6 +21,8 @@ export default function AppNotificationItem({ appNotification, onClearNotificati }, timeoutMap[appNotification.severity]); }); + const showTraceId = config.featureToggles.tracing && appNotification.traceId; + return (
{appNotification.component || appNotification.text} - {appNotification.traceId && Trace ID: {appNotification.traceId}} + {showTraceId && Trace ID: {appNotification.traceId}}
); diff --git a/public/app/core/components/AppNotifications/StoredNotificationItem.tsx b/public/app/core/components/AppNotifications/StoredNotificationItem.tsx index d6fe2992b5a..57b612db7ae 100644 --- a/public/app/core/components/AppNotifications/StoredNotificationItem.tsx +++ b/public/app/core/components/AppNotifications/StoredNotificationItem.tsx @@ -3,6 +3,7 @@ import { formatDistanceToNow } from 'date-fns'; import React, { ReactNode } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; +import { config } from '@grafana/runtime'; import { Icon, IconButton, IconName, useTheme2 } from '@grafana/ui'; import { getIconFromSeverity } from '@grafana/ui/src/components/Alert/Alert'; @@ -27,6 +28,7 @@ export const StoredNotificationItem = ({ }: Props) => { const theme = useTheme2(); const styles = getStyles(theme, severity); + const showTraceId = config.featureToggles.tracing && traceId; return (
@@ -35,7 +37,7 @@ export const StoredNotificationItem = ({
{title}
{children}
- {traceId && `Trace ID: ${traceId}`} + {showTraceId && `Trace ID: ${traceId}`}