Frontend Monitoring: Add config option to enable all default instrumentations (#94862)

* Add config options to enable all faro instrumentation

* Fix ts error

* Fix type in test

* Add to default config files
This commit is contained in:
Tobias Skarhed
2024-10-18 15:35:39 +02:00
committed by GitHub
parent a44f718c09
commit bbc4dc3867
7 changed files with 19 additions and 1 deletions

View File

@@ -1126,6 +1126,9 @@ log_endpoint_requests_per_second_limit = 3
# Max requests accepted per short interval of time for Grafana backend log ingestion endpoint (/log)
log_endpoint_burst_limit = 15
# Enables all Faro default instrumentation by using `getWebInstrumentations`. Overrides other instrumentation flags.
instrumentations_all_enabled = false
# Should error instrumentation be enabled, only affects Grafana Javascript Agent
instrumentations_errors_enabled = true

View File

@@ -1119,6 +1119,9 @@
# Max requests accepted per short interval of time for Grafana backend log ingestion endpoint (/log).
;log_endpoint_burst_limit = 15
# Enables all Faro default instrumentation by using `getWebInstrumentations`. Overrides other instrumentation flags.
;instrumentations_all_enabled = false
# Should error instrumentation be enabled, only affects Grafana Javascript Agent
;instrumentations_errors_enabled = true

View File

@@ -1499,6 +1499,10 @@ Requests per second limit enforced per an extended period, for Grafana backend l
Maximum requests accepted per short interval of time for Grafana backend log ingestion endpoint, `/log-grafana-javascript-agent`. Default is `15`.
### instrumentations_all_enabled
Enables all Faro default instrumentation by using `getWebInstrumentations`. Overrides other instrumentation flags.
### instrumentations_errors_enabled
Turn on error instrumentation. Only affects Grafana Javascript Agent.

View File

@@ -126,6 +126,7 @@ export class GrafanaBootConfig implements GrafanaConfig {
enabled: false,
customEndpoint: '',
apiKey: '',
allInstrumentationsEnabled: false,
errorInstrumentalizationEnabled: true,
consoleInstrumentalizationEnabled: false,
webVitalsInstrumentalizationEnabled: false,

View File

@@ -5,6 +5,7 @@ type GrafanaJavascriptAgent struct {
CustomEndpoint string `json:"customEndpoint"`
EndpointRPS int `json:"-"`
EndpointBurst int `json:"-"`
AllInstrumentationsEnabeld bool `json:"allInstrumentationEnabeld"`
ErrorInstrumentalizationEnabled bool `json:"errorInstrumentalizationEnabled"`
ConsoleInstrumentalizationEnabled bool `json:"consoleInstrumentalizationEnabled"`
WebVitalsInstrumentalizationEnabled bool `json:"webVitalsInstrumentalizationEnabled"`
@@ -20,6 +21,7 @@ func (cfg *Cfg) readGrafanaJavascriptAgentConfig() {
CustomEndpoint: raw.Key("custom_endpoint").MustString("/log-grafana-javascript-agent"),
EndpointRPS: raw.Key("log_endpoint_requests_per_second_limit").MustInt(3),
EndpointBurst: raw.Key("log_endpoint_burst_limit").MustInt(15),
AllInstrumentationsEnabeld: raw.Key("instrumentations_all_enabled").MustBool(true),
ErrorInstrumentalizationEnabled: raw.Key("instrumentations_errors_enabled").MustBool(true),
ConsoleInstrumentalizationEnabled: raw.Key("instrumentations_console_enabled").MustBool(true),
WebVitalsInstrumentalizationEnabled: raw.Key("instrumentations_webvitals_enabled").MustBool(true),

View File

@@ -65,6 +65,7 @@ describe('GrafanaJavascriptAgentEchoBackend', () => {
app: {
version: '1.0',
},
allInstrumentationsEnabled: true,
errorInstrumentalizationEnabled: true,
consoleInstrumentalizationEnabled: true,
webVitalsInstrumentalizationEnabled: true,

View File

@@ -9,6 +9,7 @@ import {
SessionInstrumentation,
FetchTransport,
type Instrumentation,
getWebInstrumentations,
} from '@grafana/faro-web-sdk';
import { TracingInstrumentation } from '@grafana/faro-web-tracing';
import { EchoBackend, EchoEvent, EchoEventType } from '@grafana/runtime';
@@ -20,6 +21,7 @@ export interface GrafanaJavascriptAgentBackendOptions extends BrowserConfig {
buildInfo: BuildInfo;
customEndpoint: string;
user: User;
allInstrumentationsEnabled: boolean;
errorInstrumentalizationEnabled: boolean;
consoleInstrumentalizationEnabled: boolean;
webVitalsInstrumentalizationEnabled: boolean;
@@ -67,7 +69,9 @@ export class GrafanaJavascriptAgentBackend
version: options.buildInfo.version,
environment: options.buildInfo.env,
},
instrumentations,
instrumentations: options.allInstrumentationsEnabled
? instrumentations
: [...getWebInstrumentations(), new TracingInstrumentation()],
transports,
ignoreErrors: [
'ResizeObserver loop limit exceeded',