File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change 1414 * limitations under the License.
1515 */
1616
17- use arc_swap:: ArcSwap ;
1817use once_cell:: sync:: Lazy ;
1918use prometheus:: { IntCounterVec , IntGaugeVec , Registry } ;
2019
@@ -23,20 +22,20 @@ pub(crate) const CONTROL_PLANE_LABEL: &str = "control_plane";
2322pub ( crate ) const TYPE_LABEL : & str = "type" ;
2423
2524/// TODO: Remove and replace with a local registry.
26- static REGISTRY : Lazy < ArcSwap < Registry > > = Lazy :: new ( || {
27- ArcSwap :: new ( std:: sync:: Arc :: new (
28- Registry :: new_custom ( Some ( "quilkin" . into ( ) ) , None ) . unwrap ( ) ,
29- ) )
30- } ) ;
25+ static REGISTRY_ONCE : parking_lot:: Once = parking_lot:: Once :: new ( ) ;
26+ static mut REGISTRY : Option < & ' static Registry > = None ;
3127
3228/// Sets the [`Registry`] containing all the metrics registered in xDS.
33- pub fn set_registry ( registry : std:: sync:: Arc < Registry > ) {
34- REGISTRY . store ( registry) ;
29+ pub fn set_registry ( registry : & ' static Registry ) {
30+ REGISTRY_ONCE . call_once ( || unsafe {
31+ REGISTRY = Some ( registry) ;
32+ } ) ;
3533}
3634
3735/// Returns the [`Registry`] containing all the metrics registered in xDS.
38- pub fn registry ( ) -> arc_swap:: Guard < std:: sync:: Arc < Registry > > {
39- REGISTRY . load ( )
36+ #[ inline]
37+ pub fn registry ( ) -> & ' static Registry {
38+ unsafe { REGISTRY } . expect ( "set_registry must be called" )
4039}
4140
4241pub ( crate ) fn active_control_planes ( control_plane : & str ) -> prometheus:: IntGauge {
Original file line number Diff line number Diff line change @@ -246,6 +246,8 @@ impl Service {
246246 config : & Arc < Config > ,
247247 shutdown_rx : & crate :: signal:: ShutdownRx ,
248248 ) -> crate :: Result < tokio:: task:: JoinHandle < crate :: Result < ( ) > > > {
249+ quilkin_xds:: metrics:: set_registry ( crate :: metrics:: registry ( ) ) ;
250+
249251 let mut shutdown_rx = shutdown_rx. clone ( ) ;
250252 let mds_task = self . publish_mds ( config) ?;
251253 let ( phoenix_task, phoenix_finalizer) = self . publish_phoenix ( config) ?;
You can’t perform that action at this time.
0 commit comments