55 "strings"
66 "time"
77
8+ "go.opentelemetry.io/otel"
9+ "go.opentelemetry.io/otel/attribute"
10+ "go.opentelemetry.io/otel/trace"
811 corev1 "k8s.io/api/core/v1"
912 apierrors "k8s.io/apimachinery/pkg/api/errors"
1013 apimeta "k8s.io/apimachinery/pkg/api/meta"
@@ -22,6 +25,7 @@ import (
2225
2326 impdevv1alpha1 "github.com/syscode-labs/imp/api/v1alpha1"
2427 "github.com/syscode-labs/imp/internal/cnidetect"
28+ "github.com/syscode-labs/imp/internal/tracing"
2529)
2630
2731// +kubebuilder:rbac:groups=imp.dev,resources=impvms,verbs=get;list;watch
@@ -42,12 +46,19 @@ type ImpNetworkReconciler struct {
4246// +kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch
4347// +kubebuilder:rbac:groups=cilium.io,resources=ciliumexternalworkloads,verbs=get;list;watch;create;update;patch;delete
4448
45- func (r * ImpNetworkReconciler ) Reconcile (ctx context.Context , req ctrl.Request ) (ctrl.Result , error ) {
49+ func (r * ImpNetworkReconciler ) Reconcile (ctx context.Context , req ctrl.Request ) (result ctrl.Result , err error ) {
4650 net := & impdevv1alpha1.ImpNetwork {}
4751 if err := r .Get (ctx , req .NamespacedName , net ); err != nil {
4852 return ctrl.Result {}, client .IgnoreNotFound (err )
4953 }
5054
55+ ctx , span := otel .Tracer ("imp.operator" ).Start (ctx , "operator.impnetwork.reconcile" ,
56+ trace .WithAttributes (
57+ attribute .String ("net.name" , req .Name ),
58+ attribute .String ("net.namespace" , req .Namespace ),
59+ ))
60+ defer func () { tracing .RecordError (span , err ); span .End () }()
61+
5162 if ! net .DeletionTimestamp .IsZero () {
5263 return r .handleDeletion (ctx , net )
5364 }
@@ -116,7 +127,14 @@ func (r *ImpNetworkReconciler) sync(ctx context.Context, net *impdevv1alpha1.Imp
116127// reconcileVTEPTable removes stale entries from ImpNetwork.status.vtepTable.
117128// An entry is stale if no Running ImpVM with that IP exists in this namespace
118129// referencing this network. The agent is responsible for adding entries.
119- func (r * ImpNetworkReconciler ) reconcileVTEPTable (ctx context.Context , net * impdevv1alpha1.ImpNetwork ) error {
130+ func (r * ImpNetworkReconciler ) reconcileVTEPTable (ctx context.Context , net * impdevv1alpha1.ImpNetwork ) (err error ) {
131+ ctx , span := otel .Tracer ("imp.operator" ).Start (ctx , "operator.impnetwork.vtep_gc" ,
132+ trace .WithAttributes (
133+ attribute .String ("net.name" , net .Name ),
134+ attribute .String ("net.namespace" , net .Namespace ),
135+ ))
136+ defer func () { tracing .RecordError (span , err ); span .End () }()
137+
120138 if len (net .Status .VTEPTable ) == 0 {
121139 return nil
122140 }
@@ -196,7 +214,14 @@ func (r *ImpNetworkReconciler) ciliumPresent() bool {
196214// reconcileCiliumEnrollment creates CiliumExternalWorkload objects for Running VMs
197215// attached to this network, and GCs CEWs for VMs that are no longer Running.
198216// It is a no-op when Cilium is not the active CNI or its CRDs are not present.
199- func (r * ImpNetworkReconciler ) reconcileCiliumEnrollment (ctx context.Context , net * impdevv1alpha1.ImpNetwork ) error {
217+ func (r * ImpNetworkReconciler ) reconcileCiliumEnrollment (ctx context.Context , net * impdevv1alpha1.ImpNetwork ) (err error ) {
218+ ctx , span := otel .Tracer ("imp.operator" ).Start (ctx , "operator.impnetwork.cilium_enroll" ,
219+ trace .WithAttributes (
220+ attribute .String ("net.name" , net .Name ),
221+ attribute .String ("net.namespace" , net .Namespace ),
222+ ))
223+ defer func () { tracing .RecordError (span , err ); span .End () }()
224+
200225 log := logf .FromContext (ctx )
201226
202227 // Guard: only proceed when Cilium is the detected CNI and its CRDs exist.
0 commit comments