Renamed "harcoded" to "static" and "remote" to "dynamic"

from PR review, matches the same naming schema used for signing keys fetching
pull/69843/head
Giuseppe Guerra 3 years ago
parent f8c5318021
commit 9e499fbb15
No known key found for this signature in database
  1. 88
      docs/sources/setup-grafana/configure-grafana/feature-toggles/index.md
  2. 2
      packages/grafana-data/src/types/featureToggles.gen.ts
  3. 16
      pkg/plugins/manager/loader/angular/angulardetector/gcom.go
  4. 24
      pkg/plugins/manager/loader/angular/angularinspector/angularinspector.go
  5. 4
      pkg/plugins/manager/loader/angular/angularinspector/angularinspector_test.go
  6. 2
      pkg/services/featuremgmt/registry.go
  7. 2
      pkg/services/featuremgmt/toggles_gen.csv
  8. 4
      pkg/services/featuremgmt/toggles_gen.go

@ -71,50 +71,50 @@ Some features are enabled by default. You can disable these feature by setting t
These features are early in their development lifecycle and so are not yet supported in Grafana Cloud.
Experimental features might be changed or removed without prior notice.
| Feature toggle name | Description |
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `live-service-web-worker` | This will use a webworker thread to processes events rather than the main thread |
| `queryOverLive` | Use Grafana Live WebSocket to execute backend queries |
| `lokiLive` | Support WebSocket streaming for loki (early prototype) |
| `storage` | Configurable storage for dashboards, datasources, and resources |
| `newTraceViewHeader` | Shows the new trace view header |
| `datasourceQueryMultiStatus` | Introduce HTTP 207 Multi Status for api/ds/query |
| `traceToMetrics` | Enable trace to metrics links |
| `prometheusWideSeries` | Enable wide series responses in the Prometheus datasource |
| `canvasPanelNesting` | Allow elements nesting |
| `scenes` | Experimental framework to build interactive dashboards |
| `disableSecretsCompatibility` | Disable duplicated secret storage in legacy tables |
| `logRequestsInstrumentedAsUnknown` | Logs the path for requests that are instrumented as unknown |
| `redshiftAsyncQueryDataSupport` | Enable async query data support for Redshift |
| `athenaAsyncQueryDataSupport` | Enable async query data support for Athena |
| `showDashboardValidationWarnings` | Show warnings when dashboards do not validate against the schema |
| `mysqlAnsiQuotes` | Use double quotes to escape keyword in a MySQL query |
| `showTraceId` | Show trace ids for requests |
| `alertingBacktesting` | Rule backtesting API for alerting |
| `editPanelCSVDragAndDrop` | Enables drag and drop for CSV and Excel files |
| `lokiQuerySplitting` | Split large interval queries into subqueries with smaller time intervals |
| `lokiQuerySplittingConfig` | Give users the option to configure split durations for Loki queries |
| `individualCookiePreferences` | Support overriding cookie preferences per user |
| `onlyExternalOrgRoleSync` | Prohibits a user from changing organization roles synced with external auth providers |
| `traceqlSearch` | Enables the 'TraceQL Search' tab for the Tempo datasource which provides a UI to generate TraceQL queries |
| `prometheusMetricEncyclopedia` | Replaces the Prometheus query builder metric select option with a paginated and filterable component |
| `timeSeriesTable` | Enable time series table transformer & sparkline cell type |
| `prometheusResourceBrowserCache` | Displays browser caching options in Prometheus data source configuration |
| `influxdbBackendMigration` | Query InfluxDB InfluxQL without the proxy |
| `clientTokenRotation` | Replaces the current in-request token rotation so that the client initiates the rotation |
| `disableSSEDataplane` | Disables dataplane specific processing in server side expressions. |
| `alertStateHistoryLokiSecondary` | Enable Grafana to write alert state history to an external Loki instance in addition to Grafana annotations. |
| `alertStateHistoryLokiPrimary` | Enable a remote Loki instance as the primary source for state history reads. |
| `alertStateHistoryLokiOnly` | Disable Grafana alerts from emitting annotations when a remote Loki instance is available. |
| `unifiedRequestLog` | Writes error logs to the request logger |
| `pyroscopeFlameGraph` | Changes flame graph to pyroscope one |
| `extraThemes` | Enables extra themes |
| `lokiPredefinedOperations` | Adds predefined query operations to Loki query editor |
| `pluginsFrontendSandbox` | Enables the plugins frontend sandbox |
| `cloudWatchLogsMonacoEditor` | Enables the Monaco editor for CloudWatch Logs queries |
| `exploreScrollableLogsContainer` | Improves the scrolling behavior of logs in Explore |
| `recordedQueriesMulti` | Enables writing multiple items from a single query within Recorded Queries |
| `pluginsRemoteAngularDetectionPatterns` | Enables fetching Angular detection patterns for plugins from GCOM and fallback to hardcoded ones |
| Feature toggle name | Description |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `live-service-web-worker` | This will use a webworker thread to processes events rather than the main thread |
| `queryOverLive` | Use Grafana Live WebSocket to execute backend queries |
| `lokiLive` | Support WebSocket streaming for loki (early prototype) |
| `storage` | Configurable storage for dashboards, datasources, and resources |
| `newTraceViewHeader` | Shows the new trace view header |
| `datasourceQueryMultiStatus` | Introduce HTTP 207 Multi Status for api/ds/query |
| `traceToMetrics` | Enable trace to metrics links |
| `prometheusWideSeries` | Enable wide series responses in the Prometheus datasource |
| `canvasPanelNesting` | Allow elements nesting |
| `scenes` | Experimental framework to build interactive dashboards |
| `disableSecretsCompatibility` | Disable duplicated secret storage in legacy tables |
| `logRequestsInstrumentedAsUnknown` | Logs the path for requests that are instrumented as unknown |
| `redshiftAsyncQueryDataSupport` | Enable async query data support for Redshift |
| `athenaAsyncQueryDataSupport` | Enable async query data support for Athena |
| `showDashboardValidationWarnings` | Show warnings when dashboards do not validate against the schema |
| `mysqlAnsiQuotes` | Use double quotes to escape keyword in a MySQL query |
| `showTraceId` | Show trace ids for requests |
| `alertingBacktesting` | Rule backtesting API for alerting |
| `editPanelCSVDragAndDrop` | Enables drag and drop for CSV and Excel files |
| `lokiQuerySplitting` | Split large interval queries into subqueries with smaller time intervals |
| `lokiQuerySplittingConfig` | Give users the option to configure split durations for Loki queries |
| `individualCookiePreferences` | Support overriding cookie preferences per user |
| `onlyExternalOrgRoleSync` | Prohibits a user from changing organization roles synced with external auth providers |
| `traceqlSearch` | Enables the 'TraceQL Search' tab for the Tempo datasource which provides a UI to generate TraceQL queries |
| `prometheusMetricEncyclopedia` | Replaces the Prometheus query builder metric select option with a paginated and filterable component |
| `timeSeriesTable` | Enable time series table transformer & sparkline cell type |
| `prometheusResourceBrowserCache` | Displays browser caching options in Prometheus data source configuration |
| `influxdbBackendMigration` | Query InfluxDB InfluxQL without the proxy |
| `clientTokenRotation` | Replaces the current in-request token rotation so that the client initiates the rotation |
| `disableSSEDataplane` | Disables dataplane specific processing in server side expressions. |
| `alertStateHistoryLokiSecondary` | Enable Grafana to write alert state history to an external Loki instance in addition to Grafana annotations. |
| `alertStateHistoryLokiPrimary` | Enable a remote Loki instance as the primary source for state history reads. |
| `alertStateHistoryLokiOnly` | Disable Grafana alerts from emitting annotations when a remote Loki instance is available. |
| `unifiedRequestLog` | Writes error logs to the request logger |
| `pyroscopeFlameGraph` | Changes flame graph to pyroscope one |
| `extraThemes` | Enables extra themes |
| `lokiPredefinedOperations` | Adds predefined query operations to Loki query editor |
| `pluginsFrontendSandbox` | Enables the plugins frontend sandbox |
| `cloudWatchLogsMonacoEditor` | Enables the Monaco editor for CloudWatch Logs queries |
| `exploreScrollableLogsContainer` | Improves the scrolling behavior of logs in Explore |
| `recordedQueriesMulti` | Enables writing multiple items from a single query within Recorded Queries |
| `pluginsDynamicAngularDetectionPatterns` | Enables fetching Angular detection patterns for plugins from GCOM and fallback to hardcoded ones |
## Development feature toggles

@ -101,5 +101,5 @@ export interface FeatureToggles {
cloudWatchLogsMonacoEditor?: boolean;
exploreScrollableLogsContainer?: boolean;
recordedQueriesMulti?: boolean;
pluginsRemoteAngularDetectionPatterns?: boolean;
pluginsDynamicAngularDetectionPatterns?: boolean;
}

@ -59,7 +59,7 @@ func NewGCOMDetectorsProvider(baseURL string, ttl time.Duration) (DetectorsProvi
}, nil
}
// tryUpdateRemoteDetectors tries to update the cached detectors value, if the cache has expired.
// tryUpdateDynamicDetectors tries to update the cached detectors value, if the cache has expired.
//
// If the TTL hasn't passed yet, this function returns immediately.
// Otherwise, it calls fetch and updates the cached detectors value and lastUpdate.
@ -68,7 +68,7 @@ func NewGCOMDetectorsProvider(baseURL string, ttl time.Duration) (DetectorsProvi
// However, if there's an error, the cached value is not changed (the previous one is kept).
//
// The caller must have acquired g.mux.
func (p *GCOMDetectorsProvider) tryUpdateRemoteDetectors(ctx context.Context) error {
func (p *GCOMDetectorsProvider) tryUpdateDynamicDetectors(ctx context.Context) error {
if time.Since(p.lastUpdate) <= p.ttl {
// Patterns already fetched
return nil
@ -90,23 +90,23 @@ func (p *GCOMDetectorsProvider) tryUpdateRemoteDetectors(ctx context.Context) er
if err != nil {
return fmt.Errorf("detectors: %w", err)
}
p.log.Debug("Updated remote angular detectors", "detectors", len(detectors))
p.log.Debug("Updated dynamic angular detectors", "detectors", len(detectors))
// Update cached result
p.detectors = detectors
return nil
}
// ProvideDetectors gets the remote detections, either from the cache or from the remote source (if TTL has passed).
// ProvideDetectors gets the dynamic detectors, either from the cache or from the remote source (if TTL has passed).
// If an error occurs during the cache refresh, the function fails silently and the old cached value is returned
// instead.
func (p *GCOMDetectorsProvider) ProvideDetectors(ctx context.Context) []Detector {
p.mux.Lock()
defer p.mux.Unlock()
if err := p.tryUpdateRemoteDetectors(ctx); err != nil {
if err := p.tryUpdateDynamicDetectors(ctx); err != nil {
// Fail silently
p.log.Warn("Could not update remote detectors", "error", err)
p.log.Warn("Could not update dynamic detectors", "error", err)
}
return p.detectors
}
@ -121,7 +121,7 @@ func (p *GCOMDetectorsProvider) fetch(ctx context.Context) (gcomPatterns, error)
return nil, fmt.Errorf("url joinpath: %w", err)
}
p.log.Debug("Fetching remote angular detection patterns", "url", reqURL)
p.log.Debug("Fetching dynamic angular detection patterns", "url", reqURL)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, reqURL, nil)
if err != nil {
return nil, fmt.Errorf("new request with context: %w", err)
@ -139,7 +139,7 @@ func (p *GCOMDetectorsProvider) fetch(ctx context.Context) (gcomPatterns, error)
if err := json.NewDecoder(resp.Body).Decode(&out); err != nil {
return nil, fmt.Errorf("json decode: %w", err)
}
p.log.Debug("Fetched remote angular detection patterns", "patterns", len(out), "duration", time.Since(st))
p.log.Debug("Fetched dynamic angular detection patterns", "patterns", len(out), "duration", time.Since(st))
return out, nil
}

@ -69,17 +69,17 @@ var defaultDetectors = []angulardetector.Detector{
&angulardetector.RegexDetector{Regex: regexp.MustCompile(`System\.register\(`)},
}
// newDefaultStaticDetectorsProvider returns a new StaticDetectorsProvider with the default (hardcoded) angular
// newDefaultStaticDetectorsProvider returns a new StaticDetectorsProvider with the default (static, hardcoded) angular
// detection patterns (defaultDetectors)
func newDefaultStaticDetectorsProvider() angulardetector.DetectorsProvider {
return &angulardetector.StaticDetectorsProvider{Detectors: defaultDetectors}
}
// newRemoteInspector returns the default remote Inspector, which is a PatternsListInspector that will:
// newDynamicInspector returns the default dynamic Inspector, which is a PatternsListInspector that will:
// 1. Try to get the Angular detectors from GCOM
// 2. If it fails, it will use the hardcoded detections provided by defaultDetectors.
func newRemoteInspector(cfg *config.Cfg) (Inspector, error) {
remoteProvider, err := angulardetector.NewGCOMDetectorsProvider(
// 2. If it fails, it will use the static (hardcoded) detections provided by defaultDetectors.
func newDynamicInspector(cfg *config.Cfg) (Inspector, error) {
dynamicProvider, err := angulardetector.NewGCOMDetectorsProvider(
cfg.GrafanaComURL,
angulardetector.DefaultGCOMDetectorsProviderTTL,
)
@ -88,21 +88,21 @@ func newRemoteInspector(cfg *config.Cfg) (Inspector, error) {
}
return &PatternsListInspector{
DetectorsProvider: angulardetector.SequenceDetectorsProvider{
remoteProvider,
dynamicProvider,
newDefaultStaticDetectorsProvider(),
},
}, nil
}
// newHardcodedInspector returns the default Inspector, which is a PatternsListInspector that only uses the
// hardcoded (static) angular detection patterns.
func newHardcodedInspector() (Inspector, error) {
// newStaticInspector returns the default Inspector, which is a PatternsListInspector that only uses the
// static (hardcoded) angular detection patterns.
func newStaticInspector() (Inspector, error) {
return &PatternsListInspector{DetectorsProvider: newDefaultStaticDetectorsProvider()}, nil
}
func ProvideService(cfg *config.Cfg) (Inspector, error) {
if cfg.Features != nil && cfg.Features.IsEnabled(featuremgmt.FlagPluginsRemoteAngularDetectionPatterns) {
return newRemoteInspector(cfg)
if cfg.Features != nil && cfg.Features.IsEnabled(featuremgmt.FlagPluginsDynamicAngularDetectionPatterns) {
return newDynamicInspector(cfg)
}
return newHardcodedInspector()
return newStaticInspector()
}

@ -151,9 +151,9 @@ func TestProvideInspector(t *testing.T) {
require.Equal(t, defaultDetectors, detectors, "provided detectors should be the hardcoded ones")
})
t.Run("uses remote inspector with hardcoded fallback if feature flag is present", func(t *testing.T) {
t.Run("uses dynamic inspector with hardcoded fallback if feature flag is present", func(t *testing.T) {
inspector, err := ProvideService(&config.Cfg{
Features: featuremgmt.WithFeatures(featuremgmt.FlagPluginsRemoteAngularDetectionPatterns),
Features: featuremgmt.WithFeatures(featuremgmt.FlagPluginsDynamicAngularDetectionPatterns),
})
require.NoError(t, err)
require.IsType(t, inspector, &PatternsListInspector{})

@ -565,7 +565,7 @@ var (
Owner: grafanaObservabilityMetricsSquad,
},
{
Name: "pluginsRemoteAngularDetectionPatterns",
Name: "pluginsDynamicAngularDetectionPatterns",
Description: "Enables fetching Angular detection patterns for plugins from GCOM and fallback to hardcoded ones",
Stage: FeatureStageExperimental,
FrontendOnly: false,

@ -82,4 +82,4 @@ sqlDatasourceDatabaseSelection,preview,@grafana/grafana-bi-squad,false,false,fal
cloudWatchLogsMonacoEditor,experimental,@grafana/aws-plugins,false,false,false,true
exploreScrollableLogsContainer,experimental,@grafana/observability-logs,false,false,false,true
recordedQueriesMulti,experimental,@grafana/observability-metrics,false,false,false,false
pluginsRemoteAngularDetectionPatterns,experimental,@grafana/plugins-platform-backend,false,false,false,false
pluginsDynamicAngularDetectionPatterns,experimental,@grafana/plugins-platform-backend,false,false,false,false

1 Name Stage Owner requiresDevMode RequiresLicense RequiresRestart FrontendOnly
82 cloudWatchLogsMonacoEditor experimental @grafana/aws-plugins false false false true
83 exploreScrollableLogsContainer experimental @grafana/observability-logs false false false true
84 recordedQueriesMulti experimental @grafana/observability-metrics false false false false
85 pluginsRemoteAngularDetectionPatterns pluginsDynamicAngularDetectionPatterns experimental @grafana/plugins-platform-backend false false false false

@ -339,7 +339,7 @@ const (
// Enables writing multiple items from a single query within Recorded Queries
FlagRecordedQueriesMulti = "recordedQueriesMulti"
// FlagPluginsRemoteAngularDetectionPatterns
// FlagPluginsDynamicAngularDetectionPatterns
// Enables fetching Angular detection patterns for plugins from GCOM and fallback to hardcoded ones
FlagPluginsRemoteAngularDetectionPatterns = "pluginsRemoteAngularDetectionPatterns"
FlagPluginsDynamicAngularDetectionPatterns = "pluginsDynamicAngularDetectionPatterns"
)

Loading…
Cancel
Save