Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ rules:
- serviceaccounts/token
verbs:
- create
- apiGroups:
- helm.toolkit.fluxcd.io
resources:
- helmreleases
verbs:
- get
- apiGroups:
- image.fluxcd.io
resources:
Expand All @@ -41,6 +47,12 @@ rules:
- imagerepositories/status
verbs:
- get
- apiGroups:
- kustomize.toolkit.fluxcd.io
resources:
- kustomizations
verbs:
- get
- apiGroups:
- notification.toolkit.fluxcd.io
resources:
Expand Down Expand Up @@ -85,3 +97,13 @@ rules:
- ocirepositories/status
verbs:
- get
- apiGroups:
- source.toolkit.fluxcd.io
resources:
- buckets
- externalartifacts
- gitrepositories
- helmcharts
- ocirepositories
verbs:
- get
16 changes: 14 additions & 2 deletions docs/spec/v1/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -1283,9 +1283,21 @@ stringData:
When `.spec.type` is set to `otel`, the controller will send distributed tracing data for
[Events](events.md#event-structure) to an OpenTelemetry (OTEL) collector endpoint specified in the [Address](#address) field.

The controller converts Flux events into OTEL spans with proper trace relationships based on the Flux object hierarchy. Source objects (GitRepository, HelmChart, OCIRepository, Bucket) create root spans, while other objects create child spans within the same trace. Each span includes event metadata as attributes and uses the alert name and namespace as the service identifier.
The controller converts Flux events into OTEL spans, one span per event, with trace relationships that mirror the Flux object hierarchy. Each span includes event metadata as attributes and uses the alert name and namespace as the service identifier.

Spans are correlated using a trace ID generated from the alert UID and revision metadata (depending on the source, the revision could be oci-digest, git commit hash, etc.). Having the following format: `<AlertUID>:<revision>`. All events from the same alert share the same trace ID, enabling end-to-end visibility across.
The parent of a span is resolved in the following order:

1. **Managing Kustomization.** If the object is managed by a Kustomization, found through the `kustomize.toolkit.fluxcd.io/name` and `kustomize.toolkit.fluxcd.io/namespace` labels (followed up to 10 levels), a source is linked to the Kustomization that manages it, and any other object to the root Kustomization when it is at the same revision.
2. **Related object.** Otherwise, the span is linked to the `involvedObject`'s related object, i.e. the `.relatedObject` field of the [Event](events.md#event-structure), when the controller that emitted the event sets it. Its UID is used as is.
3. **Cluster lookup.** Only when the event has no related object, the controller falls back to reading the object an event is about from the cluster, to find the object it is built from: a Kustomization's source, a HelmRelease's `.spec.chartRef` or the HelmChart generated for its `.spec.chart`.

All the spans that belong to the same revision flow share the same trace ID. It is derived from the alert UID and the revision at the root of the hierarchy (depending on the source, the revision could be oci-digest, git commit hash, etc.), having the following format: `<AlertUID>:<revision>`. When an object is managed by one or more Kustomizations, the revision is the one of the root Kustomization. Events that carry no revision, and events for which none can be resolved, are not grouped and get a trace of their own.

A source that is managed by a Kustomization which also reconciles that very source, as in the `flux bootstrap` topology (the `flux-system` GitRepository and Kustomization), is the root of the trace of its own revision. The Kustomization becomes its child instead of the other way around, and the source is not placed in the trace of the Kustomization's previous revision.

The span ID of an object at a given revision is derived from the object UID and the revision, so that spans of child objects can reference it as their parent. Consequently, events of the same object and revision share the span ID, and backends may merge them.

Finding the managing Kustomization and the cluster lookup are live `get` requests, which require `get` permissions on Kustomizations, HelmReleases and the source kinds. Objects that can't be read are left out of the trace without raising an error. When cross-namespace references are blocked (`--no-cross-namespace-refs`), only objects in the namespace of the Alert are read, so the hierarchy stops at the namespace boundary.

This Provider type supports authentication via [Secret reference](#secret-reference), [proxy configuration](#https-proxy), and [TLS certificates](#certificate-secret-reference).

Expand Down
16 changes: 14 additions & 2 deletions docs/spec/v1beta3/providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -1269,9 +1269,21 @@ stringData:
When `.spec.type` is set to `otel`, the controller will send distributed tracing data for
[Events](events.md#event-structure) to an OpenTelemetry (OTEL) collector endpoint specified in the [Address](#address) field.

The controller converts Flux events into OTEL spans with proper trace relationships based on the Flux object hierarchy. Source objects (GitRepository, HelmChart, OCIRepository, Bucket) create root spans, while other objects create child spans within the same trace. Each span includes event metadata as attributes and uses the alert name and namespace as the service identifier.
The controller converts Flux events into OTEL spans, one span per event, with trace relationships that mirror the Flux object hierarchy. Each span includes event metadata as attributes and uses the alert name and namespace as the service identifier.

Spans are correlated using a trace ID generated from the alert UID and revision metadata (depending on the source, the revision could be oci-digest, git commit hash, etc.). Having the following format: `<AlertUID>:<revision>`. All events from the same alert share the same trace ID, enabling end-to-end visibility across.
The parent of a span is resolved in the following order:

1. **Managing Kustomization.** If the object is managed by a Kustomization, found through the `kustomize.toolkit.fluxcd.io/name` and `kustomize.toolkit.fluxcd.io/namespace` labels (followed up to 10 levels), a source is linked to the Kustomization that manages it, and any other object to the root Kustomization when it is at the same revision.
2. **Related object.** Otherwise, the span is linked to the `involvedObject`'s related object, i.e. the `.relatedObject` field of the [Event](events.md#event-structure), when the controller that emitted the event sets it. Its UID is used as is.
3. **Cluster lookup.** Only when the event has no related object, the controller falls back to reading the object an event is about from the cluster, to find the object it is built from: a Kustomization's source, a HelmRelease's `.spec.chartRef` or the HelmChart generated for its `.spec.chart`.

All the spans that belong to the same revision flow share the same trace ID. It is derived from the alert UID and the revision at the root of the hierarchy (depending on the source, the revision could be oci-digest, git commit hash, etc.), having the following format: `<AlertUID>:<revision>`. When an object is managed by one or more Kustomizations, the revision is the one of the root Kustomization. Events that carry no revision, and events for which none can be resolved, are not grouped and get a trace of their own.

A source that is managed by a Kustomization which also reconciles that very source, as in the `flux bootstrap` topology (the `flux-system` GitRepository and Kustomization), is the root of the trace of its own revision. The Kustomization becomes its child instead of the other way around, and the source is not placed in the trace of the Kustomization's previous revision.

The span ID of an object at a given revision is derived from the object UID and the revision, so that spans of child objects can reference it as their parent. Consequently, events of the same object and revision share the span ID, and backends may merge them.

Finding the managing Kustomization and the cluster lookup are live `get` requests, which require `get` permissions on Kustomizations, HelmReleases and the source kinds. Objects that can't be read are left out of the trace without raising an error. When cross-namespace references are blocked (`--no-cross-namespace-refs`), only objects in the namespace of the Alert are read, so the hierarchy stops at the namespace boundary.

This Provider type supports authentication via [Secret reference](#secret-reference), [proxy configuration](#https-proxy), and [TLS certificates](#certificate-secret-reference).

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.47.0
go.opentelemetry.io/otel/sdk v1.47.0
go.opentelemetry.io/otel/trace v1.47.0
go.opentelemetry.io/proto/otlp v1.11.0
golang.org/x/oauth2 v0.37.0
golang.org/x/text v0.43.0
google.golang.org/api v0.308.0
google.golang.org/protobuf v1.36.12
k8s.io/api v0.37.1
k8s.io/apimachinery v0.37.1
k8s.io/client-go v0.37.1
Expand Down Expand Up @@ -195,7 +197,6 @@ require (
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.72.0 // indirect
go.opentelemetry.io/otel/log v1.47.0 // indirect
go.opentelemetry.io/otel/metric v1.47.0 // indirect
go.opentelemetry.io/proto/otlp v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.28.0 // indirect
go.yaml.in/yaml/v2 v2.4.4 // indirect
Expand All @@ -213,7 +214,6 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20260928230214-8a89bd6388cc // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20261019180522-ce908d29299b // indirect
google.golang.org/grpc v1.84.0 // indirect
google.golang.org/protobuf v1.36.12 // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
1 change: 1 addition & 0 deletions internal/notifier/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ func testEvent() eventv1.Event {
Severity: "info",
Timestamp: metav1.Now(),
Message: "message",
Action: "action",
Reason: "reason",
Metadata: map[string]string{
"test": "metadata",
Expand Down
28 changes: 25 additions & 3 deletions internal/notifier/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,15 @@ type notifierOptions struct {
DefaultServiceAccount string
TokenCache *cache.TokenCache
TokenClient client.Client
SPIFFEBroker fluxbroker.Interface
EventKey string
AlertMetadata metav1.ObjectMeta
// APIReader is a live (uncached) reader used by notifiers that need to
// look up other objects in the cluster.
APIReader client.Reader
// NoCrossNamespaceRefs restricts the lookups made through APIReader to
// the namespace of the Alert that triggered the notification.
NoCrossNamespaceRefs bool
SPIFFEBroker fluxbroker.Interface
EventKey string
AlertMetadata metav1.ObjectMeta
}

// Option represents a functional option for configuring a notifier.
Expand Down Expand Up @@ -233,6 +239,22 @@ func WithTokenClient(kubeClient client.Client) Option {
}
}

// WithAPIReader sets the live (uncached) reader used by notifiers to look up
// other objects in the cluster.
func WithAPIReader(reader client.Reader) Option {
return func(o *notifierOptions) {
o.APIReader = reader
}
}

// WithNoCrossNamespaceRefs restricts the lookups made by the notifier to the
// namespace of the Alert that triggered the notification.
func WithNoCrossNamespaceRefs(enabled bool) Option {
return func(o *notifierOptions) {
o.NoCrossNamespaceRefs = enabled
}
}

// WithServiceAccount sets the service account for the notifier.
func WithServiceAccount(serviceAccountName string) Option {
return func(o *notifierOptions) {
Expand Down
2 changes: 1 addition & 1 deletion internal/notifier/forwarder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestForwarder_Post(t *testing.T) {
{
name: "non-empty HMAC key adds signature header",
hmacKey: []byte("7152fed34dd6149a7c75a276c510da27cb6f82b0"),
hmacHeader: "sha256=2662a6dd1a887c05183aa5b9787d5ed92116199f09c7b3c7908ee3bd20bc60d9",
hmacHeader: "sha256=729978305ae46dfeab8809036d6793410364071039d6be3f69bac6f7e052e635",
xSigHeader: "should be overwritten with actual signature",
},
}
Expand Down
Loading