Skip to content
Merged
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
7 changes: 7 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

"github.com/kuadrant/policy-machinery/controller"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
"go.uber.org/zap/zapcore"

certmanv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
Expand Down Expand Up @@ -167,6 +168,12 @@ func main() {
"sampler", "AlwaysSample",
)

// Set global propagator for distributed tracing
otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(
propagation.TraceContext{},
propagation.Baggage{},
))

// Set as global tracer provider
otel.SetTracerProvider(traceProvider.TracerProvider())

Expand Down
8 changes: 6 additions & 2 deletions internal/controller/authconfigs_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/kuadrant/policy-machinery/controller"
"github.com/kuadrant/policy-machinery/machinery"
"github.com/samber/lo"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
k8stypes "k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -83,7 +85,7 @@ func (r *AuthConfigsReconciler) Reconcile(ctx context.Context, _ []controller.Re
httpRouteRuleKey := httpRouteRule.Name

authConfigName := AuthConfigNameForPath(pathID)
desiredAuthConfig := r.buildDesiredAuthConfig(effectivePolicy, authConfigName, authConfigsNamespace)
desiredAuthConfig := r.buildDesiredAuthConfig(ctx, effectivePolicy, authConfigName, authConfigsNamespace)
desiredAuthConfigs[k8stypes.NamespacedName{Name: desiredAuthConfig.GetName(), Namespace: desiredAuthConfig.GetNamespace()}] = struct{}{}

resource := r.client.Resource(kuadrantauthorino.AuthConfigsResource).Namespace(desiredAuthConfig.GetNamespace())
Expand Down Expand Up @@ -159,7 +161,7 @@ func (r *AuthConfigsReconciler) Reconcile(ctx context.Context, _ []controller.Re
return nil
}

func (r *AuthConfigsReconciler) buildDesiredAuthConfig(effectivePolicy EffectiveAuthPolicy, name, namespace string) *authorinov1beta3.AuthConfig {
func (r *AuthConfigsReconciler) buildDesiredAuthConfig(ctx context.Context, effectivePolicy EffectiveAuthPolicy, name, namespace string) *authorinov1beta3.AuthConfig {
_, _, _, _, httpRouteRule, _ := kuadrantpolicymachinery.ObjectsInRequestPath(effectivePolicy.Path)

authConfig := &authorinov1beta3.AuthConfig{
Expand All @@ -180,6 +182,8 @@ func (r *AuthConfigsReconciler) buildDesiredAuthConfig(effectivePolicy Effective
},
}

otel.GetTextMapPropagator().Inject(ctx, propagation.MapCarrier(authConfig.Annotations))

spec := effectivePolicy.Spec.Spec.Proper()

// named patterns
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/limitador_limits_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/kuadrant/policy-machinery/controller"
"github.com/kuadrant/policy-machinery/machinery"
"github.com/samber/lo"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
k8stypes "k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/dynamic"
Expand Down Expand Up @@ -61,6 +63,12 @@ func (r *LimitadorLimitsReconciler) Reconcile(ctx context.Context, _ []controlle

state.Store(StateLimitadorLimitsModified, true)

if limitador.Annotations == nil {
limitador.Annotations = make(map[string]string)
}

otel.GetTextMapPropagator().Inject(ctx, propagation.MapCarrier(limitador.Annotations))
Copy link
Contributor Author

@KevFan KevFan Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only setting annotation here. Did not also set the annotation at limitador reconciler at:

limitador := &limitadorv1alpha1.Limitador{
TypeMeta: metav1.TypeMeta{
Kind: "Limitador",
APIVersion: "limitador.kuadrant.io/v1alpha1",
},
ObjectMeta: metav1.ObjectMeta{
Name: kuadrant.LimitadorName,
Namespace: kobj.Namespace,
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: kobj.GroupVersionKind().GroupVersion().String(),
Kind: kobj.GroupVersionKind().Kind,
Name: kobj.Name,
UID: kobj.UID,
BlockOwnerDeletion: ptr.To(true),
Controller: ptr.To(true),
},
},
},
Spec: limitadorv1alpha1.LimitadorSpec{
MetricLabelsDefault: ptr.To("descriptors[1]"),
},
}

since if we apply the annotation at both these places, one will override the other and cause a reconcile loop. Maybe this is a non-issue since I'm guessing we only care about tracing the reconcile of the limitador limits portion.

But I wonder if we should/want to merge the reconcilers for limitador creation and the limitador limits

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's a good point, I do tend to agree we probably only care about limit reconciles but it does open up the question of why we have both


limitador.Spec.Limits = desiredLimits

obj, err := controller.Destruct(limitador)
Expand Down
Loading