2 * ========================LICENSE_START=================================
4 * ======================================================================
5 * Copyright (C) 2022 Nordix Foundation. All rights reserved.
6 * ======================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ========================LICENSE_END===================================
21 package org.onap.ccsdk.oran.a1policymanagementservice.tasks;
23 import io.micrometer.core.instrument.MeterRegistry;
24 import java.lang.invoke.MethodHandles;
25 import lombok.AccessLevel;
27 import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies;
28 import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyTypes;
29 import org.onap.ccsdk.oran.a1policymanagementservice.repository.Rics;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.stereotype.Component;
36 * The aim is to collect statistical values from the A1 Policy Management Service.
39 public class RefreshCounterTask {
41 private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
44 private final Rics rics;
47 private final PolicyTypes policyTypes;
50 private final Policies policies;
53 @Getter(AccessLevel.PUBLIC)
54 private final MeterRegistry meterRegistry;
57 public RefreshCounterTask(Rics rics, PolicyTypes policyTypes, Policies policies, MeterRegistry meterRegistry) {
59 this.policyTypes = policyTypes;
60 this.policies = policies;
61 this.meterRegistry = meterRegistry;
63 logger.trace("Counters have been initialized.");
64 meterRegistry.gauge("total_ric_count", rics, Rics::size);
65 meterRegistry.gauge("total_policy_type_count", policyTypes, PolicyTypes::size);
66 meterRegistry.gauge("total_policy_count", policies, Policies::size);