|
1 | 1 | /* |
2 | | - * Copyright (c) 2022, 2023 Oracle and/or its affiliates. |
| 2 | + * Copyright (c) 2022, 2024 Oracle and/or its affiliates. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
15 | 15 | */ |
16 | 16 | package io.helidon.microprofile.metrics; |
17 | 17 |
|
18 | | -import java.io.IOException; |
19 | | -import java.io.LineNumberReader; |
20 | | -import java.io.StringReader; |
21 | 18 | import java.util.Map; |
22 | | -import java.util.StringJoiner; |
23 | 19 | import java.util.concurrent.atomic.AtomicReference; |
24 | | -import java.util.regex.Matcher; |
25 | | -import java.util.regex.Pattern; |
26 | 20 |
|
27 | 21 | import io.helidon.microprofile.testing.junit5.AddConfig; |
28 | 22 | import io.helidon.microprofile.testing.junit5.HelidonTest; |
@@ -148,60 +142,6 @@ private JsonObject getRESTRequestJSON() { |
148 | 142 | return restRequestValue.asJsonObject(); |
149 | 143 | } |
150 | 144 |
|
151 | | - private String getRESTRequestProm() throws IOException { |
152 | | - Response metricsResponse = webTarget.path("/metrics/base") |
153 | | - .request(MediaType.TEXT_PLAIN) |
154 | | - .get(); |
155 | | - |
156 | | - assertThat("Status retrieving REST request metrics", metricsResponse.getStatus(), is(200)); |
157 | | - |
158 | | - String metrics = metricsResponse.readEntity(String.class); |
159 | | - StringJoiner sj = new StringJoiner(System.lineSeparator()); |
160 | | - LineNumberReader reader = new LineNumberReader(new StringReader(metrics)); |
161 | | - String line; |
162 | | - boolean proceed = true; |
163 | | - while (proceed) { |
164 | | - line = reader.readLine(); |
165 | | - proceed = (line != null); |
166 | | - if (proceed) { |
167 | | - if (line.startsWith("REST_request_seconds_count")) { |
168 | | - sj.add(line); |
169 | | - } |
170 | | - } |
171 | | - } |
172 | | - return sj.toString(); |
173 | | - } |
174 | | - |
175 | | - private double getRESTRequestValueForGetAsyncMethod(String prometheusOutput, |
176 | | - String valueName, |
177 | | - boolean nullOK) throws NoSuchMethodException { |
178 | | - Pattern pattern = Pattern.compile(".*?^" + valueName + "\\{([^}]+)}\\s+(\\S+).*?", |
179 | | - Pattern.MULTILINE | Pattern.DOTALL); |
180 | | - Matcher matcher = pattern.matcher(prometheusOutput); |
181 | | - |
182 | | - assertThat("Match for REST request count", matcher.matches(), is(true)); |
183 | | - // Digest the tags to make sure the class and method tags are correct. |
184 | | - String[] tags = matcher.group(1).split(","); |
185 | | - boolean foundCorrectClass = false; |
186 | | - boolean foundCorrectMethod = false; |
187 | | - |
188 | | - String expectedMethodName = HelloWorldResource.class.getMethod("getAsync", AsyncResponse.class).getName() |
189 | | - + "_" + AsyncResponse.class.getName(); |
190 | | - |
191 | | - for (String tag : tags) { |
192 | | - if (tag.isBlank()) { |
193 | | - continue; |
194 | | - } |
195 | | - String[] parts = tag.split("="); |
196 | | - foundCorrectClass |= (parts[0].equals("class") && parts[1].equals(HelloWorldResource.class.getName())); |
197 | | - foundCorrectMethod |= (parts[0].equals("method") && parts[1].equals(expectedMethodName)); |
198 | | - } |
199 | | - assertThat("Class tag correct", foundCorrectClass, is(true)); |
200 | | - assertThat("Method tag correct", foundCorrectMethod, is(true)); |
201 | | - |
202 | | - return Double.parseDouble(matcher.group(2)); |
203 | | - } |
204 | | - |
205 | 145 | private JsonValue getRESTRequestValueForGetAsyncMethod(JsonObject restRequestJson, |
206 | 146 | String valueName, |
207 | 147 | boolean nullOK) { |
|
0 commit comments