-
Notifications
You must be signed in to change notification settings - Fork 7
/
jfrMetadata.cpp
333 lines (278 loc) · 17.2 KB
/
jfrMetadata.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
/*
* Copyright 2020 Andrei Pangin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "counters.h"
#include "jfrMetadata.h"
#include "vmEntry.h"
std::map<std::string, int> Element::_string_map;
std::vector<std::string> Element::_strings;
JfrMetadata JfrMetadata::_root;
bool JfrMetadata::_initialized = false;
JfrMetadata::JfrMetadata() : Element("root") {
}
void JfrMetadata::initialize(const std::vector<std::string>& contextAttributes) {
if (_initialized) {
return;
}
_root
<< (element("metadata")
<< type("boolean", T_BOOLEAN)
<< type("char", T_CHAR)
<< type("float", T_FLOAT)
<< type("double", T_DOUBLE)
<< type("byte", T_BYTE)
<< type("short", T_SHORT)
<< type("int", T_INT)
<< type("long", T_LONG)
<< type("java.lang.String", T_STRING)
<< (type("java.lang.Class", T_CLASS, "Java Class")
<< field("classLoader", T_CLASS_LOADER, "Class Loader", F_CPOOL)
<< field("name", T_SYMBOL, "Name", F_CPOOL)
<< field("package", T_PACKAGE, "Package", F_CPOOL)
<< field("modifiers", T_INT, "Access Modifiers"))
<< (type("java.lang.Thread", T_THREAD, "Thread")
<< field("osName", T_STRING, "OS Thread Name")
<< field("osThreadId", T_LONG, "OS Thread Id")
<< field("javaName", T_STRING, "Java Thread Name")
<< field("javaThreadId", T_LONG, "Java Thread Id"))
<< (type("jdk.types.ClassLoader", T_CLASS_LOADER, "Java Class Loader")
<< field("type", T_CLASS, "Type", F_CPOOL)
<< field("name", T_SYMBOL, "Name", F_CPOOL))
<< (type("jdk.types.FrameType", T_FRAME_TYPE, "Frame type", true)
<< field("description", T_STRING, "Description"))
<< (type("jdk.types.ThreadState", T_THREAD_STATE, "Java Thread State", true)
<< field("name", T_STRING, "Name"))
<< (type("datadog.types.ExecutionMode", T_EXECUTION_MODE, "Exeuction Mode", true)
<< field("name", T_STRING, "Name"))
<< (type("jdk.types.StackTrace", T_STACK_TRACE, "Stacktrace")
<< field("truncated", T_BOOLEAN, "Truncated")
<< field("frames", T_STACK_FRAME, "Stack Frames", F_ARRAY))
<< (type("jdk.types.StackFrame", T_STACK_FRAME)
<< field("method", T_METHOD, "Java Method", F_CPOOL)
<< field("lineNumber", T_INT, "Line Number")
<< field("bytecodeIndex", T_INT, "Bytecode Index")
<< field("type", T_FRAME_TYPE, "Frame Type", F_CPOOL))
<< (type("jdk.types.Method", T_METHOD, "Java Method")
<< field("type", T_CLASS, "Type", F_CPOOL)
<< field("name", T_SYMBOL, "Name", F_CPOOL)
<< field("descriptor", T_SYMBOL, "Descriptor", F_CPOOL)
<< field("modifiers", T_INT, "Access Modifiers")
<< field("hidden", T_BOOLEAN, "Hidden"))
<< (type("jdk.types.Package", T_PACKAGE, "Package")
<< field("name", T_SYMBOL, "Name", F_CPOOL))
<< (type("jdk.types.Symbol", T_SYMBOL, "Symbol", true)
<< field("string", T_STRING, "String"))
<< (type("profiler.types.LogLevel", T_LOG_LEVEL, "Log Level", true)
<< field("name", T_STRING, "Name"))
<< (type("profiler.types.AttributeValue", T_ATTRIBUTE_VALUE, "Value", true)
<< field("value", T_STRING, "Value"))
<< (type("profiler.types.CounterName", T_COUNTER_NAME, "Value", true)
<< field("value", T_STRING, "Value"))
<< (type("datadog.ExecutionSample", T_EXECUTION_SAMPLE, "Method CPU Profiling Sample")
<< category("Datadog", "Profiling")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("eventThread", T_THREAD, "Thread", F_CPOOL)
<< field("stackTrace", T_STACK_TRACE, "Stack Trace", F_CPOOL)
<< field("state", T_THREAD_STATE, "Thread State", F_CPOOL)
<< field("mode", T_EXECUTION_MODE, "Execution Mode", F_CPOOL)
<< field("weight", T_LONG, "Sample weight")
<< field("spanId", T_LONG, "Span ID")
<< field("localRootSpanId", T_LONG, "Local Root Span ID")
|| contextAttributes)
<< (type("datadog.MethodSample", T_METHOD_SAMPLE, "Method Wall Profiling Sample")
<< category("Datadog", "Profiling")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("eventThread", T_THREAD, "Thread", F_CPOOL)
<< field("stackTrace", T_STACK_TRACE, "Stack Trace", F_CPOOL)
<< field("state", T_THREAD_STATE, "Thread State", F_CPOOL)
<< field("mode", T_EXECUTION_MODE, "Execution Mode", F_CPOOL)
<< field("weight", T_LONG, "Sample weight")
<< field("spanId", T_LONG, "Span ID")
<< field("localRootSpanId", T_LONG, "Local Root Span ID")
|| contextAttributes)
<< (type("datadog.WallClockSamplingEpoch", T_WALLCLOCK_SAMPLE_EPOCH, "WallClock Sampling Epoch")
<< category("Datadog", "Profiling")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("duration", T_LONG, "Duration", F_DURATION_MILLIS)
<< field("samplePoolSize", T_INT, "Sample Pool Size")
<< field("numSuccessfulSamples", T_INT, "Number of Successful Samples")
<< field("numFailedSamples", T_INT, "Number of Failed Samples")
<< field("numExitedThreads", T_INT, "Number of Exited Threads Before Handling Signal")
<< field("numPermissionDenied", T_INT, "Number of Permission Denied Errors"))
<< (type("datadog.ObjectSample", T_ALLOC, "Allocation sample")
<< category("Datadog", "Profiling")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("eventThread", T_THREAD, "Event Thread", F_CPOOL)
<< field("stackTrace", T_STACK_TRACE, "Stack Trace", F_CPOOL)
<< field("objectClass", T_CLASS, "Object Class", F_CPOOL)
<< field("size", T_LONG, "Original Size", F_BYTES)
<< field("weight", T_FLOAT, "Sample weight")
<< field("spanId", T_LONG, "Span ID")
<< field("localRootSpanId", T_LONG, "Local Root Span ID")
|| contextAttributes)
<< (type("datadog.HeapLiveObject", T_HEAP_LIVE_OBJECT, "Heap Live Object")
<< category("Datadog", "Profiling")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("eventThread", T_THREAD, "Event Thread", F_CPOOL)
<< field("stackTrace", T_STACK_TRACE, "Stack Trace", F_CPOOL)
<< field("objectClass", T_CLASS, "Object Class", F_CPOOL)
<< field("age", T_LONG, "Age", F_UNSIGNED)
<< field("size", T_LONG, "Original Size", F_BYTES)
<< field("weight", T_FLOAT, "Sample weight")
<< field("spanId", T_LONG, "Span ID")
<< field("localRootSpanId", T_LONG, "Local Root Span ID")
|| contextAttributes)
<< (type("datadog.Endpoint", T_ENDPOINT, "Endpoint")
<< category("Datadog")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("duration", T_LONG, "Duration", F_DURATION_TICKS)
<< field("eventThread", T_THREAD, "Event Thread", F_CPOOL)
<< field("stackTrace", T_STACK_TRACE, "Stack Trace", F_CPOOL)
<< field("endpoint", T_STRING, "Endpoint", F_CPOOL)
<< field("operation", T_ATTRIBUTE_VALUE, "Operation", F_CPOOL)
<< field("localRootSpanId", T_LONG, "Local Root Span ID"))
<< (type("datadog.QueueTime", T_QUEUE_TIME, "Queue Time")
<< category("Datadog")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("duration", T_LONG, "Duration", F_DURATION_TICKS)
<< field("eventThread", T_THREAD, "Event Thread", F_CPOOL)
<< field("origin", T_THREAD, "Origin Thread", F_CPOOL)
<< field("task", T_CLASS, "Task", F_CPOOL)
<< field("scheduler", T_CLASS, "Scheduler", F_CPOOL)
<< field("spanId", T_LONG, "Span ID")
<< field("localRootSpanId", T_LONG, "Local Root Span ID")
|| contextAttributes)
<< (type("datadog.HeapUsage", T_HEAP_USAGE, "JVM Heap Usage")
<< category("Datadog")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("size", T_LONG, "Current Heap Usage", F_BYTES)
<< field("isLive", T_BOOLEAN, "After GC"))
<< (type("jdk.CPULoad", T_CPU_LOAD, "CPU Load")
<< category("Operating System", "Processor")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("jvmUser", T_FLOAT, "JVM User", F_PERCENTAGE)
<< field("jvmSystem", T_FLOAT, "JVM System", F_PERCENTAGE)
<< field("machineTotal", T_FLOAT, "Machine Total", F_PERCENTAGE))
<< (type("jdk.ActiveRecording", T_ACTIVE_RECORDING, "java-profiler Recording")
<< category("Flight Recorder")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("duration", T_LONG, "Duration", F_DURATION_TICKS)
<< field("eventThread", T_THREAD, "Event Thread", F_CPOOL)
<< field("stackTrace", T_STACK_TRACE, "Stack Trace", F_CPOOL)
<< field("id", T_LONG, "Id")
<< field("name", T_STRING, "Name")
<< field("destination", T_STRING, "Destination")
<< field("maxAge", T_LONG, "Max Age", F_DURATION_MILLIS)
<< field("flushInterval", T_LONG, "Flush Interval", F_DURATION_MILLIS, VM::java_version() >= 14)
<< field("maxSize", T_LONG, "Max Size", F_BYTES)
<< field("recordingStart", T_LONG, "Start Time", F_TIME_MILLIS)
<< field("recordingDuration", T_LONG, "Recording Duration", F_DURATION_MILLIS))
<< (type("jdk.ActiveSetting", T_ACTIVE_SETTING, "java-profiler Setting")
<< category("Flight Recorder")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("duration", T_LONG, "Duration", F_DURATION_TICKS)
<< field("eventThread", T_THREAD, "Event Thread", F_CPOOL)
<< field("stackTrace", T_STACK_TRACE, "Stack Trace", F_CPOOL)
<< field("id", T_LONG, "Event Id")
<< field("name", T_STRING, "Setting Name")
<< field("value", T_STRING, "Setting Value"))
<< (type("datadog.ProfilerSetting", T_DATADOG_SETTING, "Profiler Configuration Setting")
<< category("Datadog")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("duration", T_LONG, "Duration", F_DURATION_TICKS)
<< field("eventThread", T_THREAD, "Event Thread", F_CPOOL)
<< field("stackTrace", T_STACK_TRACE, "Stack Trace", F_CPOOL)
<< field("name", T_STRING, "Setting Name")
<< field("value", T_STRING, "Setting Value")
<< field("unit", T_STRING, "Setting Unit"))
<< (type("datadog.DatadogProfilerConfig", T_DATADOG_PROFILER_CONFIG, "Datadog Profiler Configuration")
<< category("Datadog")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("duration", T_LONG, "Duration", F_DURATION_TICKS)
<< field("eventThread", T_THREAD, "Event Thread", F_CPOOL)
<< field("cpuInterval", T_LONG, "CPU Sampling Interval", F_DURATION_MILLIS)
<< field("wallInterval", T_LONG, "Wall Sampling Interval", F_DURATION_MILLIS)
<< field("allocInterval", T_LONG, "Allocation Sampling Interval", F_BYTES)
<< field("memleakInterval", T_LONG, "MemLeak Sampling Interval", F_BYTES)
<< field("memleakCapacity", T_LONG, "MemLeak Sampling Capacity")
<< field("gcGenerations", T_BOOLEAN, "GC Generations Tracking")
<< field("modeMask", T_INT, "Profiling mode bitmask")
<< field("version", T_STRING, "Version")
<< field("cpuEngine", T_STRING, "CPU Engine"))
<< (type("datadog.DatadogProfilerClassRefCache", T_DATADOG_CLASSREF_CACHE, "Datadog ClassRef Cache Stats")
<< category("Datadog")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("size", T_LONG, "Cache Size", F_BYTES))
<< (type("datadog.ProfilerCounter", T_DATADOG_COUNTER, "Datadog Profiler Internal Counter")
<< category("Datadog")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("name", T_COUNTER_NAME, "Name")
<< field("count", T_LONG, "Count"))
<< (type("jdk.OSInformation", T_OS_INFORMATION, "OS Information")
<< category("Operating System")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("osVersion", T_STRING, "OS Version"))
<< (type("jdk.CPUInformation", T_CPU_INFORMATION, "CPU Information")
<< category("Operating System", "Processor")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("cpu", T_STRING, "Type")
<< field("description", T_STRING, "Description")
<< field("sockets", T_INT, "Sockets", F_UNSIGNED)
<< field("cores", T_INT, "Cores", F_UNSIGNED)
<< field("hwThreads", T_INT, "Hardware Threads", F_UNSIGNED))
<< (type("jdk.JVMInformation", T_JVM_INFORMATION, "JVM Information")
<< category("Java Virtual Machine")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("jvmName", T_STRING, "JVM Name")
<< field("jvmVersion", T_STRING, "JVM Version")
<< field("jvmArguments", T_STRING, "JVM Command Line Arguments")
<< field("jvmFlags", T_STRING, "JVM Settings File Arguments")
<< field("javaArguments", T_STRING, "Java Application Arguments")
<< field("jvmStartTime", T_LONG, "JVM Start Time", F_TIME_MILLIS)
<< field("pid", T_LONG, "Process Identifier"))
<< (type("jdk.InitialSystemProperty", T_INITIAL_SYSTEM_PROPERTY, "Initial System Property")
<< category("Java Virtual Machine")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("key", T_STRING, "Key")
<< field("value", T_STRING, "Value"))
<< (type("jdk.NativeLibrary", T_NATIVE_LIBRARY, "Native Library")
<< category("Java Virtual Machine", "Runtime")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("name", T_STRING, "Name")
<< field("baseAddress", T_LONG, "Base Address", F_ADDRESS)
<< field("topAddress", T_LONG, "Top Address", F_ADDRESS))
<< (type("profiler.Log", T_LOG, "Log Message")
<< category("Profiler")
<< field("startTime", T_LONG, "Start Time", F_TIME_TICKS)
<< field("level", T_LOG_LEVEL, "Level", F_CPOOL)
<< field("message", T_STRING, "Message"))
<< (type("jdk.jfr.Label", T_LABEL, NULL)
<< field("value", T_STRING))
<< (type("jdk.jfr.Category", T_CATEGORY, NULL)
<< field("value", T_STRING, NULL, F_ARRAY))
<< (type("jdk.jfr.Timestamp", T_TIMESTAMP, "Timestamp")
<< field("value", T_STRING))
<< (type("jdk.jfr.Timespan", T_TIMESPAN, "Timespan")
<< field("value", T_STRING))
<< (type("jdk.jfr.DataAmount", T_DATA_AMOUNT, "Data Amount")
<< field("value", T_STRING))
<< type("jdk.jfr.MemoryAddress", T_MEMORY_ADDRESS, "Memory Address")
<< type("jdk.jfr.Unsigned", T_UNSIGNED, "Unsigned Value")
<< type("jdk.jfr.Percentage", T_PERCENTAGE, "Percentage"))
<< element("region").attribute("locale", "en_US").attribute("gmtOffset", "0");
// The map is used only during construction
_string_map.clear();
_initialized = true;
}