Faro: Update configuration with best practices (#112108)

* Clean up faro configuration to align with best practices

* Update grafana docs

* remove fixme comment

* fix tests

* don't spread config in
This commit is contained in:
Josh Hunt
2025-10-13 13:46:29 +01:00
committed by GitHub
parent 32f1912311
commit ea25b75966
9 changed files with 223 additions and 201 deletions
+26 -22
View File
@@ -1,32 +1,36 @@
package setting
type GrafanaJavascriptAgent struct {
Enabled bool `json:"enabled"`
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"`
TracingInstrumentalizationEnabled bool `json:"tracingInstrumentalizationEnabled"`
InternalLoggerLevel int `json:"internalLoggerLevel"`
ApiKey string `json:"apiKey"`
EndpointRPS int `json:"-"`
EndpointBurst int `json:"-"`
// Faro config
Enabled bool `json:"enabled"`
CustomEndpoint string `json:"customEndpoint"`
ApiKey string `json:"apiKey"`
InternalLoggerLevel int `json:"internalLoggerLevel"`
ConsoleInstrumentalizationEnabled bool `json:"consoleInstrumentalizationEnabled"`
PerformanceInstrumentalizationEnabled bool `json:"performanceInstrumentalizationEnabled"`
CSPInstrumentalizationEnabled bool `json:"cspInstrumentalizationEnabled"`
TracingInstrumentalizationEnabled bool `json:"tracingInstrumentalizationEnabled"`
WebVitalsAttributionEnabled bool `json:"webVitalsAttributionEnabled"`
}
func (cfg *Cfg) readGrafanaJavascriptAgentConfig() {
raw := cfg.Raw.Section("log.frontend")
cfg.GrafanaJavascriptAgent = GrafanaJavascriptAgent{
Enabled: raw.Key("enabled").MustBool(true),
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(false),
ErrorInstrumentalizationEnabled: raw.Key("instrumentations_errors_enabled").MustBool(true),
ConsoleInstrumentalizationEnabled: raw.Key("instrumentations_console_enabled").MustBool(true),
WebVitalsInstrumentalizationEnabled: raw.Key("instrumentations_webvitals_enabled").MustBool(true),
TracingInstrumentalizationEnabled: raw.Key("instrumentations_tracing_enabled").MustBool(true),
InternalLoggerLevel: raw.Key("internal_logger_level").MustInt(0),
ApiKey: raw.Key("api_key").String(),
EndpointRPS: raw.Key("log_endpoint_requests_per_second_limit").MustInt(3),
EndpointBurst: raw.Key("log_endpoint_burst_limit").MustInt(15),
// Faro config
Enabled: raw.Key("enabled").MustBool(false),
CustomEndpoint: raw.Key("custom_endpoint").MustString("/log-grafana-javascript-agent"),
ApiKey: raw.Key("api_key").String(),
InternalLoggerLevel: raw.Key("internal_logger_level").MustInt(0),
ConsoleInstrumentalizationEnabled: raw.Key("instrumentations_console_enabled").MustBool(true),
PerformanceInstrumentalizationEnabled: raw.Key("instrumentations_performance_enabled").MustBool(true),
CSPInstrumentalizationEnabled: raw.Key("instrumentations_csp_enabled").MustBool(true),
TracingInstrumentalizationEnabled: raw.Key("instrumentations_tracing_enabled").MustBool(true),
WebVitalsAttributionEnabled: raw.Key("web_vitals_attribution_enabled").MustBool(true),
}
}