Skip to content

Commit

Permalink
Small refactor of default config
Browse files Browse the repository at this point in the history
  • Loading branch information
xperimental committed Oct 10, 2024
1 parent b2209f2 commit 09daa17
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
20 changes: 11 additions & 9 deletions operator/internal/manifests/config_otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,8 @@ import (
"github.com/grafana/loki/operator/internal/manifests/internal/config"
)

func defaultOTLPAttributeConfig(ts *lokiv1.TenantsSpec) config.OTLPAttributeConfig {
if ts == nil || ts.Mode != lokiv1.OpenshiftLogging {
return config.OTLPAttributeConfig{}
}

// TODO decide which of these can be disabled by using "disableRecommendedAttributes"
// TODO decide whether we want to split the default configuration by tenant
result := config.OTLPAttributeConfig{
func defaultOpenShiftLoggingAttributes() config.OTLPAttributeConfig {
return config.OTLPAttributeConfig{
DefaultIndexLabels: []string{
"openshift.cluster.uid",
"openshift.log.source",
Expand Down Expand Up @@ -90,8 +84,16 @@ func defaultOTLPAttributeConfig(ts *lokiv1.TenantsSpec) config.OTLPAttributeConf
},
},
}
}

func defaultOTLPAttributeConfig(ts *lokiv1.TenantsSpec) config.OTLPAttributeConfig {
if ts == nil || ts.Mode != lokiv1.OpenshiftLogging {
return config.OTLPAttributeConfig{}
}

return result
// TODO decide which of these can be disabled by using "disableRecommendedAttributes"
// TODO decide whether we want to split the default configuration by tenant
return defaultOpenShiftLoggingAttributes()
}

func collectAttributes(attrs []lokiv1.OTLPAttributeReference) (regularExpressions, names []string) {
Expand Down
9 changes: 9 additions & 0 deletions operator/internal/manifests/config_otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ func TestOtlpAttributeConfig(t *testing.T) {
},
},
},
{
desc: "openshift-logging defaults",
spec: lokiv1.LokiStackSpec{
Tenants: &lokiv1.TenantsSpec{
Mode: lokiv1.OpenshiftLogging,
},
},
wantConfig: defaultOpenShiftLoggingAttributes(),
},
}

for _, tc := range tt {
Expand Down

0 comments on commit 09daa17

Please sign in to comment.