Skip to content

Commit 15d4169

Browse files
authored
Frontend logging: Remove Sentry javascript agent support (grafana#67493)
* remove Sentry * fix sourcemap resolve
1 parent 9614dc2 commit 15d4169

38 files changed

+47
-1288
lines changed

.github/renovate.json5

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
"systemjs",
1717
"ts-loader", // we should remove ts-loader and use babel-loader instead
1818
"ora", // we should bump this once we move to esm modules
19-
20-
// Sentry deprecated in favor of Grafana Faro for frontend logging.
21-
// Major effort required to upgrade to latest Sentry, not worthwhile
22-
"@sentry/browser",
23-
"@sentry/types",
24-
"@sentry/utils",
2519
],
2620
"includePaths": ["package.json", "packages/**"],
2721
"ignorePaths": ["packages/grafana-toolkit/package.json", "emails/**", "plugins-bundled/**", "**/mocks/**"],

conf/defaults.ini

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -872,21 +872,12 @@ facility =
872872
tag =
873873

874874
[log.frontend]
875-
# Should Sentry javascript agent be initialized
875+
# Should Faro javascript agent be initialized
876876
enabled = false
877877

878-
# Defines which provider to use sentry or grafana
879-
provider = sentry
880-
881-
# Sentry DSN if you want to send events to Sentry.
882-
sentry_dsn =
883-
884878
# Custom HTTP endpoint to send events to. Default will log the events to stdout.
885879
custom_endpoint =
886880

887-
# Rate of events to be reported to Sentry between 0 (none) and 1 (all), float
888-
sample_rate = 1.0
889-
890881
# Requests per second limit enforced per an extended period, for Grafana backend log ingestion endpoint (/log).
891882
log_endpoint_requests_per_second_limit = 3
892883

conf/sample.ini

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -844,20 +844,11 @@
844844
;tag =
845845

846846
[log.frontend]
847-
# Should Sentry javascript agent be initialized
847+
# Should Faro javascript agent be initialized
848848
;enabled = false
849849

850-
# Defines which provider to use, default is Sentry
851-
;provider = sentry
852-
853-
# Sentry DSN if you want to send events to Sentry.
854-
;sentry_dsn =
855-
856-
# Custom HTTP endpoint to send events captured by the Sentry agent to. Default will log the events to stdout.
857-
;custom_endpoint = /log
858-
859-
# Rate of events to be reported between 0 (none) and 1 (all), float
860-
;sample_rate = 1.0
850+
# Custom HTTP endpoint to send events to. Default will log the events to stdout.
851+
;custom_endpoint = /log-grafana-javascript-agent
861852

862853
# Requests per second limit enforced an extended period, for Grafana backend log ingestion endpoint (/log).
863854
;log_endpoint_requests_per_second_limit = 3

docs/sources/setup-grafana/configure-grafana/_index.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,31 +1284,19 @@ Syslog tag. By default, the process's `argv[0]` is used.
12841284

12851285
### enabled
12861286

1287-
Sentry javascript agent is initialized. Default is `false`.
1288-
1289-
### provider
1290-
1291-
Defines which provider to use `sentry` or `grafana`. Default is `sentry`
1292-
1293-
### sentry_dsn
1294-
1295-
Sentry DSN if you want to send events to Sentry
1287+
Faro javascript agent is initialized. Default is `false`.
12961288

12971289
### custom_endpoint
12981290

1299-
Custom HTTP endpoint to send events captured by the Sentry agent to. Default, `/log`, will log the events to stdout.
1300-
1301-
### sample_rate
1302-
1303-
Rate of events to be reported between `0` (none) and `1` (all, default), float.
1291+
Custom HTTP endpoint to send events captured by the Faro agent to. Default, `/log-grafana-javascript-agent`, will log the events to stdout.
13041292

13051293
### log_endpoint_requests_per_second_limit
13061294

1307-
Requests per second limit enforced per an extended period, for Grafana backend log ingestion endpoint, `/log`. Default is `3`.
1295+
Requests per second limit enforced per an extended period, for Grafana backend log ingestion endpoint, `/log-grafana-javascript-agent`. Default is `3`.
13081296

13091297
### log_endpoint_burst_limit
13101298

1311-
Maximum requests accepted per short interval of time for Grafana backend log ingestion endpoint, `/log`. Default is `15`.
1299+
Maximum requests accepted per short interval of time for Grafana backend log ingestion endpoint, `/log-grafana-javascript-agent`. Default is `15`.
13121300

13131301
### instrumentations_errors_enabled
13141302

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ require (
4040
github.com/crewjam/saml v0.4.12
4141
github.com/fatih/color v1.15.0
4242
github.com/gchaincl/sqlhooks v1.3.0
43-
github.com/getsentry/sentry-go v0.13.0
4443
github.com/go-git/go-git/v5 v5.4.2
4544
github.com/go-ldap/ldap/v3 v3.4.4
4645
github.com/go-openapi/strfmt v0.21.7

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -801,8 +801,6 @@ github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebK
801801
github.com/getkin/kin-openapi v0.76.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg=
802802
github.com/getkin/kin-openapi v0.115.0 h1:c8WHRLVY3G8m9jQTy0/DnIuljgRwTCB5twZytQS4JyU=
803803
github.com/getkin/kin-openapi v0.115.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BHOEV2VaAVf/pc=
804-
github.com/getsentry/sentry-go v0.13.0 h1:20dgTiUSfxRB/EhMPtxcL9ZEbM1ZdR+W/7f7NWD+xWo=
805-
github.com/getsentry/sentry-go v0.13.0/go.mod h1:EOsfu5ZdvKPfeHYV6pTVQnsjfp30+XA7//UooKNumH0=
806804
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
807805
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
808806
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 h1:Mn26/9ZMNWSw9C9ERFA1PUxfmGpolnw2v0bKOREu5ew=
@@ -822,7 +820,6 @@ github.com/go-asn1-ber/asn1-ber v1.5.4 h1:vXT6d/FNDiELJnLb6hGNa309LMsrCoYFvpwHDF
822820
github.com/go-asn1-ber/asn1-ber v1.5.4/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0=
823821
github.com/go-chi/chi v4.1.0+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
824822
github.com/go-chi/chi/v5 v5.0.8/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
825-
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
826823
github.com/go-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g=
827824
github.com/go-fonts/latin-modern v0.2.0/go.mod h1:rQVLdDMK+mK1xscDwsqM5J8U2jrRa3T0ecnM9pNujks=
828825
github.com/go-fonts/liberation v0.1.1/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2HYqyqAO9z7GY=
@@ -1962,7 +1959,6 @@ github.com/pierrec/lz4 v2.6.0+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi
19621959
github.com/pierrec/lz4/v4 v4.1.8/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
19631960
github.com/pierrec/lz4/v4 v4.1.15 h1:MO0/ucJhngq7299dKLwIMtgTfbkoSPF6AoMYDd8Q4q0=
19641961
github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
1965-
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
19661962
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
19671963
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
19681964
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,6 @@
287287
"@react-stately/tree": "3.3.1",
288288
"@reduxjs/toolkit": "1.9.3",
289289
"@remix-run/router": "^1.5.0",
290-
"@sentry/browser": "6.19.7",
291-
"@sentry/types": "6.19.7",
292-
"@sentry/utils": "6.19.7",
293290
"@testing-library/react-hooks": "^8.0.1",
294291
"@types/react-resizable": "3.0.3",
295292
"@types/trusted-types": "2.0.3",

packages/grafana-data/src/types/config.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,6 @@ export interface LicenseInfo {
4646
trialExpiry?: number;
4747
}
4848

49-
/**
50-
* Describes Sentry integration config
51-
*
52-
* @public
53-
*/
54-
export interface SentryConfig {
55-
enabled: boolean;
56-
dsn: string;
57-
customEndpoint: string;
58-
sampleRate: number;
59-
}
60-
6149
/**
6250
* Describes GrafanaJavascriptAgentConfig integration config
6351
*
@@ -209,7 +197,6 @@ export interface GrafanaConfig {
209197
licenseInfo: LicenseInfo;
210198
http2Enabled: boolean;
211199
dateFormats?: SystemDateFormatSettings;
212-
sentry: SentryConfig;
213200
grafanaJavascriptAgent: GrafanaJavascriptAgentConfig;
214201
customTheme?: any;
215202
geomapDefaultBaseLayer?: MapLayerOptions;

packages/grafana-runtime/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"@grafana/e2e-selectors": "10.1.0-pre",
4242
"@grafana/faro-web-sdk": "1.0.2",
4343
"@grafana/ui": "10.1.0-pre",
44-
"@sentry/browser": "6.19.7",
4544
"history": "4.10.1",
4645
"lodash": "4.17.21",
4746
"rxjs": "7.8.0",

packages/grafana-runtime/src/config.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,6 @@ export class GrafanaBootConfig implements GrafanaConfig {
103103
supportBundlesEnabled = false;
104104
http2Enabled = false;
105105
dateFormats?: SystemDateFormatSettings;
106-
sentry = {
107-
enabled: false,
108-
dsn: '',
109-
customEndpoint: '',
110-
sampleRate: 1,
111-
};
112106
grafanaJavascriptAgent = {
113107
enabled: false,
114108
customEndpoint: '',

packages/grafana-runtime/src/services/EchoSrv.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ export interface EchoEvent<T extends EchoEventType = any, P = any> {
7878
export enum EchoEventType {
7979
Performance = 'performance',
8080
MetaAnalytics = 'meta-analytics',
81-
Sentry = 'sentry',
8281
Pageview = 'pageview',
8382
Interaction = 'interaction',
8483
ExperimentView = 'experimentview',
Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,59 @@
1-
import { captureMessage, captureException, Severity as LogLevel } from '@sentry/browser';
2-
3-
import { faro, LogLevel as GrafanaLogLevel } from '@grafana/faro-web-sdk';
1+
import { faro, LogLevel } from '@grafana/faro-web-sdk';
42

53
import { config } from '../config';
64

75
export { LogLevel };
86

9-
// a bit stricter than what Sentry allows
107
type Contexts = Record<string, Record<string, number | string | Record<string, string | number>>>;
118

129
/**
13-
* Log a message at INFO level. Depending on configuration might be forwarded to backend and logged to stdout or sent to Sentry
14-
*
10+
* Log a message at INFO level
1511
* @public
1612
*/
1713
export function logInfo(message: string, contexts?: Contexts) {
1814
if (config.grafanaJavascriptAgent.enabled) {
1915
faro.api.pushLog([message], {
20-
level: GrafanaLogLevel.INFO,
16+
level: LogLevel.INFO,
2117
context: contexts,
2218
});
2319
}
24-
if (config.sentry.enabled) {
25-
captureMessage(message, {
26-
level: LogLevel.Info,
27-
contexts,
28-
});
29-
}
3020
}
3121

3222
/**
33-
* Log a message at WARNING level. Depending on configuration might be forwarded to backend and logged to stdout or sent to Sentry
23+
* Log a message at WARNING level
3424
*
3525
* @public
3626
*/
3727
export function logWarning(message: string, contexts?: Contexts) {
3828
if (config.grafanaJavascriptAgent.enabled) {
3929
faro.api.pushLog([message], {
40-
level: GrafanaLogLevel.WARN,
30+
level: LogLevel.WARN,
4131
context: contexts,
4232
});
4333
}
44-
if (config.sentry.enabled) {
45-
captureMessage(message, {
46-
level: LogLevel.Warning,
47-
contexts,
48-
});
49-
}
5034
}
5135

5236
/**
53-
* Log a message at DEBUG level. Depending on configuration might be forwarded to backend and logged to stdout or sent to Sentry
37+
* Log a message at DEBUG level
5438
*
5539
* @public
5640
*/
5741
export function logDebug(message: string, contexts?: Contexts) {
5842
if (config.grafanaJavascriptAgent.enabled) {
5943
faro.api.pushLog([message], {
60-
level: GrafanaLogLevel.DEBUG,
44+
level: LogLevel.DEBUG,
6145
context: contexts,
6246
});
6347
}
64-
if (config.sentry.enabled) {
65-
captureMessage(message, {
66-
level: LogLevel.Debug,
67-
contexts,
68-
});
69-
}
7048
}
7149

7250
/**
73-
* Log an error. Depending on configuration might be forwarded to backend and logged to stdout or sent to Sentry
51+
* Log an error
7452
*
7553
* @public
7654
*/
7755
export function logError(err: Error, contexts?: Contexts) {
7856
if (config.grafanaJavascriptAgent.enabled) {
7957
faro.api.pushError(err);
8058
}
81-
if (config.sentry.enabled) {
82-
captureException(err, { contexts });
83-
}
8459
}

packages/grafana-ui/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
"@react-aria/overlays": "3.10.1",
6464
"@react-aria/utils": "3.13.1",
6565
"@react-stately/menu": "3.4.1",
66-
"@sentry/browser": "6.19.7",
6766
"ansicolor": "1.1.100",
6867
"calculate-size": "1.1.1",
6968
"classnames": "2.3.2",

packages/grafana-ui/src/components/ErrorBoundary/ErrorBoundary.test.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import { captureException } from '@sentry/browser';
21
import { render, screen } from '@testing-library/react';
32
import React, { FC } from 'react';
43

54
import { faro } from '@grafana/faro-web-sdk';
65

76
import { ErrorBoundary } from './ErrorBoundary';
87

9-
jest.mock('@sentry/browser');
108
jest.mock('@grafana/faro-web-sdk', () => ({
119
faro: {
1210
api: {
@@ -31,7 +29,7 @@ describe('ErrorBoundary', () => {
3129
consoleSpy.mockRestore();
3230
});
3331

34-
it('should catch error and report it to sentry, including react component stack in context', async () => {
32+
it('should catch error and report it to Faro', async () => {
3533
const problem = new Error('things went terribly wrong');
3634
render(
3735
<ErrorBoundary>
@@ -46,13 +44,6 @@ describe('ErrorBoundary', () => {
4644
);
4745

4846
await screen.findByText(problem.message);
49-
expect(captureException).toHaveBeenCalledTimes(1);
50-
const [error, context] = (captureException as jest.Mock).mock.calls[0];
51-
expect(error).toBe(problem);
52-
expect(context).toHaveProperty('contexts');
53-
expect(context.contexts).toHaveProperty('react');
54-
expect(context.contexts.react).toHaveProperty('componentStack');
55-
expect(context.contexts.react.componentStack).toMatch(/^\s+at ErrorThrower (.*)\s+at ErrorBoundary (.*)\s*$/);
5647
expect(faro.api.pushError).toHaveBeenCalledTimes(1);
5748
expect((faro.api.pushError as jest.Mock).mock.calls[0][0]).toBe(problem);
5849
});

packages/grafana-ui/src/components/ErrorBoundary/ErrorBoundary.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { captureException } from '@sentry/browser';
21
import React, { PureComponent, ReactNode, ComponentType } from 'react';
32

43
import { faro } from '@grafana/faro-web-sdk';
@@ -38,7 +37,6 @@ export class ErrorBoundary extends PureComponent<Props, State> {
3837
};
3938

4039
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
41-
captureException(error, { contexts: { react: { componentStack: errorInfo.componentStack } } });
4240
faro?.api?.pushError(error);
4341
this.setState({ error, errorInfo });
4442

pkg/api/dtos/frontend_settings.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ type FrontendSettingsDTO struct {
185185
RendererVersion string `json:"rendererVersion"`
186186
SecretsManagerPluginEnabled bool `json:"secretsManagerPluginEnabled"`
187187
Http2Enabled bool `json:"http2Enabled"`
188-
Sentry setting.Sentry `json:"sentry"`
189188
GrafanaJavascriptAgent setting.GrafanaJavascriptAgent `json:"grafanaJavascriptAgent"`
190189
PluginCatalogURL string `json:"pluginCatalogURL"`
191190
PluginAdminEnabled bool `json:"pluginAdminEnabled"`

pkg/api/dtos/index.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"html/template"
55

66
"github.com/grafana/grafana/pkg/services/navtree"
7-
"github.com/grafana/grafana/pkg/setting"
87
)
98

109
type IndexViewData struct {
@@ -27,7 +26,6 @@ type IndexViewData struct {
2726
FavIcon template.URL
2827
AppleTouchIcon template.URL
2928
AppTitle string
30-
Sentry *setting.Sentry
3129
ContentDeliveryURL string
3230
LoadingLogo template.URL
3331
CSPContent string

0 commit comments

Comments
 (0)