Dynatrace: Add to list of DS with custom label logic (#90258)

This commit is contained in:
Fabrizio 2024-07-15 10:18:54 +02:00 committed by GitHub
parent 0547a9ed88
commit 612ebf5508
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 15 deletions

View File

@ -3,6 +3,7 @@ package expr
import (
"context"
"fmt"
"slices"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/data"
@ -295,10 +296,14 @@ func WideToMany(frame *data.Frame, fixSeries func(series mathexp.Series, valueFi
// checkIfSeriesNeedToBeFixed scans all value fields of all provided frames and determines whether the resulting mathexp.Series
// needs to be updated so each series could be identifiable by labels.
// NOTE: applicable only to only datasources.DS_GRAPHITE and datasources.DS_TESTDATA data sources
// NOTE: applicable only to some datas ources (datasources.DS_GRAPHITE, datasources.DS_TESTDATA, etc.); a more general solution should be investigated
// returns a function that patches the mathexp.Series with information from data.Field from which it was created if the all series need to be fixed. Otherwise, returns nil
func checkIfSeriesNeedToBeFixed(frames []*data.Frame, datasourceType string) func(series mathexp.Series, valueField *data.Field) {
if !(datasourceType == datasources.DS_GRAPHITE || datasourceType == datasources.DS_TESTDATA) {
supportedDatasources := []string{datasources.DS_GRAPHITE, datasources.DS_TESTDATA, datasources.DS_DYNATRACE}
checkdatasourceType := func(ds string) bool {
return datasourceType == ds
}
if !slices.ContainsFunc(supportedDatasources, checkdatasourceType) {
return nil
}

View File

@ -148,6 +148,7 @@ func TestCheckIfSeriesNeedToBeFixed(t *testing.T) {
}
supportedDatasources := []string{
datasources.DS_DYNATRACE,
datasources.DS_GRAPHITE,
datasources.DS_TESTDATA,
}

View File

@ -11,26 +11,27 @@ import (
)
const (
DS_ACCESS_DIRECT = "direct"
DS_ACCESS_PROXY = "proxy"
DS_ALERTMANAGER = "alertmanager"
DS_AZURE_MONITOR = "grafana-azure-monitor-datasource"
DS_DYNATRACE = "grafana-dynatrace-datasource"
DS_ES = "elasticsearch"
DS_ES_OPEN_DISTRO = "grafana-es-open-distro-datasource"
DS_ES_OPENSEARCH = "grafana-opensearch-datasource"
DS_GRAPHITE = "graphite"
DS_INFLUXDB = "influxdb"
DS_INFLUXDB_08 = "influxdb_08"
DS_ES = "elasticsearch"
DS_PROMETHEUS = "prometheus"
DS_ALERTMANAGER = "alertmanager"
DS_JAEGER = "jaeger"
DS_LOKI = "loki"
DS_OPENTSDB = "opentsdb"
DS_TEMPO = "tempo"
DS_ZIPKIN = "zipkin"
DS_MYSQL = "mysql"
DS_POSTGRES = "grafana-postgresql-datasource"
DS_MSSQL = "mssql"
DS_ACCESS_DIRECT = "direct"
DS_ACCESS_PROXY = "proxy"
DS_ES_OPEN_DISTRO = "grafana-es-open-distro-datasource"
DS_ES_OPENSEARCH = "grafana-opensearch-datasource"
DS_AZURE_MONITOR = "grafana-azure-monitor-datasource"
DS_MYSQL = "mysql"
DS_OPENTSDB = "opentsdb"
DS_POSTGRES = "grafana-postgresql-datasource"
DS_PROMETHEUS = "prometheus"
DS_TEMPO = "tempo"
DS_TESTDATA = "grafana-testdata-datasource"
DS_ZIPKIN = "zipkin"
// CustomHeaderName is the prefix that is used to store the name of a custom header.
CustomHeaderName = "httpHeaderName"
// CustomHeaderValue is the prefix that is used to store the value of a custom header.