3c896b9071f013ceb23fb77884a4d135f927ab39
[clamp.git] / src / main / java / org / onap / clamp / clds / util / OnapLogConstants.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2018 AT&T Intellectual Property. All rights
6  *                             reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END============================================
20  * ===================================================================
21  *
22  */
23
24 package org.onap.clamp.clds.util;
25
26 /**
27  * Constants for standard ONAP headers, MDCs, etc.
28  */
29 public final class OnapLogConstants {
30
31     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
32     //
33     // Constructors.
34     //
35     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
36
37     /**
38      * Hide and forbid construction.
39      */
40     private OnapLogConstants() {
41         throw new UnsupportedOperationException();
42     }
43
44
45     /**
46      * Marker constants.
47      */
48     public static final class Markers {
49
50         /** Marker reporting invocation. */
51         public static final String INVOKE = "INVOKE";
52
53         /** Marker reporting synchronous invocation. */
54         public static final String INVOKE_RETURN = "INVOKE-RETURN";
55
56         /** Marker reporting synchronous invocation. */
57         public static final String INVOKE_SYNC = "INVOKE-SYNCHRONOUS";
58
59         /** Marker reporting entry into a component. */
60         public static final String ENTRY = "ENTRY";
61
62         /** Marker reporting exit from a component. */
63         public static final String EXIT = "EXIT";
64
65         /**
66          * Hide and forbid construction.
67          */
68         private Markers() {
69             throw new UnsupportedOperationException();
70         }
71     }
72
73     /**
74      * MDC name constants.
75      */
76     public static final class Mdcs {
77
78         // Tracing. ////////////////////////////////////////////////////////////
79
80         /** MDC correlating messages for an invocation. */
81         public static final String INVOCATION_ID = "InvocationID";
82
83         /** MDC correlating messages for a logical transaction. */
84         public static final String REQUEST_ID = "RequestID";
85
86         /** MDC recording calling service. */
87         public static final String PARTNER_NAME = "PartnerName";
88
89         /** MDC recording current service. */
90         public static final String SERVICE_NAME = "ServiceName";
91
92         /** MDC recording target service. */
93         public static final String TARGET_SERVICE_NAME = "TargetServiceName";
94
95         /** MDC recording InvocationID Out. */
96         public static final String INVOCATIONID_OUT = "InvocationIDOut";
97
98         /** MDC recording target entity. */
99         public static final String TARGET_ENTITY = "TargetEngity";
100
101         /** MDC recording current service instance. */
102         public static final String INSTANCE_UUID = "InstanceUUID";
103
104         // Network. ////////////////////////////////////////////////////////////
105
106         /** MDC recording caller address. */
107         public static final String CLIENT_IP_ADDRESS = "ClientIPAddress";
108
109         /** MDC recording server address. */
110         public static final String SERVER_FQDN = "ServerFQDN";
111
112         /**
113          * MDC recording timestamp at the start of the current request,
114          * with the same scope as {@link #REQUEST_ID}.
115          *
116          * <p>Open issues:
117          * <ul>
118          *     <ul>Easily confused with {@link #INVOKE_TIMESTAMP}.</ul>
119          *     <ul>No mechanism for propagation between components, e.g. via HTTP headers.</ul>
120          *     <ul>Whatever mechanism we define, it's going to be costly.</ul>
121          * </ul>
122          * </p>
123          * */
124         public static final String ENTRY_TIMESTAMP = "EntryTimestamp";
125         public static final String END_TIMESTAMP = "EndTimestamp";
126         public static final String ELAPSED_TIMESTAMP = "ElapsedTime";
127         /** MDC recording timestamp at the start of the current invocation. */
128         public static final String INVOKE_TIMESTAMP = "InvokeTimestamp";
129
130         // Outcomes. ///////////////////////////////////////////////////////////
131
132         /** MDC reporting outcome code. */
133         public static final String RESPONSE_CODE = "ResponseCode";
134
135         /** MDC reporting outcome description. */
136         public static final String RESPONSE_DESCRIPTION = "ResponseDescription";
137
138         /** MDC reporting outcome error level. */
139         public static final String RESPONSE_SEVERITY = "Severity";
140
141         /** MDC reporting outcome error level. */
142         public static final String RESPONSE_STATUS_CODE = "StatusCode";
143
144         // Unsorted. ///////////////////////////////////////////////////////////
145
146         /**
147          * Hide and forbid construction.
148          */
149         private Mdcs() {
150             throw new UnsupportedOperationException();
151         }
152     }
153
154     /**
155      * Header name constants.
156      */
157     public static final class Headers {
158
159         /** HTTP <tt>X-ONAP-RequestID</tt> header. */
160         public static final String REQUEST_ID = "X-ONAP-RequestID";
161
162         /** HTTP <tt>X-ONAP-InvocationID</tt> header. */
163         public static final String INVOCATION_ID = "X-ONAP-InvocationID";
164
165         /** HTTP <tt>X-ONAP-PartnerName</tt> header. */
166         public static final String PARTNER_NAME = "X-ONAP-PartnerName";
167
168         /**
169          * Hide and forbid construction.
170          */
171         private Headers() {
172             throw new UnsupportedOperationException();
173         }
174     }
175
176     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
177     //
178     // Enums.
179     //
180     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
181
182     /**
183      * Response success or not, for setting <tt>StatusCode</tt>.
184      */
185     public enum ResponseStatus {
186
187         /** Success. */
188         COMPLETED,
189
190         /** Not. */
191         ERROR,
192     }
193 }