pprofextended.proto 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. // Copyright 2023, OpenTelemetry Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. // This file includes work covered by the following copyright and permission notices:
  16. //
  17. // Copyright 2016 Google Inc. All Rights Reserved.
  18. //
  19. // Licensed under the Apache License, Version 2.0 (the "License");
  20. // you may not use this file except in compliance with the License.
  21. // You may obtain a copy of the License at
  22. //
  23. // http://www.apache.org/licenses/LICENSE-2.0
  24. //
  25. // Unless required by applicable law or agreed to in writing, software
  26. // distributed under the License is distributed on an "AS IS" BASIS,
  27. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  28. // See the License for the specific language governing permissions and
  29. // limitations under the License.
  30. // Profile is a common stacktrace profile format.
  31. //
  32. // Measurements represented with this format should follow the
  33. // following conventions:
  34. //
  35. // - Consumers should treat unset optional fields as if they had been
  36. // set with their default value.
  37. //
  38. // - When possible, measurements should be stored in "unsampled" form
  39. // that is most useful to humans. There should be enough
  40. // information present to determine the original sampled values.
  41. //
  42. // - On-disk, the serialized proto must be gzip-compressed.
  43. //
  44. // - The profile is represented as a set of samples, where each sample
  45. // references a sequence of locations, and where each location belongs
  46. // to a mapping.
  47. // - There is a N->1 relationship from sample.location_id entries to
  48. // locations. For every sample.location_id entry there must be a
  49. // unique Location with that index.
  50. // - There is an optional N->1 relationship from locations to
  51. // mappings. For every nonzero Location.mapping_id there must be a
  52. // unique Mapping with that index.
  53. syntax = "proto3";
  54. package opentelemetry.proto.profiles.v1experimental;
  55. import "opentelemetry/proto/common/v1/common.proto";
  56. option csharp_namespace = "OpenTelemetry.Proto.Profiles.V1Experimental";
  57. option java_multiple_files = true;
  58. option java_package = "io.opentelemetry.proto.profiles.v1experimental";
  59. option go_package = "go.opentelemetry.io/proto/otlp/profiles/v1experimental";
  60. // Represents a complete profile, including sample types, samples,
  61. // mappings to binaries, locations, functions, string table, and additional metadata.
  62. message Profile {
  63. // A description of the samples associated with each Sample.value.
  64. // For a cpu profile this might be:
  65. // [["cpu","nanoseconds"]] or [["wall","seconds"]] or [["syscall","count"]]
  66. // For a heap profile, this might be:
  67. // [["allocations","count"], ["space","bytes"]],
  68. // If one of the values represents the number of events represented
  69. // by the sample, by convention it should be at index 0 and use
  70. // sample_type.unit == "count".
  71. repeated ValueType sample_type = 1;
  72. // The set of samples recorded in this profile.
  73. repeated Sample sample = 2;
  74. // Mapping from address ranges to the image/binary/library mapped
  75. // into that address range. mapping[0] will be the main binary.
  76. repeated Mapping mapping = 3;
  77. // Locations referenced by samples via location_indices.
  78. repeated Location location = 4;
  79. // Array of locations referenced by samples.
  80. repeated int64 location_indices = 15;
  81. // Functions referenced by locations.
  82. repeated Function function = 5;
  83. // Lookup table for attributes.
  84. repeated opentelemetry.proto.common.v1.KeyValue attribute_table = 16;
  85. // Represents a mapping between Attribute Keys and Units.
  86. repeated AttributeUnit attribute_units = 17;
  87. // Lookup table for links.
  88. repeated Link link_table = 18;
  89. // A common table for strings referenced by various messages.
  90. // string_table[0] must always be "".
  91. repeated string string_table = 6;
  92. // frames with Function.function_name fully matching the following
  93. // regexp will be dropped from the samples, along with their successors.
  94. int64 drop_frames = 7; // Index into string table.
  95. // frames with Function.function_name fully matching the following
  96. // regexp will be kept, even if it matches drop_frames.
  97. int64 keep_frames = 8; // Index into string table.
  98. // The following fields are informational, do not affect
  99. // interpretation of results.
  100. // Time of collection (UTC) represented as nanoseconds past the epoch.
  101. int64 time_nanos = 9;
  102. // Duration of the profile, if a duration makes sense.
  103. int64 duration_nanos = 10;
  104. // The kind of events between sampled occurrences.
  105. // e.g [ "cpu","cycles" ] or [ "heap","bytes" ]
  106. ValueType period_type = 11;
  107. // The number of events between sampled occurrences.
  108. int64 period = 12;
  109. // Free-form text associated with the profile. The text is displayed as is
  110. // to the user by the tools that read profiles (e.g. by pprof). This field
  111. // should not be used to store any machine-readable information, it is only
  112. // for human-friendly content. The profile must stay functional if this field
  113. // is cleaned.
  114. repeated int64 comment = 13; // Indices into string table.
  115. // Index into the string table of the type of the preferred sample
  116. // value. If unset, clients should default to the last sample value.
  117. int64 default_sample_type = 14;
  118. }
  119. // Represents a mapping between Attribute Keys and Units.
  120. message AttributeUnit {
  121. // Index into string table.
  122. int64 attribute_key = 1;
  123. // Index into string table.
  124. int64 unit = 2;
  125. }
  126. // A pointer from a profile Sample to a trace Span.
  127. // Connects a profile sample to a trace span, identified by unique trace and span IDs.
  128. message Link {
  129. // A unique identifier of a trace that this linked span is part of. The ID is a
  130. // 16-byte array.
  131. bytes trace_id = 1;
  132. // A unique identifier for the linked span. The ID is an 8-byte array.
  133. bytes span_id = 2;
  134. }
  135. // Specifies the method of aggregating metric values, either DELTA (change since last report)
  136. // or CUMULATIVE (total since a fixed start time).
  137. enum AggregationTemporality {
  138. /* UNSPECIFIED is the default AggregationTemporality, it MUST not be used. */
  139. AGGREGATION_TEMPORALITY_UNSPECIFIED = 0;
  140. /** DELTA is an AggregationTemporality for a profiler which reports
  141. changes since last report time. Successive metrics contain aggregation of
  142. values from continuous and non-overlapping intervals.
  143. The values for a DELTA metric are based only on the time interval
  144. associated with one measurement cycle. There is no dependency on
  145. previous measurements like is the case for CUMULATIVE metrics.
  146. For example, consider a system measuring the number of requests that
  147. it receives and reports the sum of these requests every second as a
  148. DELTA metric:
  149. 1. The system starts receiving at time=t_0.
  150. 2. A request is received, the system measures 1 request.
  151. 3. A request is received, the system measures 1 request.
  152. 4. A request is received, the system measures 1 request.
  153. 5. The 1 second collection cycle ends. A metric is exported for the
  154. number of requests received over the interval of time t_0 to
  155. t_0+1 with a value of 3.
  156. 6. A request is received, the system measures 1 request.
  157. 7. A request is received, the system measures 1 request.
  158. 8. The 1 second collection cycle ends. A metric is exported for the
  159. number of requests received over the interval of time t_0+1 to
  160. t_0+2 with a value of 2. */
  161. AGGREGATION_TEMPORALITY_DELTA = 1;
  162. /** CUMULATIVE is an AggregationTemporality for a profiler which
  163. reports changes since a fixed start time. This means that current values
  164. of a CUMULATIVE metric depend on all previous measurements since the
  165. start time. Because of this, the sender is required to retain this state
  166. in some form. If this state is lost or invalidated, the CUMULATIVE metric
  167. values MUST be reset and a new fixed start time following the last
  168. reported measurement time sent MUST be used.
  169. For example, consider a system measuring the number of requests that
  170. it receives and reports the sum of these requests every second as a
  171. CUMULATIVE metric:
  172. 1. The system starts receiving at time=t_0.
  173. 2. A request is received, the system measures 1 request.
  174. 3. A request is received, the system measures 1 request.
  175. 4. A request is received, the system measures 1 request.
  176. 5. The 1 second collection cycle ends. A metric is exported for the
  177. number of requests received over the interval of time t_0 to
  178. t_0+1 with a value of 3.
  179. 6. A request is received, the system measures 1 request.
  180. 7. A request is received, the system measures 1 request.
  181. 8. The 1 second collection cycle ends. A metric is exported for the
  182. number of requests received over the interval of time t_0 to
  183. t_0+2 with a value of 5.
  184. 9. The system experiences a fault and loses state.
  185. 10. The system recovers and resumes receiving at time=t_1.
  186. 11. A request is received, the system measures 1 request.
  187. 12. The 1 second collection cycle ends. A metric is exported for the
  188. number of requests received over the interval of time t_1 to
  189. t_1+1 with a value of 1.
  190. Note: Even though, when reporting changes since last report time, using
  191. CUMULATIVE is valid, it is not recommended. */
  192. AGGREGATION_TEMPORALITY_CUMULATIVE = 2;
  193. }
  194. // ValueType describes the type and units of a value, with an optional aggregation temporality.
  195. message ValueType {
  196. int64 type = 1; // Index into string table.
  197. int64 unit = 2; // Index into string table.
  198. AggregationTemporality aggregation_temporality = 3;
  199. }
  200. // Each Sample records values encountered in some program
  201. // context. The program context is typically a stack trace, perhaps
  202. // augmented with auxiliary information like the thread-id, some
  203. // indicator of a higher level request being handled etc.
  204. message Sample {
  205. // The indices recorded here correspond to locations in Profile.location.
  206. // The leaf is at location_index[0]. [deprecated, superseded by locations_start_index / locations_length]
  207. repeated uint64 location_index = 1;
  208. // locations_start_index along with locations_length refers to to a slice of locations in Profile.location.
  209. // Supersedes location_index.
  210. uint64 locations_start_index = 7;
  211. // locations_length along with locations_start_index refers to a slice of locations in Profile.location.
  212. // Supersedes location_index.
  213. uint64 locations_length = 8;
  214. // A 128bit id that uniquely identifies this stacktrace, globally. Index into string table. [optional]
  215. uint32 stacktrace_id_index = 9;
  216. // The type and unit of each value is defined by the corresponding
  217. // entry in Profile.sample_type. All samples must have the same
  218. // number of values, the same as the length of Profile.sample_type.
  219. // When aggregating multiple samples into a single sample, the
  220. // result has a list of values that is the element-wise sum of the
  221. // lists of the originals.
  222. repeated int64 value = 2;
  223. // label includes additional context for this sample. It can include
  224. // things like a thread id, allocation size, etc.
  225. //
  226. // NOTE: While possible, having multiple values for the same label key is
  227. // strongly discouraged and should never be used. Most tools (e.g. pprof) do
  228. // not have good (or any) support for multi-value labels. And an even more
  229. // discouraged case is having a string label and a numeric label of the same
  230. // name on a sample. Again, possible to express, but should not be used.
  231. // [deprecated, superseded by attributes]
  232. repeated Label label = 3;
  233. // References to attributes in Profile.attribute_table. [optional]
  234. repeated uint64 attributes = 10;
  235. // Reference to link in Profile.link_table. [optional]
  236. uint64 link = 12;
  237. // Timestamps associated with Sample represented in nanoseconds. These timestamps are expected
  238. // to fall within the Profile's time range. [optional]
  239. repeated uint64 timestamps_unix_nano = 13;
  240. }
  241. // Provides additional context for a sample,
  242. // such as thread ID or allocation size, with optional units. [deprecated]
  243. message Label {
  244. int64 key = 1; // Index into string table
  245. // At most one of the following must be present
  246. int64 str = 2; // Index into string table
  247. int64 num = 3;
  248. // Should only be present when num is present.
  249. // Specifies the units of num.
  250. // Use arbitrary string (for example, "requests") as a custom count unit.
  251. // If no unit is specified, consumer may apply heuristic to deduce the unit.
  252. // Consumers may also interpret units like "bytes" and "kilobytes" as memory
  253. // units and units like "seconds" and "nanoseconds" as time units,
  254. // and apply appropriate unit conversions to these.
  255. int64 num_unit = 4; // Index into string table
  256. }
  257. // Indicates the semantics of the build_id field.
  258. enum BuildIdKind {
  259. // Linker-generated build ID, stored in the ELF binary notes.
  260. BUILD_ID_LINKER = 0;
  261. // Build ID based on the content hash of the binary. Currently no particular
  262. // hashing approach is standardized, so a given producer needs to define it
  263. // themselves and thus unlike BUILD_ID_LINKER this kind of hash is producer-specific.
  264. // We may choose to provide a standardized stable hash recommendation later.
  265. BUILD_ID_BINARY_HASH = 1;
  266. }
  267. // Describes the mapping of a binary in memory, including its address range,
  268. // file offset, and metadata like build ID
  269. message Mapping {
  270. // Unique nonzero id for the mapping. [deprecated]
  271. uint64 id = 1;
  272. // Address at which the binary (or DLL) is loaded into memory.
  273. uint64 memory_start = 2;
  274. // The limit of the address range occupied by this mapping.
  275. uint64 memory_limit = 3;
  276. // Offset in the binary that corresponds to the first mapped address.
  277. uint64 file_offset = 4;
  278. // The object this entry is loaded from. This can be a filename on
  279. // disk for the main binary and shared libraries, or virtual
  280. // abstractions like "[vdso]".
  281. int64 filename = 5; // Index into string table
  282. // A string that uniquely identifies a particular program version
  283. // with high probability. E.g., for binaries generated by GNU tools,
  284. // it could be the contents of the .note.gnu.build-id field.
  285. int64 build_id = 6; // Index into string table
  286. // Specifies the kind of build id. See BuildIdKind enum for more details [optional]
  287. BuildIdKind build_id_kind = 11;
  288. // References to attributes in Profile.attribute_table. [optional]
  289. repeated uint64 attributes = 12;
  290. // The following fields indicate the resolution of symbolic info.
  291. bool has_functions = 7;
  292. bool has_filenames = 8;
  293. bool has_line_numbers = 9;
  294. bool has_inline_frames = 10;
  295. }
  296. // Describes function and line table debug information.
  297. message Location {
  298. // Unique nonzero id for the location. A profile could use
  299. // instruction addresses or any integer sequence as ids. [deprecated]
  300. uint64 id = 1;
  301. // The index of the corresponding profile.Mapping for this location.
  302. // It can be unset if the mapping is unknown or not applicable for
  303. // this profile type.
  304. uint64 mapping_index = 2;
  305. // The instruction address for this location, if available. It
  306. // should be within [Mapping.memory_start...Mapping.memory_limit]
  307. // for the corresponding mapping. A non-leaf address may be in the
  308. // middle of a call instruction. It is up to display tools to find
  309. // the beginning of the instruction if necessary.
  310. uint64 address = 3;
  311. // Multiple line indicates this location has inlined functions,
  312. // where the last entry represents the caller into which the
  313. // preceding entries were inlined.
  314. //
  315. // E.g., if memcpy() is inlined into printf:
  316. // line[0].function_name == "memcpy"
  317. // line[1].function_name == "printf"
  318. repeated Line line = 4;
  319. // Provides an indication that multiple symbols map to this location's
  320. // address, for example due to identical code folding by the linker. In that
  321. // case the line information above represents one of the multiple
  322. // symbols. This field must be recomputed when the symbolization state of the
  323. // profile changes.
  324. bool is_folded = 5;
  325. // Type of frame (e.g. kernel, native, python, hotspot, php). Index into string table.
  326. uint32 type_index = 6;
  327. // References to attributes in Profile.attribute_table. [optional]
  328. repeated uint64 attributes = 7;
  329. }
  330. // Details a specific line in a source code, linked to a function.
  331. message Line {
  332. // The index of the corresponding profile.Function for this line.
  333. uint64 function_index = 1;
  334. // Line number in source code.
  335. int64 line = 2;
  336. // Column number in source code.
  337. int64 column = 3;
  338. }
  339. // Describes a function, including its human-readable name, system name,
  340. // source file, and starting line number in the source.
  341. message Function {
  342. // Unique nonzero id for the function. [deprecated]
  343. uint64 id = 1;
  344. // Name of the function, in human-readable form if available.
  345. int64 name = 2; // Index into string table
  346. // Name of the function, as identified by the system.
  347. // For instance, it can be a C++ mangled name.
  348. int64 system_name = 3; // Index into string table
  349. // Source file containing the function.
  350. int64 filename = 4; // Index into string table
  351. // Line number in source file.
  352. int64 start_line = 5;
  353. }