Skip to content

Commit

Permalink
Merge pull request #91 from kube-logging/feat/switch-to-condition
Browse files Browse the repository at this point in the history
feat: deprecate ottl field in subs and bridges with condition
  • Loading branch information
csatib02 authored Nov 7, 2024
2 parents d9cb27d + 6cd0472 commit 9e3cf30
Show file tree
Hide file tree
Showing 33 changed files with 658 additions and 163 deletions.
6 changes: 3 additions & 3 deletions api/telemetry/v1alpha1/bridge_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (

// BridgeSpec defines the desired state of Bridge
type BridgeSpec struct {
SourceTenant string `json:"sourceTenant,omitempty"`
TargetTenant string `json:"targetTenant,omitempty"`
SourceTenant string `json:"sourceTenant"`
TargetTenant string `json:"targetTenant"`
// The OTTL condition which must be satisfied in order to forward telemetry
// from the source tenant to the target tenant
OTTL string `json:"ottl,omitempty"`
Condition string `json:"condition"`
}

// BridgeStatus defines the observed state of Bridge
Expand Down
5 changes: 2 additions & 3 deletions api/telemetry/v1alpha1/subscription_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import (

// SubscriptionSpec defines the desired state of Subscription
type SubscriptionSpec struct {
Outputs []NamespacedName `json:"outputs,omitempty"`
OTTL string `json:"ottl,omitempty"`
Debug bool `json:"debug,omitempty"`
Condition string `json:"condition"`
Outputs []NamespacedName `json:"outputs,omitempty"`
}

// SubscriptionStatus defines the observed state of Subscription
Expand Down
24 changes: 19 additions & 5 deletions api/telemetry/v1alpha1/tenant_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Statement represents a single statement in a Transform processor
// TransformStatement represents a single statement in a Transform processor
// ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor
type Statement struct {
type TransformStatement struct {
// +kubebuilder:validation:Enum:=resource;scope;span;spanevent;metric;datapoint;log
Context string `json:"context,omitempty"`
Conditions []string `json:"conditions,omitempty"`
Expand All @@ -38,16 +38,30 @@ type Transform struct {
// vaid options are: ignore, silent, propagate; (default: propagate)
ErrorMode string `json:"errorMode,omitempty"`

TraceStatements []Statement `json:"traceStatements,omitempty"`
MetricStatements []Statement `json:"metricStatements,omitempty"`
LogStatements []Statement `json:"logStatements,omitempty"`
TraceStatements []TransformStatement `json:"traceStatements,omitempty"`
MetricStatements []TransformStatement `json:"metricStatements,omitempty"`
LogStatements []TransformStatement `json:"logStatements,omitempty"`
}

// RouteConfig defines the routing configuration for a tenant
// it will be used to generate routing connectors
type RouteConfig struct {
DefaultPipelines []string `json:"defaultPipelines,omitempty"` // TODO: Provide users with a guide to determine generated pipeline names

// +kubebuilder:validation:Enum:=ignore;silent;propagate

// ErrorMode specifies how errors are handled while processing a statement
// vaid options are: ignore, silent, propagate; (default: propagate)
ErrorMode string `json:"errorMode,omitempty"`
MatchOnce bool `json:"matchOnce,omitempty"`
}

// TenantSpec defines the desired state of Tenant
type TenantSpec struct {
SubscriptionNamespaceSelectors []metav1.LabelSelector `json:"subscriptionNamespaceSelectors,omitempty"`
LogSourceNamespaceSelectors []metav1.LabelSelector `json:"logSourceNamespaceSelectors,omitempty"`
Transform Transform `json:"transform,omitempty"`
RouteConfig RouteConfig `json:"routeConfig,omitempty"`
}

// TenantStatus defines the observed state of Tenant
Expand Down
49 changes: 35 additions & 14 deletions api/telemetry/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ spec:
spec:
description: BridgeSpec defines the desired state of Bridge
properties:
ottl:
condition:
description: |-
The OTTL condition which must be satisfied in order to forward telemetry
from the source tenant to the target tenant
Expand All @@ -60,6 +60,10 @@ spec:
type: string
targetTenant:
type: string
required:
- condition
- sourceTenant
- targetTenant
type: object
status:
description: BridgeStatus defines the observed state of Bridge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ spec:
spec:
description: SubscriptionSpec defines the desired state of Subscription
properties:
debug:
type: boolean
ottl:
condition:
type: string
outputs:
items:
Expand All @@ -67,6 +65,8 @@ spec:
- namespace
type: object
type: array
required:
- condition
type: object
status:
description: SubscriptionStatus defines the observed state of Subscription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,27 @@ spec:
type: object
x-kubernetes-map-type: atomic
type: array
routeConfig:
description: |-
RouteConfig defines the routing configuration for a tenant
it will be used to generate routing connectors
properties:
defaultPipelines:
items:
type: string
type: array
errorMode:
description: |-
ErrorMode specifies how errors are handled while processing a statement
vaid options are: ignore, silent, propagate; (default: propagate)
enum:
- ignore
- silent
- propagate
type: string
matchOnce:
type: boolean
type: object
subscriptionNamespaceSelectors:
items:
description: |-
Expand Down Expand Up @@ -172,7 +193,7 @@ spec:
logStatements:
items:
description: |-
Statement represents a single statement in a Transform processor
TransformStatement represents a single statement in a Transform processor
ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor
properties:
conditions:
Expand All @@ -198,7 +219,7 @@ spec:
metricStatements:
items:
description: |-
Statement represents a single statement in a Transform processor
TransformStatement represents a single statement in a Transform processor
ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor
properties:
conditions:
Expand Down Expand Up @@ -227,7 +248,7 @@ spec:
traceStatements:
items:
description: |-
Statement represents a single statement in a Transform processor
TransformStatement represents a single statement in a Transform processor
ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor
properties:
conditions:
Expand Down
6 changes: 5 additions & 1 deletion config/crd/bases/telemetry.kube-logging.dev_bridges.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ spec:
spec:
description: BridgeSpec defines the desired state of Bridge
properties:
ottl:
condition:
description: |-
The OTTL condition which must be satisfied in order to forward telemetry
from the source tenant to the target tenant
Expand All @@ -60,6 +60,10 @@ spec:
type: string
targetTenant:
type: string
required:
- condition
- sourceTenant
- targetTenant
type: object
status:
description: BridgeStatus defines the observed state of Bridge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ spec:
spec:
description: SubscriptionSpec defines the desired state of Subscription
properties:
debug:
type: boolean
ottl:
condition:
type: string
outputs:
items:
Expand All @@ -67,6 +65,8 @@ spec:
- namespace
type: object
type: array
required:
- condition
type: object
status:
description: SubscriptionStatus defines the observed state of Subscription
Expand Down
27 changes: 24 additions & 3 deletions config/crd/bases/telemetry.kube-logging.dev_tenants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,27 @@ spec:
type: object
x-kubernetes-map-type: atomic
type: array
routeConfig:
description: |-
RouteConfig defines the routing configuration for a tenant
it will be used to generate routing connectors
properties:
defaultPipelines:
items:
type: string
type: array
errorMode:
description: |-
ErrorMode specifies how errors are handled while processing a statement
vaid options are: ignore, silent, propagate; (default: propagate)
enum:
- ignore
- silent
- propagate
type: string
matchOnce:
type: boolean
type: object
subscriptionNamespaceSelectors:
items:
description: |-
Expand Down Expand Up @@ -172,7 +193,7 @@ spec:
logStatements:
items:
description: |-
Statement represents a single statement in a Transform processor
TransformStatement represents a single statement in a Transform processor
ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor
properties:
conditions:
Expand All @@ -198,7 +219,7 @@ spec:
metricStatements:
items:
description: |-
Statement represents a single statement in a Transform processor
TransformStatement represents a single statement in a Transform processor
ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor
properties:
conditions:
Expand Down Expand Up @@ -227,7 +248,7 @@ spec:
traceStatements:
items:
description: |-
Statement represents a single statement in a Transform processor
TransformStatement represents a single statement in a Transform processor
ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor
properties:
conditions:
Expand Down
2 changes: 1 addition & 1 deletion config/samples/telemetry_v1alpha1_bridge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ metadata:
spec:
sourceTenant: shared
destinationTenant: tenantA
ottl: 'route() where attributes["parsed"]["method"] == "GET"'
condition: 'attributes["parsed"]["method"] == "GET"'
1 change: 1 addition & 0 deletions config/samples/telemetry_v1alpha1_subscription.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ metadata:
app.kubernetes.io/created-by: telemetry-controller
name: subscription-sample
spec:
condition: "true"
outputs:
- name: output-sample
namespace: collector
4 changes: 2 additions & 2 deletions docs/demos/loki/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ metadata:
name: all-logs
namespace: tenant-demo-1
spec:
ottl: 'route()'
condition: "true"
outputs:
- name: loki
namespace: collector
Expand All @@ -86,7 +86,7 @@ metadata:
name: all-logs
namespace: tenant-demo-2
spec:
ottl: 'route()'
condition: "true"
outputs:
- name: loki
namespace: collector
Expand Down
Loading

0 comments on commit 9e3cf30

Please sign in to comment.