Skip to content

Commit e1b4892

Browse files
committed
chore: use consts for frequently used id's
Signed-off-by: Bence Csati <bence.csati@axoflow.com>
1 parent a09236d commit e1b4892

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

pkg/resources/otel_conf_gen/pipeline/components/exporter/debug_exporter.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414

1515
package exporter
1616

17+
const DebugExporterID = "debug"
18+
1719
func GenerateDebugExporters() map[string]any {
1820
result := make(map[string]any)
19-
result["debug"] = map[string]any{
21+
result[DebugExporterID] = map[string]any{
2022
"verbosity": "detailed",
2123
}
2224

pkg/resources/otel_conf_gen/pipeline/components/exporter/prometheus_exporter.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import (
2424
"github.com/kube-logging/telemetry-controller/api/telemetry/v1alpha1"
2525
)
2626

27+
const (
28+
DefaultPrometheusExporterID = "prometheus/message_metrics_exporter"
29+
)
30+
2731
type TLSServerConfig struct {
2832
// squash ensures fields are correctly decoded in embedded struct.
2933
v1alpha1.TLSSetting `json:",inline"`
@@ -125,7 +129,7 @@ func GenerateMetricsExporters() map[string]any {
125129
}
126130

127131
metricsExporters := make(map[string]any)
128-
metricsExporters["prometheus/message_metrics_exporter"] = defaultPrometheusExporterConfig
132+
metricsExporters[DefaultPrometheusExporterID] = defaultPrometheusExporterConfig
129133

130134
return metricsExporters
131135
}

pkg/resources/otel_conf_gen/pipeline/components/processor/attributes_processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func GenerateOutputExporterNameProcessor(outputName string) AttributesProcessor
7474

7575
func GenerateMetricsProcessors() map[string]any {
7676
metricsProcessors := make(map[string]any)
77-
metricsProcessors["deltatocumulative"] = DeltaToCumulativeConfig{}
77+
metricsProcessors[DefaultDeltaToCumulativeProcessorID] = DeltaToCumulativeConfig{}
7878
metricsProcessors["attributes/metricattributes"] = AttributesProcessor{
7979
Actions: []AttributesProcessorAction{
8080
{

pkg/resources/otel_conf_gen/pipeline/components/processor/delta_to_cumulative_processor.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ package processor
1616

1717
import "time"
1818

19+
const DefaultDeltaToCumulativeProcessorID = "deltatocumulative"
20+
1921
type DeltaToCumulativeConfig struct {
2022
MaxStale time.Duration `json:"max_stale,omitempty"`
2123
MaxStreams int `json:"max_streams,omitempty"`

pkg/resources/otel_conf_gen/pipeline/pipeline.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
otelv1beta1 "github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
2121

2222
"github.com/kube-logging/telemetry-controller/api/telemetry/v1alpha1"
23+
"github.com/kube-logging/telemetry-controller/pkg/resources/otel_conf_gen/pipeline/components/exporter"
24+
"github.com/kube-logging/telemetry-controller/pkg/resources/otel_conf_gen/pipeline/components/processor"
2325
)
2426

2527
func GeneratePipeline(receivers, processors, exporters []string) *otelv1beta1.Pipeline {
@@ -55,19 +57,19 @@ func GenerateMetricsPipelines() map[string]*otelv1beta1.Pipeline {
5557
metricsPipelines := make(map[string]*otelv1beta1.Pipeline)
5658
metricsPipelines["metrics/tenant"] = &otelv1beta1.Pipeline{
5759
Receivers: []string{"count/tenant_metrics"},
58-
Processors: []string{"deltatocumulative", "attributes/metricattributes"},
59-
Exporters: []string{"prometheus/message_metrics_exporter"},
60+
Processors: []string{processor.DefaultDeltaToCumulativeProcessorID, "attributes/metricattributes"},
61+
Exporters: []string{exporter.DefaultPrometheusExporterID},
6062
}
6163
metricsPipelines["metrics/output"] = &otelv1beta1.Pipeline{
6264
Receivers: []string{"count/output_metrics"},
63-
Processors: []string{"deltatocumulative", "attributes/metricattributes"},
64-
Exporters: []string{"prometheus/message_metrics_exporter"},
65+
Processors: []string{processor.DefaultDeltaToCumulativeProcessorID, "attributes/metricattributes"},
66+
Exporters: []string{exporter.DefaultPrometheusExporterID},
6567
}
6668

6769
metricsPipelines["metrics/output_bytes"] = &otelv1beta1.Pipeline{
6870
Receivers: []string{"bytes/exporter"},
69-
Processors: []string{"deltatocumulative", "attributes/metricattributes"},
70-
Exporters: []string{"prometheus/message_metrics_exporter"},
71+
Processors: []string{processor.DefaultDeltaToCumulativeProcessorID, "attributes/metricattributes"},
72+
Exporters: []string{exporter.DefaultPrometheusExporterID},
7173
}
7274

7375
return metricsPipelines

0 commit comments

Comments
 (0)