Frontend Logging: Integrate grafana javascript agent (#50801)
Add Grafana Javascript Agent integration to Grafana
This commit is contained in:
@@ -371,6 +371,9 @@ type Cfg struct {
|
||||
// Sentry config
|
||||
Sentry Sentry
|
||||
|
||||
// GrafanaJavascriptAgent config
|
||||
GrafanaJavascriptAgent GrafanaJavascriptAgent
|
||||
|
||||
// Data sources
|
||||
DataSourceLimit int
|
||||
|
||||
@@ -1054,6 +1057,7 @@ func (cfg *Cfg) Load(args CommandLineArgs) error {
|
||||
|
||||
cfg.readDateFormats()
|
||||
cfg.readSentryConfig()
|
||||
cfg.readGrafanaJavascriptAgentConfig()
|
||||
|
||||
if err := cfg.readLiveSettings(iniFile); err != nil {
|
||||
return err
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package setting
|
||||
|
||||
type GrafanaJavascriptAgent struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
CustomEndpoint string `json:"customEndpoint"`
|
||||
EndpointRPS int `json:"-"`
|
||||
EndpointBurst int `json:"-"`
|
||||
ErrorInstrumentalizationEnabled bool `json:"errorInstrumentalizationEnabled"`
|
||||
ConsoleInstrumentalizationEnabled bool `json:"consoleInstrumentalizationEnabled"`
|
||||
WebVitalsInstrumentalizationEnabled bool `json:"webVitalsInstrumentalizationEnabled"`
|
||||
ApiKey string `json:"apiKey"`
|
||||
}
|
||||
|
||||
func (cfg *Cfg) readGrafanaJavascriptAgentConfig() {
|
||||
raw := cfg.Raw.Section("log.frontend")
|
||||
provider := raw.Key("provider").MustString("sentry")
|
||||
if provider == "grafana" {
|
||||
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),
|
||||
ErrorInstrumentalizationEnabled: raw.Key("instrumentations_errors_enabled").MustBool(true),
|
||||
ConsoleInstrumentalizationEnabled: raw.Key("instrumentations_console_enabled").MustBool(true),
|
||||
WebVitalsInstrumentalizationEnabled: raw.Key("instrumentations_webvitals_enabled").MustBool(true),
|
||||
ApiKey: raw.Key("api_key").String(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,15 @@ type Sentry struct {
|
||||
|
||||
func (cfg *Cfg) readSentryConfig() {
|
||||
raw := cfg.Raw.Section("log.frontend")
|
||||
cfg.Sentry = Sentry{
|
||||
Enabled: raw.Key("enabled").MustBool(true),
|
||||
DSN: raw.Key("sentry_dsn").String(),
|
||||
CustomEndpoint: raw.Key("custom_endpoint").String(),
|
||||
SampleRate: raw.Key("sample_rate").MustFloat64(),
|
||||
EndpointRPS: raw.Key("log_endpoint_requests_per_second_limit").MustInt(),
|
||||
EndpointBurst: raw.Key("log_endpoint_burst_limit").MustInt(),
|
||||
provider := raw.Key("provider").MustString("sentry")
|
||||
if provider == "sentry" || provider != "grafana" {
|
||||
cfg.Sentry = Sentry{
|
||||
Enabled: raw.Key("enabled").MustBool(true),
|
||||
DSN: raw.Key("sentry_dsn").String(),
|
||||
CustomEndpoint: raw.Key("custom_endpoint").MustString("/log"),
|
||||
SampleRate: raw.Key("sample_rate").MustFloat64(),
|
||||
EndpointRPS: raw.Key("log_endpoint_requests_per_second_limit").MustInt(3),
|
||||
EndpointBurst: raw.Key("log_endpoint_burst_limit").MustInt(15),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user