2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. 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.vid.logging;
24 import org.apache.http.HttpMessage;
25 import org.apache.http.HttpRequest;
26 import org.apache.http.HttpResponse;
27 import org.onap.logging.filter.base.AbstractMetricLogFilter;
30 public abstract class ApacheClientMetricInterceptor extends AbstractMetricLogFilter<HttpRequest, HttpResponse, HttpMessage> {
33 protected void addHeader(HttpMessage httpMessage, String headerName, String headerValue) {
34 httpMessage.addHeader(headerName, headerValue);
38 protected String getTargetServiceName(HttpRequest httpRequest) {
39 return httpRequest.getRequestLine().getUri();
43 protected String getServiceName(HttpRequest httpRequest) {
44 return URI.create(httpRequest.getRequestLine().getUri()).getPath();
48 protected int getHttpStatusCode(HttpResponse httpResponse) {
49 return httpResponse.getStatusLine().getStatusCode();
53 protected String getResponseCode(HttpResponse httpResponse) {
54 return String.valueOf(httpResponse.getStatusLine().getStatusCode());
58 protected String getTargetEntity(HttpRequest httpRequest) {
59 //fallback to default value that provided by AbstractMetricLogFilter