652e3541c438aa03f57ea158e5649184bd99b441
[dcaegen2/services/sdk.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * DCAEGEN2-SERVICES-SDK
4  * ================================================================================
5  * Copyright (C) 2018 NOKIA 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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.dcaegen2.services.sdk.rest.services.model.logging;
22
23 import org.slf4j.MDC;
24
25 import java.util.Map;
26
27 public final class MdcVariables {
28
29     @Deprecated
30     public static final String X_ONAP_REQUEST_ID = "X-ONAP-RequestID";
31     @Deprecated
32     public static final String X_INVOCATION_ID = "X-InvocationID";
33
34     public static final String INSTANCE_UUID = "InstanceUUID";
35     public static final String RESPONSE_CODE = "ResponseCode";
36     public static final String REQUEST_ID = "RequestID";
37     public static final String CLIENT_NAME = "PartnerName";
38     public static final String CLIENT_IP = "ClientIPAddress";
39     public static final String INVOCATION_ID = "InvocationID";
40     public static final String INVOCATION_TIMESTAMP = "InvokeTimestamp";
41     public static final String STATUS_CODE = "StatusCode";
42     public static final String INSTANCE_ID = "InstanceID";
43     public static final String SERVER_FQDN = "ServerFQDN";
44     public static final String SERVICE_NAME = "ServiceName";
45
46     private static final String HTTP_HEADER_PREFIX = "X-";
47
48     private MdcVariables() {
49     }
50
51     public static String httpHeader(String mdcName) {
52         return HTTP_HEADER_PREFIX + mdcName;
53     }
54
55     /**
56      * @deprecated use {@link RequestDiagnosticContext#withSlf4jMdc(Runnable)}.
57      * @param mdcContextMap
58      */
59     @Deprecated
60     public static void setMdcContextMap(Map<String, String> mdcContextMap) {
61         if (mdcContextMap != null) {
62             MDC.setContextMap(mdcContextMap);
63         }
64     }
65 }