profiles.proto 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  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. syntax = "proto3";
  31. package opentelemetry.proto.profiles.v1development;
  32. import "opentelemetry/proto/common/v1/common.proto";
  33. import "opentelemetry/proto/resource/v1/resource.proto";
  34. option csharp_namespace = "OpenTelemetry.Proto.Profiles.V1Development";
  35. option java_multiple_files = true;
  36. option java_package = "io.opentelemetry.proto.profiles.v1development";
  37. option java_outer_classname = "ProfilesProto";
  38. option go_package = "go.opentelemetry.io/proto/otlp/profiles/v1development";
  39. // Relationships Diagram
  40. //
  41. // ┌──────────────────┐ LEGEND
  42. // │ ProfilesData │
  43. // └──────────────────┘ ─────▶ embedded
  44. // │
  45. // │ 1-n ─────▷ referenced by index
  46. // ▼
  47. // ┌──────────────────┐
  48. // │ ResourceProfiles │
  49. // └──────────────────┘
  50. // │
  51. // │ 1-n
  52. // ▼
  53. // ┌──────────────────┐
  54. // │ ScopeProfiles │
  55. // └──────────────────┘
  56. // │
  57. // │ 1-1
  58. // ▼
  59. // ┌──────────────────┐
  60. // │ Profile │
  61. // └──────────────────┘
  62. // │ n-1
  63. // │ 1-n ┌───────────────────────────────────────┐
  64. // ▼ │ ▽
  65. // ┌──────────────────┐ 1-n ┌──────────────┐ ┌──────────┐
  66. // │ Sample │ ──────▷ │ KeyValue │ │ Link │
  67. // └──────────────────┘ └──────────────┘ └──────────┘
  68. // │ 1-n △ △
  69. // │ 1-n ┌─────────────────┘ │ 1-n
  70. // ▽ │ │
  71. // ┌──────────────────┐ n-1 ┌──────────────┐
  72. // │ Location │ ──────▷ │ Mapping │
  73. // └──────────────────┘ └──────────────┘
  74. // │
  75. // │ 1-n
  76. // ▼
  77. // ┌──────────────────┐
  78. // │ Line │
  79. // └──────────────────┘
  80. // │
  81. // │ 1-1
  82. // ▽
  83. // ┌──────────────────┐
  84. // │ Function │
  85. // └──────────────────┘
  86. //
  87. // ProfilesData represents the profiles data that can be stored in persistent storage,
  88. // OR can be embedded by other protocols that transfer OTLP profiles data but do not
  89. // implement the OTLP protocol.
  90. //
  91. // The main difference between this message and collector protocol is that
  92. // in this message there will not be any "control" or "metadata" specific to
  93. // OTLP protocol.
  94. //
  95. // When new fields are added into this message, the OTLP request MUST be updated
  96. // as well.
  97. message ProfilesData {
  98. // An array of ResourceProfiles.
  99. // For data coming from a single resource this array will typically contain
  100. // one element. Intermediary nodes that receive data from multiple origins
  101. // typically batch the data before forwarding further and in that case this
  102. // array will contain multiple elements.
  103. repeated ResourceProfiles resource_profiles = 1;
  104. }
  105. // A collection of ScopeProfiles from a Resource.
  106. message ResourceProfiles {
  107. reserved 1000;
  108. // The resource for the profiles in this message.
  109. // If this field is not set then no resource info is known.
  110. opentelemetry.proto.resource.v1.Resource resource = 1;
  111. // A list of ScopeProfiles that originate from a resource.
  112. repeated ScopeProfiles scope_profiles = 2;
  113. // The Schema URL, if known. This is the identifier of the Schema that the resource data
  114. // is recorded in. Notably, the last part of the URL path is the version number of the
  115. // schema: http[s]://server[:port]/path/<version>. To learn more about Schema URL see
  116. // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
  117. // This schema_url applies to the data in the "resource" field. It does not apply
  118. // to the data in the "scope_profiles" field which have their own schema_url field.
  119. string schema_url = 3;
  120. }
  121. // A collection of Profiles produced by an InstrumentationScope.
  122. message ScopeProfiles {
  123. // The instrumentation scope information for the profiles in this message.
  124. // Semantically when InstrumentationScope isn't set, it is equivalent with
  125. // an empty instrumentation scope name (unknown).
  126. opentelemetry.proto.common.v1.InstrumentationScope scope = 1;
  127. // A list of Profiles that originate from an instrumentation scope.
  128. repeated Profile profiles = 2;
  129. // The Schema URL, if known. This is the identifier of the Schema that the profile data
  130. // is recorded in. Notably, the last part of the URL path is the version number of the
  131. // schema: http[s]://server[:port]/path/<version>. To learn more about Schema URL see
  132. // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
  133. // This schema_url applies to all profiles in the "profiles" field.
  134. string schema_url = 3;
  135. }
  136. // Profile is a common stacktrace profile format.
  137. //
  138. // Measurements represented with this format should follow the
  139. // following conventions:
  140. //
  141. // - Consumers should treat unset optional fields as if they had been
  142. // set with their default value.
  143. //
  144. // - When possible, measurements should be stored in "unsampled" form
  145. // that is most useful to humans. There should be enough
  146. // information present to determine the original sampled values.
  147. //
  148. // - On-disk, the serialized proto must be gzip-compressed.
  149. //
  150. // - The profile is represented as a set of samples, where each sample
  151. // references a sequence of locations, and where each location belongs
  152. // to a mapping.
  153. // - There is a N->1 relationship from sample.location_id entries to
  154. // locations. For every sample.location_id entry there must be a
  155. // unique Location with that index.
  156. // - There is an optional N->1 relationship from locations to
  157. // mappings. For every nonzero Location.mapping_id there must be a
  158. // unique Mapping with that index.
  159. // Represents a complete profile, including sample types, samples,
  160. // mappings to binaries, locations, functions, string table, and additional metadata.
  161. // It modifies and annotates pprof Profile with OpenTelemetry specific fields.
  162. //
  163. // Note that whilst fields in this message retain the name and field id from pprof in most cases
  164. // for ease of understanding data migration, it is not intended that pprof:Profile and
  165. // OpenTelemetry:Profile encoding be wire compatible.
  166. message Profile {
  167. // A description of the samples associated with each Sample.value.
  168. // For a cpu profile this might be:
  169. // [["cpu","nanoseconds"]] or [["wall","seconds"]] or [["syscall","count"]]
  170. // For a heap profile, this might be:
  171. // [["allocations","count"], ["space","bytes"]],
  172. // If one of the values represents the number of events represented
  173. // by the sample, by convention it should be at index 0 and use
  174. // sample_type.unit == "count".
  175. repeated ValueType sample_type = 1;
  176. // The set of samples recorded in this profile.
  177. repeated Sample sample = 2;
  178. // Mapping from address ranges to the image/binary/library mapped
  179. // into that address range. mapping[0] will be the main binary.
  180. // If multiple binaries contribute to the Profile and no main
  181. // binary can be identified, mapping[0] has no special meaning.
  182. repeated Mapping mapping_table = 3;
  183. // Locations referenced by samples via location_indices.
  184. repeated Location location_table = 4;
  185. // Array of locations referenced by samples.
  186. repeated int32 location_indices = 5;
  187. // Functions referenced by locations.
  188. repeated Function function_table = 6;
  189. // Lookup table for attributes.
  190. repeated opentelemetry.proto.common.v1.KeyValue attribute_table = 7;
  191. // Represents a mapping between Attribute Keys and Units.
  192. repeated AttributeUnit attribute_units = 8;
  193. // Lookup table for links.
  194. repeated Link link_table = 9;
  195. // A common table for strings referenced by various messages.
  196. // string_table[0] must always be "".
  197. repeated string string_table = 10;
  198. // The following fields 9-14 are informational, do not affect
  199. // interpretation of results.
  200. // Time of collection (UTC) represented as nanoseconds past the epoch.
  201. int64 time_nanos = 11;
  202. // Duration of the profile, if a duration makes sense.
  203. int64 duration_nanos = 12;
  204. // The kind of events between sampled occurrences.
  205. // e.g [ "cpu","cycles" ] or [ "heap","bytes" ]
  206. ValueType period_type = 13;
  207. // The number of events between sampled occurrences.
  208. int64 period = 14;
  209. // Free-form text associated with the profile. The text is displayed as is
  210. // to the user by the tools that read profiles (e.g. by pprof). This field
  211. // should not be used to store any machine-readable information, it is only
  212. // for human-friendly content. The profile must stay functional if this field
  213. // is cleaned.
  214. repeated int32 comment_strindices = 15; // Indices into string table.
  215. // Index into the string table of the type of the preferred sample
  216. // value. If unset, clients should default to the last sample value.
  217. int32 default_sample_type_strindex = 16;
  218. // A globally unique identifier for a profile. The ID is a 16-byte array. An ID with
  219. // all zeroes is considered invalid.
  220. //
  221. // This field is required.
  222. bytes profile_id = 17;
  223. // dropped_attributes_count is the number of attributes that were discarded. Attributes
  224. // can be discarded because their keys are too long or because there are too many
  225. // attributes. If this value is 0, then no attributes were dropped.
  226. uint32 dropped_attributes_count = 19;
  227. // Specifies format of the original payload. Common values are defined in semantic conventions. [required if original_payload is present]
  228. string original_payload_format = 20;
  229. // Original payload can be stored in this field. This can be useful for users who want to get the original payload.
  230. // Formats such as JFR are highly extensible and can contain more information than what is defined in this spec.
  231. // Inclusion of original payload should be configurable by the user. Default behavior should be to not include the original payload.
  232. // If the original payload is in pprof format, it SHOULD not be included in this field.
  233. // The field is optional, however if it is present then equivalent converted data should be populated in other fields
  234. // of this message as far as is practicable.
  235. bytes original_payload = 21;
  236. // References to attributes in attribute_table. [optional]
  237. // It is a collection of key/value pairs. Note, global attributes
  238. // like server name can be set using the resource API. Examples of attributes:
  239. //
  240. // "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
  241. // "/http/server_latency": 300
  242. // "abc.com/myattribute": true
  243. // "abc.com/score": 10.239
  244. //
  245. // The OpenTelemetry API specification further restricts the allowed value types:
  246. // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/common/README.md#attribute
  247. // Attribute keys MUST be unique (it is not allowed to have more than one
  248. // attribute with the same key).
  249. repeated int32 attribute_indices = 22;
  250. }
  251. // Represents a mapping between Attribute Keys and Units.
  252. message AttributeUnit {
  253. // Index into string table.
  254. int32 attribute_key_strindex = 1;
  255. // Index into string table.
  256. int32 unit_strindex = 2;
  257. }
  258. // A pointer from a profile Sample to a trace Span.
  259. // Connects a profile sample to a trace span, identified by unique trace and span IDs.
  260. message Link {
  261. // A unique identifier of a trace that this linked span is part of. The ID is a
  262. // 16-byte array.
  263. bytes trace_id = 1;
  264. // A unique identifier for the linked span. The ID is an 8-byte array.
  265. bytes span_id = 2;
  266. }
  267. // Specifies the method of aggregating metric values, either DELTA (change since last report)
  268. // or CUMULATIVE (total since a fixed start time).
  269. enum AggregationTemporality {
  270. /* UNSPECIFIED is the default AggregationTemporality, it MUST not be used. */
  271. AGGREGATION_TEMPORALITY_UNSPECIFIED = 0;
  272. /** DELTA is an AggregationTemporality for a profiler which reports
  273. changes since last report time. Successive metrics contain aggregation of
  274. values from continuous and non-overlapping intervals.
  275. The values for a DELTA metric are based only on the time interval
  276. associated with one measurement cycle. There is no dependency on
  277. previous measurements like is the case for CUMULATIVE metrics.
  278. For example, consider a system measuring the number of requests that
  279. it receives and reports the sum of these requests every second as a
  280. DELTA metric:
  281. 1. The system starts receiving at time=t_0.
  282. 2. A request is received, the system measures 1 request.
  283. 3. A request is received, the system measures 1 request.
  284. 4. A request is received, the system measures 1 request.
  285. 5. The 1 second collection cycle ends. A metric is exported for the
  286. number of requests received over the interval of time t_0 to
  287. t_0+1 with a value of 3.
  288. 6. A request is received, the system measures 1 request.
  289. 7. A request is received, the system measures 1 request.
  290. 8. The 1 second collection cycle ends. A metric is exported for the
  291. number of requests received over the interval of time t_0+1 to
  292. t_0+2 with a value of 2. */
  293. AGGREGATION_TEMPORALITY_DELTA = 1;
  294. /** CUMULATIVE is an AggregationTemporality for a profiler which
  295. reports changes since a fixed start time. This means that current values
  296. of a CUMULATIVE metric depend on all previous measurements since the
  297. start time. Because of this, the sender is required to retain this state
  298. in some form. If this state is lost or invalidated, the CUMULATIVE metric
  299. values MUST be reset and a new fixed start time following the last
  300. reported measurement time sent MUST be used.
  301. For example, consider a system measuring the number of requests that
  302. it receives and reports the sum of these requests every second as a
  303. CUMULATIVE metric:
  304. 1. The system starts receiving at time=t_0.
  305. 2. A request is received, the system measures 1 request.
  306. 3. A request is received, the system measures 1 request.
  307. 4. A request is received, the system measures 1 request.
  308. 5. The 1 second collection cycle ends. A metric is exported for the
  309. number of requests received over the interval of time t_0 to
  310. t_0+1 with a value of 3.
  311. 6. A request is received, the system measures 1 request.
  312. 7. A request is received, the system measures 1 request.
  313. 8. The 1 second collection cycle ends. A metric is exported for the
  314. number of requests received over the interval of time t_0 to
  315. t_0+2 with a value of 5.
  316. 9. The system experiences a fault and loses state.
  317. 10. The system recovers and resumes receiving at time=t_1.
  318. 11. A request is received, the system measures 1 request.
  319. 12. The 1 second collection cycle ends. A metric is exported for the
  320. number of requests received over the interval of time t_1 to
  321. t_1+1 with a value of 1.
  322. Note: Even though, when reporting changes since last report time, using
  323. CUMULATIVE is valid, it is not recommended. */
  324. AGGREGATION_TEMPORALITY_CUMULATIVE = 2;
  325. }
  326. // ValueType describes the type and units of a value, with an optional aggregation temporality.
  327. message ValueType {
  328. int32 type_strindex = 1; // Index into string table.
  329. int32 unit_strindex = 2; // Index into string table.
  330. AggregationTemporality aggregation_temporality = 3;
  331. }
  332. // Each Sample records values encountered in some program
  333. // context. The program context is typically a stack trace, perhaps
  334. // augmented with auxiliary information like the thread-id, some
  335. // indicator of a higher level request being handled etc.
  336. message Sample {
  337. // locations_start_index along with locations_length refers to to a slice of locations in Profile.location_indices.
  338. int32 locations_start_index = 1;
  339. // locations_length along with locations_start_index refers to a slice of locations in Profile.location_indices.
  340. // Supersedes location_index.
  341. int32 locations_length = 2;
  342. // The type and unit of each value is defined by the corresponding
  343. // entry in Profile.sample_type. All samples must have the same
  344. // number of values, the same as the length of Profile.sample_type.
  345. // When aggregating multiple samples into a single sample, the
  346. // result has a list of values that is the element-wise sum of the
  347. // lists of the originals.
  348. repeated int64 value = 3;
  349. // References to attributes in Profile.attribute_table. [optional]
  350. repeated int32 attribute_indices = 4;
  351. // Reference to link in Profile.link_table. [optional]
  352. optional int32 link_index = 5;
  353. // Timestamps associated with Sample represented in nanoseconds. These timestamps are expected
  354. // to fall within the Profile's time range. [optional]
  355. repeated uint64 timestamps_unix_nano = 6;
  356. }
  357. // Describes the mapping of a binary in memory, including its address range,
  358. // file offset, and metadata like build ID
  359. message Mapping {
  360. // Address at which the binary (or DLL) is loaded into memory.
  361. uint64 memory_start = 1;
  362. // The limit of the address range occupied by this mapping.
  363. uint64 memory_limit = 2;
  364. // Offset in the binary that corresponds to the first mapped address.
  365. uint64 file_offset = 3;
  366. // The object this entry is loaded from. This can be a filename on
  367. // disk for the main binary and shared libraries, or virtual
  368. // abstractions like "[vdso]".
  369. int32 filename_strindex = 4; // Index into string table
  370. // References to attributes in Profile.attribute_table. [optional]
  371. repeated int32 attribute_indices = 5;
  372. // The following fields indicate the resolution of symbolic info.
  373. bool has_functions = 6;
  374. bool has_filenames = 7;
  375. bool has_line_numbers = 8;
  376. bool has_inline_frames = 9;
  377. }
  378. // Describes function and line table debug information.
  379. message Location {
  380. // Reference to mapping in Profile.mapping_table.
  381. // It can be unset if the mapping is unknown or not applicable for
  382. // this profile type.
  383. optional int32 mapping_index = 1;
  384. // The instruction address for this location, if available. It
  385. // should be within [Mapping.memory_start...Mapping.memory_limit]
  386. // for the corresponding mapping. A non-leaf address may be in the
  387. // middle of a call instruction. It is up to display tools to find
  388. // the beginning of the instruction if necessary.
  389. uint64 address = 2;
  390. // Multiple line indicates this location has inlined functions,
  391. // where the last entry represents the caller into which the
  392. // preceding entries were inlined.
  393. //
  394. // E.g., if memcpy() is inlined into printf:
  395. // line[0].function_name == "memcpy"
  396. // line[1].function_name == "printf"
  397. repeated Line line = 3;
  398. // Provides an indication that multiple symbols map to this location's
  399. // address, for example due to identical code folding by the linker. In that
  400. // case the line information above represents one of the multiple
  401. // symbols. This field must be recomputed when the symbolization state of the
  402. // profile changes.
  403. bool is_folded = 4;
  404. // References to attributes in Profile.attribute_table. [optional]
  405. repeated int32 attribute_indices = 5;
  406. }
  407. // Details a specific line in a source code, linked to a function.
  408. message Line {
  409. // Reference to function in Profile.function_table.
  410. int32 function_index = 1;
  411. // Line number in source code.
  412. int64 line = 2;
  413. // Column number in source code.
  414. int64 column = 3;
  415. }
  416. // Describes a function, including its human-readable name, system name,
  417. // source file, and starting line number in the source.
  418. message Function {
  419. // Name of the function, in human-readable form if available.
  420. int32 name_strindex = 1; // Index into string table
  421. // Name of the function, as identified by the system.
  422. // For instance, it can be a C++ mangled name.
  423. int32 system_name_strindex = 2; // Index into string table
  424. // Source file containing the function.
  425. int32 filename_strindex = 3; // Index into string table
  426. // Line number in source file.
  427. int64 start_line = 4;
  428. }