Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add service name enrichment processor #1973

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9413ba2
feat: add service name enrichment processor
rakesh-garimella Mar 24, 2025
20a640f
add image
rakesh-garimella Mar 24, 2025
ba30090
fix
rakesh-garimella Mar 24, 2025
7cfb5ce
add service_enrichment to metric and traces
rakesh-garimella Mar 25, 2025
63ca9d1
Merge branch 'main' into add-service-name-enrichment-processor
a-thaler Mar 26, 2025
4ad8e62
fixes and add service enrichment processor to logs
rakesh-garimella Mar 26, 2025
23289ce
fix
rakesh-garimella Mar 26, 2025
ded91d3
improve tests
rakesh-garimella Mar 27, 2025
49f2ff0
fix
rakesh-garimella Mar 27, 2025
867dc50
fix
rakesh-garimella Mar 27, 2025
134bd63
remove uneeded files
rakesh-garimella Mar 27, 2025
37334ec
fix
rakesh-garimella Mar 27, 2025
fda505b
Merge branch 'main' into add-service-name-enrichment-processor
rakesh-garimella Mar 28, 2025
1a30100
fix image
rakesh-garimella Mar 28, 2025
0e80071
fix tests
rakesh-garimella Mar 28, 2025
ed592d2
fix
rakesh-garimella Mar 28, 2025
762dcb5
remove image name changes
rakesh-garimella Mar 28, 2025
a248d79
fixes
rakesh-garimella Mar 28, 2025
e527e47
fix
rakesh-garimella Mar 28, 2025
e2a1adf
fix
rakesh-garimella Mar 28, 2025
5c5431c
fix
rakesh-garimella Mar 28, 2025
862bd0f
fix
rakesh-garimella Mar 31, 2025
7adf53b
fix
rakesh-garimella Mar 31, 2025
a53713e
fix
rakesh-garimella Mar 31, 2025
1c2f362
Merge branch 'main' into add-service-name-enrichment-processor
skhalash Mar 31, 2025
ffa39a4
fix
rakesh-garimella Mar 31, 2025
0b16a0e
Merge branch 'main' into add-service-name-enrichment-processor
rakesh-garimella Mar 31, 2025
a358b2c
fix
rakesh-garimella Mar 31, 2025
77c7da5
fix imports
rakesh-garimella Mar 31, 2025
3981e52
fix
rakesh-garimella Mar 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/otelcollector/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ func DefaultExtensions() Extensions {
},
}
}

type ServiceEnrichmentProcessor struct {
ResourceAttributes []string `yaml:"resource_attributes"`
}
9 changes: 5 additions & 4 deletions internal/otelcollector/config/log/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ type Operator struct {

type Processors struct {
config.BaseProcessors `yaml:",inline"`
SetInstrumentationScopeRuntime *log.TransformProcessor `yaml:"transform/set-instrumentation-scope-runtime,omitempty"`
K8sAttributes *config.K8sAttributesProcessor `yaml:"k8sattributes,omitempty"`
InsertClusterAttributes *config.ResourceProcessor `yaml:"resource/insert-cluster-attributes,omitempty"`
DropKymaAttributes *config.ResourceProcessor `yaml:"resource/drop-kyma-attributes,omitempty"`
SetInstrumentationScopeRuntime *log.TransformProcessor `yaml:"transform/set-instrumentation-scope-runtime,omitempty"`
K8sAttributes *config.K8sAttributesProcessor `yaml:"k8sattributes,omitempty"`
InsertClusterAttributes *config.ResourceProcessor `yaml:"resource/insert-cluster-attributes,omitempty"`
ResolveServiceName *config.ServiceEnrichmentProcessor `yaml:"service_enrichment,omitempty"`
DropKymaAttributes *config.ResourceProcessor `yaml:"resource/drop-kyma-attributes,omitempty"`
}

type Exporters map[string]Exporter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func makePipelineConfig(receiverIDs, exporterIDs string) config.Pipeline {
"transform/set-instrumentation-scope-runtime",
"k8sattributes",
"resource/insert-cluster-attributes",
"service_enrichment",
"resource/drop-kyma-attributes",
},
Exporters: []string{exporterIDs},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func TestBuildAgentConfig(t *testing.T) {
require.Contains(t, collectorConfig.Service.Pipelines, "logs/test")

require.Contains(t, collectorConfig.Service.Pipelines["logs/test"].Receivers, "filelog/test")
require.Equal(t, []string{"memory_limiter", "transform/set-instrumentation-scope-runtime", "k8sattributes", "resource/insert-cluster-attributes", "resource/drop-kyma-attributes"}, collectorConfig.Service.Pipelines["logs/test"].Processors)
require.Equal(t, []string{"memory_limiter", "transform/set-instrumentation-scope-runtime", "k8sattributes", "resource/insert-cluster-attributes", "service_enrichment", "resource/drop-kyma-attributes"}, collectorConfig.Service.Pipelines["logs/test"].Processors)
require.Equal(t, []string{"otlp/test"}, collectorConfig.Service.Pipelines["logs/test"].Exporters)
})
})
Expand All @@ -178,8 +178,8 @@ func TestBuildAgentConfig(t *testing.T) {
require.Contains(t, collectorConfig.Service.Pipelines["logs/test1"].Receivers, "filelog/test1")
require.Contains(t, collectorConfig.Service.Pipelines["logs/test2"].Receivers, "filelog/test2")

require.Equal(t, []string{"memory_limiter", "transform/set-instrumentation-scope-runtime", "k8sattributes", "resource/insert-cluster-attributes", "resource/drop-kyma-attributes"}, collectorConfig.Service.Pipelines["logs/test1"].Processors)
require.Equal(t, []string{"memory_limiter", "transform/set-instrumentation-scope-runtime", "k8sattributes", "resource/insert-cluster-attributes", "resource/drop-kyma-attributes"}, collectorConfig.Service.Pipelines["logs/test2"].Processors)
require.Equal(t, []string{"memory_limiter", "transform/set-instrumentation-scope-runtime", "k8sattributes", "resource/insert-cluster-attributes", "service_enrichment", "resource/drop-kyma-attributes"}, collectorConfig.Service.Pipelines["logs/test1"].Processors)
require.Equal(t, []string{"memory_limiter", "transform/set-instrumentation-scope-runtime", "k8sattributes", "resource/insert-cluster-attributes", "service_enrichment", "resource/drop-kyma-attributes"}, collectorConfig.Service.Pipelines["logs/test2"].Processors)

require.Contains(t, collectorConfig.Service.Pipelines["logs/test1"].Exporters, "otlp/test1")
require.Contains(t, collectorConfig.Service.Pipelines["logs/test2"].Exporters, "otlp/test2")
Expand Down
1 change: 1 addition & 0 deletions internal/otelcollector/config/log/agent/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func makeProcessorsConfig(opts BuildOptions) Processors {
SetInstrumentationScopeRuntime: makeInstrumentationScopeRuntime(opts.InstrumentationScopeVersion),
K8sAttributes: processors.K8sAttributesProcessorConfig(opts.Enrichments),
InsertClusterAttributes: processors.InsertClusterAttributesProcessorConfig(opts.ClusterName, opts.CloudProvider),
ResolveServiceName: processors.MakeResolveServiceNameConfig(),
DropKymaAttributes: processors.DropKymaAttributesProcessorConfig(),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ service:
- transform/set-instrumentation-scope-runtime
- k8sattributes
- resource/insert-cluster-attributes
- service_enrichment
- resource/drop-kyma-attributes
exporters:
- otlp/test
Expand Down Expand Up @@ -151,6 +152,10 @@ processors:
- action: insert
key: cloud.provider
value: azure
service_enrichment:
resource_attributes:
- kyma.kubernetes_io_app_name
- kyma.app_name
resource/drop-kyma-attributes:
attributes:
- action: delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ service:
- transform/set-instrumentation-scope-runtime
- k8sattributes
- resource/insert-cluster-attributes
- service_enrichment
- resource/drop-kyma-attributes
exporters:
- otlp/test
Expand Down Expand Up @@ -154,6 +155,10 @@ processors:
- action: insert
key: cloud.provider
value: azure
service_enrichment:
resource_attributes:
- kyma.kubernetes_io_app_name
- kyma.app_name
resource/drop-kyma-attributes:
attributes:
- action: delete
Expand Down
9 changes: 5 additions & 4 deletions internal/otelcollector/config/log/gateway/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ type Receivers struct {
type Processors struct {
config.BaseProcessors `yaml:",inline"`

SetObsTimeIfZero *log.TransformProcessor `yaml:"transform/set-observed-time-if-zero,omitempty"`
K8sAttributes *config.K8sAttributesProcessor `yaml:"k8sattributes,omitempty"`
InsertClusterAttributes *config.ResourceProcessor `yaml:"resource/insert-cluster-attributes,omitempty"`
DropKymaAttributes *config.ResourceProcessor `yaml:"resource/drop-kyma-attributes,omitempty"`
SetObsTimeIfZero *log.TransformProcessor `yaml:"transform/set-observed-time-if-zero,omitempty"`
K8sAttributes *config.K8sAttributesProcessor `yaml:"k8sattributes,omitempty"`
InsertClusterAttributes *config.ResourceProcessor `yaml:"resource/insert-cluster-attributes,omitempty"`
ResolveServiceName *config.ServiceEnrichmentProcessor `yaml:"service_enrichment,omitempty"`
DropKymaAttributes *config.ResourceProcessor `yaml:"resource/drop-kyma-attributes,omitempty"`
}

type Exporters map[string]Exporter
Expand Down
2 changes: 2 additions & 0 deletions internal/otelcollector/config/log/gateway/config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func makePipelineConfig(exporterIDs ...string) config.Pipeline {
"transform/set-observed-time-if-zero",
"k8sattributes",
"resource/insert-cluster-attributes",
"service_enrichment",
"resource/drop-kyma-attributes",
"batch",
},
Exporters: exporterIDs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ func TestBuildConfig(t *testing.T) {
require.Equal(t, collectorConfig.Service.Pipelines["logs/test"].Processors[1], "transform/set-observed-time-if-zero")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test"].Processors[2], "k8sattributes")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test"].Processors[3], "resource/insert-cluster-attributes")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test"].Processors[4], "batch")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test"].Processors[4], "service_enrichment")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test"].Processors[5], "resource/drop-kyma-attributes")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test"].Processors[6], "batch")

require.Contains(t, collectorConfig.Service.Pipelines["logs/test"].Exporters, "otlp/test")
})
Expand All @@ -235,7 +237,9 @@ func TestBuildConfig(t *testing.T) {
require.Equal(t, collectorConfig.Service.Pipelines["logs/test-1"].Processors[1], "transform/set-observed-time-if-zero")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test-1"].Processors[2], "k8sattributes")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test-1"].Processors[3], "resource/insert-cluster-attributes")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test-1"].Processors[4], "batch")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test-1"].Processors[4], "service_enrichment")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test-1"].Processors[5], "resource/drop-kyma-attributes")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test-1"].Processors[6], "batch")

require.Contains(t, collectorConfig.Service.Pipelines, "logs/test-2")
require.Contains(t, collectorConfig.Service.Pipelines["logs/test-2"].Exporters, "otlp/test-2")
Expand All @@ -244,7 +248,9 @@ func TestBuildConfig(t *testing.T) {
require.Equal(t, collectorConfig.Service.Pipelines["logs/test-2"].Processors[1], "transform/set-observed-time-if-zero")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test-2"].Processors[2], "k8sattributes")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test-2"].Processors[3], "resource/insert-cluster-attributes")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test-2"].Processors[4], "batch")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test-2"].Processors[4], "service_enrichment")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test-1"].Processors[5], "resource/drop-kyma-attributes")
require.Equal(t, collectorConfig.Service.Pipelines["logs/test-2"].Processors[6], "batch")

require.Contains(t, envVars, "OTLP_ENDPOINT_TEST_1")
require.Contains(t, envVars, "OTLP_ENDPOINT_TEST_2")
Expand Down
2 changes: 2 additions & 0 deletions internal/otelcollector/config/log/gateway/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ func makeProcessorsConfig(opts BuildOptions) Processors {
SetObsTimeIfZero: makeSetObsTimeIfZeroProcessorConfig(),
K8sAttributes: processors.K8sAttributesProcessorConfig(opts.Enrichments),
InsertClusterAttributes: processors.InsertClusterAttributesProcessorConfig(opts.ClusterName, opts.CloudProvider),
ResolveServiceName: processors.MakeResolveServiceNameConfig(),
DropKymaAttributes: processors.DropKymaAttributesProcessorConfig(),
}
}

Expand Down
10 changes: 10 additions & 0 deletions internal/otelcollector/config/log/gateway/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ service:
- transform/set-observed-time-if-zero
- k8sattributes
- resource/insert-cluster-attributes
- service_enrichment
- resource/drop-kyma-attributes
- batch
exporters:
- otlp/test
Expand Down Expand Up @@ -102,6 +104,14 @@ processors:
- action: insert
key: cloud.provider
value: test-cloud-provider
service_enrichment:
resource_attributes:
- kyma.kubernetes_io_app_name
- kyma.app_name
resource/drop-kyma-attributes:
attributes:
- action: delete
pattern: kyma.*
exporters:
otlp/test:
endpoint: ${OTLP_ENDPOINT_TEST}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ service:
- transform/set-observed-time-if-zero
- k8sattributes
- resource/insert-cluster-attributes
- service_enrichment
- resource/drop-kyma-attributes
- batch
exporters:
- otlp/test
Expand Down Expand Up @@ -105,6 +107,14 @@ processors:
- action: insert
key: cloud.provider
value: test-cloud-provider
service_enrichment:
resource_attributes:
- kyma.kubernetes_io_app_name
- kyma.app_name
resource/drop-kyma-attributes:
attributes:
- action: delete
pattern: kyma.*
exporters:
otlp/test:
endpoint: ${OTLP_ENDPOINT_TEST}
Expand Down
42 changes: 21 additions & 21 deletions internal/otelcollector/config/metric/gateway/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,27 @@ type ModuleGVR struct {
type Processors struct {
config.BaseProcessors `yaml:",inline"`

K8sAttributes *config.K8sAttributesProcessor `yaml:"k8sattributes,omitempty"`
InsertClusterAttributes *config.ResourceProcessor `yaml:"resource/insert-cluster-attributes,omitempty"`
DropDiagnosticMetricsIfInputSourcePrometheus *FilterProcessor `yaml:"filter/drop-diagnostic-metrics-if-input-source-prometheus,omitempty"`
DropDiagnosticMetricsIfInputSourceIstio *FilterProcessor `yaml:"filter/drop-diagnostic-metrics-if-input-source-istio,omitempty"`
DropIfInputSourceRuntime *FilterProcessor `yaml:"filter/drop-if-input-source-runtime,omitempty"`
DropIfInputSourcePrometheus *FilterProcessor `yaml:"filter/drop-if-input-source-prometheus,omitempty"`
DropIfInputSourceIstio *FilterProcessor `yaml:"filter/drop-if-input-source-istio,omitempty"`
DropIfEnvoyMetricsDisabled *FilterProcessor `yaml:"filter/drop-envoy-metrics-if-disabled,omitempty"`
DropIfInputSourceOTLP *FilterProcessor `yaml:"filter/drop-if-input-source-otlp,omitempty"`
DropRuntimePodMetrics *FilterProcessor `yaml:"filter/drop-runtime-pod-metrics,omitempty"`
DropRuntimeContainerMetrics *FilterProcessor `yaml:"filter/drop-runtime-container-metrics,omitempty"`
DropRuntimeNodeMetrics *FilterProcessor `yaml:"filter/drop-runtime-node-metrics,omitempty"`
DropRuntimeVolumeMetrics *FilterProcessor `yaml:"filter/drop-runtime-volume-metrics,omitempty"`
DropRuntimeDeploymentMetrics *FilterProcessor `yaml:"filter/drop-runtime-deployment-metrics,omitempty"`
DropRuntimeStatefulSetMetrics *FilterProcessor `yaml:"filter/drop-runtime-statefulset-metrics,omitempty"`
DropRuntimeDaemonSetMetrics *FilterProcessor `yaml:"filter/drop-runtime-daemonset-metrics,omitempty"`
DropRuntimeJobMetrics *FilterProcessor `yaml:"filter/drop-runtime-job-metrics,omitempty"`
ResolveServiceName *metric.TransformProcessor `yaml:"transform/resolve-service-name,omitempty"`
DropKymaAttributes *config.ResourceProcessor `yaml:"resource/drop-kyma-attributes,omitempty"`
SetInstrumentationScopeKyma *metric.TransformProcessor `yaml:"transform/set-instrumentation-scope-kyma,omitempty"`
DeleteSkipEnrichmentAttribute *config.ResourceProcessor `yaml:"resource/delete-skip-enrichment-attribute,omitempty"`
K8sAttributes *config.K8sAttributesProcessor `yaml:"k8sattributes,omitempty"`
InsertClusterAttributes *config.ResourceProcessor `yaml:"resource/insert-cluster-attributes,omitempty"`
DropDiagnosticMetricsIfInputSourcePrometheus *FilterProcessor `yaml:"filter/drop-diagnostic-metrics-if-input-source-prometheus,omitempty"`
DropDiagnosticMetricsIfInputSourceIstio *FilterProcessor `yaml:"filter/drop-diagnostic-metrics-if-input-source-istio,omitempty"`
DropIfInputSourceRuntime *FilterProcessor `yaml:"filter/drop-if-input-source-runtime,omitempty"`
DropIfInputSourcePrometheus *FilterProcessor `yaml:"filter/drop-if-input-source-prometheus,omitempty"`
DropIfInputSourceIstio *FilterProcessor `yaml:"filter/drop-if-input-source-istio,omitempty"`
DropIfEnvoyMetricsDisabled *FilterProcessor `yaml:"filter/drop-envoy-metrics-if-disabled,omitempty"`
DropIfInputSourceOTLP *FilterProcessor `yaml:"filter/drop-if-input-source-otlp,omitempty"`
DropRuntimePodMetrics *FilterProcessor `yaml:"filter/drop-runtime-pod-metrics,omitempty"`
DropRuntimeContainerMetrics *FilterProcessor `yaml:"filter/drop-runtime-container-metrics,omitempty"`
DropRuntimeNodeMetrics *FilterProcessor `yaml:"filter/drop-runtime-node-metrics,omitempty"`
DropRuntimeVolumeMetrics *FilterProcessor `yaml:"filter/drop-runtime-volume-metrics,omitempty"`
DropRuntimeDeploymentMetrics *FilterProcessor `yaml:"filter/drop-runtime-deployment-metrics,omitempty"`
DropRuntimeStatefulSetMetrics *FilterProcessor `yaml:"filter/drop-runtime-statefulset-metrics,omitempty"`
DropRuntimeDaemonSetMetrics *FilterProcessor `yaml:"filter/drop-runtime-daemonset-metrics,omitempty"`
DropRuntimeJobMetrics *FilterProcessor `yaml:"filter/drop-runtime-job-metrics,omitempty"`
ResolveServiceName *config.ServiceEnrichmentProcessor `yaml:"service_enrichment,omitempty"`
DropKymaAttributes *config.ResourceProcessor `yaml:"resource/drop-kyma-attributes,omitempty"`
SetInstrumentationScopeKyma *metric.TransformProcessor `yaml:"transform/set-instrumentation-scope-kyma,omitempty"`
DeleteSkipEnrichmentAttribute *config.ResourceProcessor `yaml:"resource/delete-skip-enrichment-attribute,omitempty"`

// NamespaceFilters contains filter processors, which need different configurations per pipeline
NamespaceFilters NamespaceFilters `yaml:",inline,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func makeProcessorsConfig(opts BuildOptions) Processors {
Enabled: false,
}),
InsertClusterAttributes: processors.InsertClusterAttributesProcessorConfig(opts.ClusterName, opts.CloudProvider),
ResolveServiceName: makeResolveServiceNameConfig(),
ResolveServiceName: processors.MakeResolveServiceNameConfig(),
DropKymaAttributes: processors.DropKymaAttributesProcessorConfig(),
DeleteSkipEnrichmentAttribute: makeDeleteSkipEnrichmentAttributeConfig(),
}
Expand All @@ -44,13 +44,6 @@ func makeMemoryLimiterConfig() *config.MemoryLimiter {
}
}

func makeResolveServiceNameConfig() *metric.TransformProcessor {
return &metric.TransformProcessor{
ErrorMode: "ignore",
MetricStatements: processors.ResolveServiceNameStatements(),
}
}

func makeDeleteSkipEnrichmentAttributeConfig() *config.ResourceProcessor {
return &config.ResourceProcessor{
Attributes: []config.AttributeAction{
Expand Down
2 changes: 1 addition & 1 deletion internal/otelcollector/config/metric/gateway/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func makeInputPipelineServiceConfig(pipeline *telemetryv1alpha1.MetricPipeline)
func makeAttributesEnrichmentPipelineServiceConfig(pipelineName string) config.Pipeline {
return config.Pipeline{
Receivers: []string{formatRoutingConnectorID(pipelineName)},
Processors: []string{"k8sattributes", "transform/resolve-service-name"},
Processors: []string{"k8sattributes", "service_enrichment"},
Exporters: []string{formatForwardConnectorID(pipelineName)},
}
}
Expand Down
Loading
Loading