4
4
import lombok .Data ;
5
5
import lombok .SneakyThrows ;
6
6
import lombok .extern .slf4j .Slf4j ;
7
- import no .nav .common .metrics .Event ;
8
- import no .nav .common .metrics .MetricsClient ;
9
7
import no .nav .common .rest .client .RestUtils ;
10
8
import no .nav .pto .veilarbportefolje .opensearch .domene .OpensearchClientConfig ;
11
9
import okhttp3 .OkHttpClient ;
23
21
public class OpensearchCountService {
24
22
private final OpensearchClientConfig opensearchClientConfig ;
25
23
private final String indexName ;
26
- private final MetricsClient metricsClient ;
27
24
private final OkHttpClient client ;
28
25
29
26
@ Autowired
30
27
public OpensearchCountService (
31
28
OpensearchClientConfig opensearchClientConfig ,
32
- IndexName opensearchIndex ,
33
- MetricsClient metricsClient
29
+ IndexName opensearchIndex
34
30
) {
35
31
this .opensearchClientConfig = opensearchClientConfig ;
36
- this .metricsClient = metricsClient ;
37
32
this .indexName = opensearchIndex .getValue ();
38
33
client = baseClient ();
39
34
}
@@ -49,22 +44,13 @@ public long getCount() {
49
44
50
45
try (Response response = client .newCall (request ).execute ()) {
51
46
RestUtils .throwIfNotSuccessful (response );
52
- long count = RestUtils .parseJsonResponse (response , CountResponse .class )
47
+
48
+ return RestUtils .parseJsonResponse (response , CountResponse .class )
53
49
.map (CountResponse ::getCount )
54
50
.orElse (0L );
55
-
56
- reportDocCountToInfluxdb (count );
57
- return count ;
58
51
}
59
52
}
60
53
61
- private void reportDocCountToInfluxdb (long count ) {
62
- Event event = new Event ("portefolje.antall.brukere" );
63
- event .addFieldToReport ("antall_brukere" , count );
64
-
65
- metricsClient .report (event );
66
- }
67
-
68
54
public static String createAbsoluteUrl (OpensearchClientConfig config , String indexName ) {
69
55
return String .format ("%s%s/" ,
70
56
createAbsoluteUrl (config ),
0 commit comments