|
22 | 22 | import javax.ws.rs.core.Response.Status;
|
23 | 23 |
|
24 | 24 | import io.micrometer.core.instrument.Tag;
|
| 25 | +import io.micrometer.core.instrument.binder.http.Outcome; |
25 | 26 | import io.micrometer.core.instrument.util.StringUtils;
|
26 | 27 | import org.glassfish.jersey.server.ContainerRequest;
|
27 | 28 | import org.glassfish.jersey.server.ContainerResponse;
|
@@ -49,18 +50,6 @@ public final class JerseyTags {
|
49 | 50 |
|
50 | 51 | private static final Tag STATUS_SERVER_ERROR = Tag.of("status", String.valueOf(Status.INTERNAL_SERVER_ERROR.getStatusCode()));
|
51 | 52 |
|
52 |
| - private static final Tag OUTCOME_UNKNOWN = Tag.of("outcome", "UNKNOWN"); |
53 |
| - |
54 |
| - private static final Tag OUTCOME_INFORMATIONAL = Tag.of("outcome", "INFORMATIONAL"); |
55 |
| - |
56 |
| - private static final Tag OUTCOME_SUCCESS = Tag.of("outcome", "SUCCESS"); |
57 |
| - |
58 |
| - private static final Tag OUTCOME_REDIRECTION = Tag.of("outcome", "REDIRECTION"); |
59 |
| - |
60 |
| - private static final Tag OUTCOME_CLIENT_ERROR = Tag.of("outcome", "CLIENT_ERROR"); |
61 |
| - |
62 |
| - private static final Tag OUTCOME_SERVER_ERROR = Tag.of("outcome", "SERVER_ERROR"); |
63 |
| - |
64 | 53 | private static final Tag METHOD_UNKNOWN = Tag.of("method", "UNKNOWN");
|
65 | 54 |
|
66 | 55 | private static final Pattern TRAILING_SLASH_PATTERN = Pattern.compile("/$");
|
@@ -170,29 +159,10 @@ public static Tag exception(RequestEvent event) {
|
170 | 159 | */
|
171 | 160 | public static Tag outcome(ContainerResponse response) {
|
172 | 161 | if (response != null) {
|
173 |
| - int status = response.getStatus(); |
174 |
| - switch (Response.Status.Family.familyOf(status)) { |
175 |
| - case INFORMATIONAL: |
176 |
| - return OUTCOME_INFORMATIONAL; |
177 |
| - |
178 |
| - case SUCCESSFUL: |
179 |
| - return OUTCOME_SUCCESS; |
180 |
| - |
181 |
| - case REDIRECTION: |
182 |
| - return OUTCOME_REDIRECTION; |
183 |
| - |
184 |
| - case CLIENT_ERROR: |
185 |
| - return OUTCOME_CLIENT_ERROR; |
186 |
| - |
187 |
| - case SERVER_ERROR: |
188 |
| - return OUTCOME_SERVER_ERROR; |
189 |
| - |
190 |
| - default: |
191 |
| - return OUTCOME_UNKNOWN; |
192 |
| - } |
| 162 | + return Outcome.forStatus(response.getStatus()).asTag(); |
193 | 163 | }
|
194 | 164 | /* In case there is no response we are dealing with an unmapped exception. */
|
195 |
| - return OUTCOME_SERVER_ERROR; |
| 165 | + return Outcome.SERVER_ERROR.asTag(); |
196 | 166 | }
|
197 | 167 |
|
198 | 168 | }
|
0 commit comments