@@ -18,6 +18,8 @@ package gorch
1818
1919import (
2020 "context"
21+ "github.com/trustyai-explainability/trustyai-service-operator/controllers/metrics"
22+ "strconv"
2123 "time"
2224
2325 routev1 "github.com/openshift/api/route/v1"
@@ -67,6 +69,19 @@ func ControllerSetUp(mgr manager.Manager, ns, configmap string, recorder record.
6769 }).SetupWithManager (mgr )
6870}
6971
72+ // createOrchestratorCreationMetrics collects and publishes metrics related to new-created Guardrails Orchestrators
73+ func createOrchestratorCreationMetrics (orchestrator * gorchv1alpha1.GuardrailsOrchestrator ) {
74+ // Update the Prometheus metrics for each task in the tasklist
75+ labels := make (map [string ]string )
76+ labels ["orchestrator_namespace" ] = orchestrator .Namespace
77+ labels ["using_built_in_detectors" ] = strconv .FormatBool (orchestrator .Spec .EnableBuiltInDetectors )
78+ labels ["using_sidecar_gateway" ] = strconv .FormatBool (orchestrator .Spec .SidecarGatewayConfig != nil )
79+
80+ // create/update metric counter
81+ counter := metrics .GetOrCreateGuardrailsOrchestratorCounter (labels )
82+ counter .Inc ()
83+ }
84+
7085// Reconcile is part of the main kubernetes reconciliation loop which aims to
7186// move the current state of the cluster closer to the desired state.
7287// TODO(user): Modify the Reconcile function to compare the state specified by
@@ -103,6 +118,8 @@ func (r *GuardrailsOrchestratorReconciler) Reconcile(ctx context.Context, req ct
103118 log .Error (err , "Failed to update GuardrailsOrchestrator status during initialization" )
104119 return ctrl.Result {}, err
105120 }
121+
122+ createOrchestratorCreationMetrics (orchestrator )
106123 }
107124
108125 if ! controllerutil .ContainsFinalizer (orchestrator , finalizerName ) {
0 commit comments