Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
15 changes: 8 additions & 7 deletions docs/contributor/otel-bump-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ As a maintainer or contributor, follow these steps to update the `opentelemetry-

## Table of Content

- [OpenTelemetry Dependency Bump Guide](#opentelemetry-dependency-bump-guide)
- [Table of Content](#table-of-content)
- [Preparation](#preparation)
- [Review Changed Components](#1-review-changed-components)
- [Detect OTTL Changes](#2-detect-ottl-changes)
- [Review Processor Updates](#3-review-processor-updates)
- [Check Internal Metrics](#4-check-internal-metrics)
- [Identify and Plan for Breaking Changes](#5-identify-and-plan-for-breaking-changes)
- [1. Review Changed Components](#1-review-changed-components)
- [2. Detect OTTL Changes](#2-detect-ottl-changes)
- [3. Review Processor Updates](#3-review-processor-updates)
- [4. Check Internal Metrics](#4-check-internal-metrics)
- [5. Identify and Plan for Breaking Changes](#5-identify-and-plan-for-breaking-changes)
- [Implementation](#implementation)
- [Post Bump Verification](#post-bump-verification)
- [Post-Bump Verification](#post-bump-verification)

## Preparation

Expand All @@ -36,7 +38,6 @@ Identify breaking changes, bug fixes, and enhancements for the following compone
- `filterprocessor` (contrib)
- `k8sattributesprocessor` (contrib)
- `memorylimiterprocessor`
- `resourceprocessor` (contrib)
- `transformprocessor` (contrib)
- Exporters
- `otlpexporter`
Expand Down
6 changes: 6 additions & 0 deletions internal/otelcollector/config/common/config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import (
"github.com/kyma-project/telemetry-manager/internal/otelcollector/ports"
)

type ClusterOptions struct {
Name string
UID string
CloudProvider string
}

func NewConfig() *Config {
config := &Config{
Receivers: make(map[string]any),
Expand Down
18 changes: 9 additions & 9 deletions internal/otelcollector/config/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ const (
ComponentIDSetInstrumentationScopeKymaProcessor = "transform/set-instrumentation-scope-kyma"
ComponentIDSetInstrumentationScopeRuntimeProcessor = "transform/set-instrumentation-scope-runtime"
ComponentIDUserDefinedTransformProcessor = "transform/user-defined-%s" // dynamically filled with pipeline name
ComponentIDInsertClusterAttributesProcessor = "resource/insert-cluster-attributes"
ComponentIDDropKymaAttributesProcessor = "resource/drop-kyma-attributes"
ComponentIDInsertClusterAttributesProcessor = "transform/insert-cluster-attributes"
ComponentIDDropKymaAttributesProcessor = "transform/drop-kyma-attributes"

ComponentIDSetKymaInputNameRuntimeProcessor ComponentID = "resource/set-kyma-input-name-runtime"
ComponentIDSetKymaInputNameIstioProcessor ComponentID = "resource/set-kyma-input-name-istio"
ComponentIDSetKymaInputNamePrometheusProcessor ComponentID = "resource/set-kyma-input-name-prometheus"
ComponentIDSetKymaInputNameKymaProcessor ComponentID = "resource/set-kyma-input-name-kyma"
ComponentIDSetKymaInputNameOTLPProcessor ComponentID = "resource/set-kyma-input-name-otlp"
ComponentIDSetKymaInputNameRuntimeProcessor ComponentID = "transform/set-kyma-input-name-runtime"
ComponentIDSetKymaInputNameIstioProcessor ComponentID = "transform/set-kyma-input-name-istio"
ComponentIDSetKymaInputNamePrometheusProcessor ComponentID = "transform/set-kyma-input-name-prometheus"
ComponentIDSetKymaInputNameKymaProcessor ComponentID = "transform/set-kyma-input-name-kyma"
ComponentIDSetKymaInputNameOTLPProcessor ComponentID = "transform/set-kyma-input-name-otlp"

// Log-Specific Processors

Expand Down Expand Up @@ -152,8 +152,8 @@ const (
ComponentIDDropIstioDiagnosticMetricsProcessor = "filter/drop-diagnostic-metrics-if-input-source-istio"
ComponentIDFilterDropNonPVCVolumesMetricsProcessor = "filter/drop-non-pvc-volumes-metrics"
ComponentIDFilterDropVirtualNetworkInterfacesProcessor = "filter/drop-virtual-network-interfaces"
ComponentIDResourceDropServiceNameProcessor = "resource/drop-service-name"
ComponentIDDropSkipEnrichmentAttributeProcessor = "resource/drop-skip-enrichment-attribute"
ComponentIDDropServiceNameProcessor = "transform/drop-service-name"
ComponentIDDropSkipEnrichmentAttributeProcessor = "transform/drop-skip-enrichment-attribute"
ComponentIDSetInstrumentationScopePrometheusProcessor = "transform/set-instrumentation-scope-prometheus"
ComponentIDSetInstrumentationScopeIstioProcessor = "transform/set-instrumentation-scope-istio"
ComponentIDInsertSkipEnrichmentAttributeProcessor = "transform/insert-skip-enrichment-attribute"
Expand Down
96 changes: 32 additions & 64 deletions internal/otelcollector/config/common/processor_builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,58 +108,6 @@ func extractPodLabels(enrichments *operatorv1alpha1.EnrichmentSpec) []ExtractLab
// RESOURCE PROCESSOR BUILDERS
// =============================================================================

// InsertClusterAttributesProcessorConfig creates a resource processor that inserts cluster attributes
func InsertClusterAttributesProcessorConfig(clusterName, clusterUID, cloudProvider string) *ResourceProcessor {
if cloudProvider != "" {
return &ResourceProcessor{
Attributes: []AttributeAction{
{
Action: AttributeActionInsert,
Key: "k8s.cluster.name",
Value: clusterName,
},
{
Action: AttributeActionInsert,
Key: "k8s.cluster.uid",
Value: clusterUID,
},
{
Action: AttributeActionInsert,
Key: "cloud.provider",
Value: cloudProvider,
},
},
}
}

return &ResourceProcessor{
Attributes: []AttributeAction{
{
Action: AttributeActionInsert,
Key: "k8s.cluster.name",
Value: clusterName,
},
{
Action: AttributeActionInsert,
Key: "k8s.cluster.uid",
Value: clusterUID,
},
},
}
}

// DropKymaAttributesProcessorConfig creates a resource processor that drops Kyma attributes
func DropKymaAttributesProcessorConfig() *ResourceProcessor {
return &ResourceProcessor{
Attributes: []AttributeAction{
{
Action: AttributeActionDelete,
RegexPattern: "kyma.*",
},
},
}
}

// ResolveServiceNameConfig creates a service enrichment processor configuration
func ResolveServiceNameConfig() *ServiceEnrichmentProcessor {
return &ServiceEnrichmentProcessor{
Expand Down Expand Up @@ -285,6 +233,32 @@ func TransformSpecsToProcessorStatements(specs []telemetryv1alpha1.TransformSpec
return result
}

// InsertClusterAttributesProcessorStatements creates processor statements for the transform processor that inserts cluster attributes
func InsertClusterAttributesProcessorStatements(cluster ClusterOptions) []TransformProcessorStatements {
statements := []string{
fmt.Sprintf("set(resource.attributes[\"k8s.cluster.name\"], \"%s\")", cluster.Name),
fmt.Sprintf("set(resource.attributes[\"k8s.cluster.uid\"], \"%s\")", cluster.UID),
}

if cluster.CloudProvider != "" {
statements = append(statements,
fmt.Sprintf("set(resource.attributes[\"cloud.provider\"], \"%s\")", cluster.CloudProvider))
}

return []TransformProcessorStatements{{
Statements: statements,
}}
}

// DropKymaAttributesProcessorStatements creates processor statements for the transform processor that drops Kyma attributes
func DropKymaAttributesProcessorStatements() []TransformProcessorStatements {
return []TransformProcessorStatements{{
Statements: []string{
"delete_matching_keys(resource.attributes, \"kyma.*\")",
},
}}
}

// InstrumentationScopeProcessorConfig creates a transform processor for instrumentation scope
func InstrumentationScopeProcessorConfig(instrumentationScopeVersion string, inputSource ...InputSourceType) *TransformProcessor {
statements := []string{}
Expand All @@ -301,20 +275,14 @@ func InstrumentationScopeProcessorConfig(instrumentationScopeVersion string, inp
return MetricTransformProcessorConfig(transformProcessorStatements)
}

// KymaInputNameProcessorConfig creates a transform processor that sets the custom `kyma.input.name` attribute
// KymaInputNameProcessorStatements creates processor statements for the transform processor that sets the custom `kyma.input.name` attribute
// the attribute is mainly used for routing purpose in the metric agent configuration
func KymaInputNameProcessorConfig(inputSource InputSourceType) *ResourceProcessor {
resourceProcessor := ResourceProcessor{
Attributes: []AttributeAction{
{
Action: AttributeActionInsert,
Key: KymaInputNameAttribute,
Value: string(inputSource),
},
func KymaInputNameProcessorStatements(inputSource InputSourceType) []TransformProcessorStatements {
return []TransformProcessorStatements{{
Statements: []string{
fmt.Sprintf("set(resource.attributes[\"%s\"], \"%s\")", KymaInputNameAttribute, string(inputSource)),
},
}

return &resourceProcessor
}}
}

func instrumentationStatement(inputSource InputSourceType, instrumentationScopeVersion string) []string {
Expand Down
Loading
Loading