Skip to content

Commit f79ea33

Browse files
antonpirkerstephanie-anderson
authored andcommitted
New: Event payload Cloud Resource Context (#825)
* First version of cloud resource context spec
1 parent f1147e8 commit f79ea33

File tree

1 file changed

+119
-55
lines changed

1 file changed

+119
-55
lines changed

develop-docs/sdk/event-payloads/contexts.mdx

Lines changed: 119 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ The `type` and default key is `"device"`.
3838
`family`
3939

4040
: _Optional_. The family of the device. This is usually the common part of model
41-
names across generations. For instance, `iPhone` would be a reasonable family,
42-
so would be `Samsung Galaxy`.
41+
names across generations. For instance, `iPhone` would be a reasonable family,
42+
so would be `Samsung Galaxy`.
4343

4444
`model`
4545

@@ -56,12 +56,12 @@ The `type` and default key is `"device"`.
5656
`battery_level`
5757

5858
: _Optional_. If the device has a battery, this can be a floating point value
59-
defining the battery level (in the range 0-100).
59+
defining the battery level (in the range 0-100).
6060

6161
`orientation`
6262

6363
: _Optional_. This can be a string `portrait` or `landscape` to define the
64-
orientation of a device.
64+
orientation of a device.
6565

6666
`manufacturer`
6767

@@ -106,7 +106,7 @@ The `type` and default key is `"device"`.
106106
`simulator`
107107

108108
: _Optional_. A flag indicating whether this device is a simulator or an actual
109-
device.
109+
device.
110110

111111
`memory_size`
112112

@@ -131,17 +131,17 @@ The `type` and default key is `"device"`.
131131
`external_storage_size`
132132

133133
: _Optional_. Total size of an attached external storage in bytes (for example,
134-
android SDK card).
134+
android SDK card).
135135

136136
`external_free_storage`
137137

138138
: _Optional_. Free size of an attached external storage in bytes (for example,
139-
android SDK card).
139+
android SDK card).
140140

141141
`boot_time`
142142

143143
: _Optional_. A formatted UTC timestamp when the system was booted. For example,
144-
`"2018-02-08T12:52:12Z"`.
144+
`"2018-02-08T12:52:12Z"`.
145145

146146
`timezone`
147147

@@ -161,8 +161,8 @@ The `type` and default key is `"device"`.
161161

162162
`processor_frequency`
163163

164-
: _Optional_. Processor frequency in MHz. Note that the actual CPU frequency might vary depending on current load and power conditions,
165-
especially on low-powered devices like phones and laptops.
164+
: _Optional_. Processor frequency in MHz. Note that the actual CPU frequency might vary depending on current load and power conditions,
165+
especially on low-powered devices like phones and laptops.
166166

167167
`device_type`
168168

@@ -205,15 +205,15 @@ The `type` and default key is `"os"`. However, since contexts can be set
205205
multiple times under different keys, there has historically been a lot of
206206
confusion about which OS context represents what. So here's some examples:
207207

208-
* In events reported from a Python/ASP.NET/Rails web backend, the OS context
208+
- In events reported from a Python/ASP.NET/Rails web backend, the OS context
209209
under the default key `"os"` is the server's operating system, and is set by
210210
the SDK (if at all).
211211

212212
Additionally, the Sentry server will attempt to parse the `User-Agent` header
213213
from the event's [Request Interface](/sdk/event-payloads/request/) and create a _secondary_ OS
214214
context under the non-default key `"client_os"`.
215215

216-
* In events reported from a JS web frontend, the SDK typically reports no OS
216+
- In events reported from a JS web frontend, the SDK typically reports no OS
217217
context.
218218

219219
The server however knows by looking at the platform (`"javascript"`) that the
@@ -222,11 +222,11 @@ confusion about which OS context represents what. So here's some examples:
222222

223223
To summarize:
224224

225-
* `"os"` key for the device generating the event.
226-
* `"client_os"` key for an adjacent client device's OS (that is _not_ the
225+
- `"os"` key for the device generating the event.
226+
- `"client_os"` key for an adjacent client device's OS (that is _not_ the
227227
device creating the event) if it's important. The Sentry server sets this as part of
228228
User-Agent parsing, but SDKs can set this directly too.
229-
* If in doubt, just send `"os"`. Any other keys are not searchable in the
229+
- If in doubt, just send `"os"`. Any other keys are not searchable in the
230230
product and will not be visually pronounced using icons, so using something
231231
like `"server_os"` to clarify what you meant is probably going to
232232
backfire with regards to the overall product experience.
@@ -252,7 +252,7 @@ To summarize:
252252
`kernel_version`
253253

254254
: _Optional_. An independent kernel version string. This is typically the entire
255-
output of the `uname` syscall.
255+
output of the `uname` syscall.
256256

257257
`rooted`
258258

@@ -265,10 +265,10 @@ To summarize:
265265
`raw_description`
266266

267267
: _Optional_. An unprocessed description string obtained by the operating
268-
system. For some well-known runtimes, Sentry will attempt to parse `name` and
269-
`version` from this string, if they are not explicitly given.
268+
system. For some well-known runtimes, Sentry will attempt to parse `name` and
269+
`version` from this string, if they are not explicitly given.
270270

271-
### Example
271+
### Example OS Context
272272

273273
The OS Context for the 3 major OSs should look like this:
274274

@@ -278,7 +278,7 @@ The OS Context for the 3 major OSs should look like this:
278278
"type": "os",
279279
"name": "Windows",
280280
"version": "10.0.19041",
281-
"build": "662",
281+
"build": "662"
282282
},
283283
"mac": {
284284
"type": "os",
@@ -296,7 +296,6 @@ The OS Context for the 3 major OSs should look like this:
296296
}
297297
```
298298

299-
300299
## Runtime Context
301300

302301
Runtime context describes a runtime in more detail. Typically, this context is
@@ -316,8 +315,8 @@ The `type` and default key is `"runtime"`.
316315
`raw_description`
317316

318317
: _Optional_. An unprocessed description string obtained by the runtime. For
319-
some well-known runtimes, Sentry will attempt to parse `name` and `version`
320-
from this string, if they are not explicitly given.
318+
some well-known runtimes, Sentry will attempt to parse `name` and `version`
319+
from this string, if they are not explicitly given.
321320

322321
## App Context
323322

@@ -342,7 +341,7 @@ The `type` and default key is `"app"`.
342341
`app_identifier`
343342

344343
: _Optional_. Version-independent application identifier, often a dotted bundle
345-
ID.
344+
ID.
346345

347346
`app_name`
348347

@@ -412,7 +411,7 @@ GPU context describes the GPU of the device.
412411

413412
: _Optional_. The device low-level API type.
414413

415-
Examples: `"Apple Metal"` or `"Direct3D11"`
414+
Examples: `"Apple Metal"` or `"Direct3D11"`
416415

417416
`multi_threaded_rendering`
418417

@@ -424,11 +423,11 @@ GPU context describes the GPU of the device.
424423

425424
`max_texture_size`
426425

427-
: _Optional_. Largest size of a texture that is supported by the graphics hardware. For example, `16384`.
426+
: _Optional_. Largest size of a texture that is supported by the graphics hardware. For example, `16384`.
428427

429428
`graphics_shader_level`
430429

431-
: _Optional_. Approximate "shader capability" level of the graphics device. For example, `Shader Model 2.0, OpenGL ES 3.0, Metal / OpenGL ES 3.1, 27 (unknown)`.
430+
: _Optional_. Approximate "shader capability" level of the graphics device. For example, `Shader Model 2.0, OpenGL ES 3.0, Metal / OpenGL ES 3.1, 27 (unknown)`.
432431

433432
`supports_draw_call_instancing`
434433

@@ -446,17 +445,21 @@ GPU context describes the GPU of the device.
446445

447446
: _Optional_. Are geometry shaders available on the device?
448447

449-
Example:
448+
### Example GPU Context
450449

451450
```json
452-
"gpu": {
453-
"name": "AMD Radeon Pro 560",
454-
"vendor_name": "Apple",
455-
"memory_size": 4096,
456-
"api_type": "Metal",
457-
"multi_threaded_rendering": true,
458-
"version": "Metal",
459-
"npot_support": "Full"
451+
{
452+
"contexts": {
453+
"gpu": {
454+
"name": "AMD Radeon Pro 560",
455+
"vendor_name": "Apple",
456+
"memory_size": 4096,
457+
"api_type": "Metal",
458+
"multi_threaded_rendering": true,
459+
"version": "Metal",
460+
"npot_support": "Full"
461+
}
462+
}
460463
}
461464
```
462465

@@ -470,31 +473,35 @@ The `type` and default key is `"state"`.
470473

471474
: **Required**. Object with two keys: _Optional_ `type` for naming the state library (e.g.: Redux, MobX, Vuex) and **Required** `value` that holds the state object.
472475

473-
Example:
476+
### Example State Context
474477

475478
```json
476-
"state": {
477-
"state": {
478-
"type": "MobX",
479-
"value": {
480-
"flights": [],
481-
"airports": [],
482-
"showModal": false
479+
{
480+
"contexts": {
481+
"state": {
482+
"state": {
483+
"type": "MobX",
484+
"value": {
485+
"flights": [],
486+
"airports": [],
487+
"showModal": false
488+
}
489+
}
483490
}
484-
},
491+
}
485492
}
486493
```
487494

488495
## Culture Context
489496

490-
Culture Context describes certain properties of the culture in which
497+
Culture Context describes certain properties of the culture in which
491498
the software is used.
492499

493500
The `type` and default key is `"culture"`.
494501

495502
`calendar`
496503

497-
: _Optional_. For example `GregorianCalendar`. Free form string.
504+
: _Optional_. For example `GregorianCalendar`. Free form string.
498505

499506
`display_name`
500507

@@ -512,20 +519,77 @@ The `type` and default key is `"culture"`.
512519

513520
: _Optional_. The timezone of the locale. For example, `Europe/Vienna`.
514521

515-
## Examples
522+
## Cloud Resource Context
523+
524+
Cloud Resource Context describes certain properties of cloud provider the software is running.
525+
The data in the context abides to the [Cloud](https://opentelemetry.io/docs/reference/specification/resource/semantic_conventions/cloud/) and [Host](https://opentelemetry.io/docs/reference/specification/resource/semantic_conventions/host/) semantic conventions of OpenTelemenetry.
526+
527+
The `type` and default key is `"cloud_resource"`.
528+
529+
`cloud.provider`
530+
531+
: _Optional_. Name of the cloud provider.
532+
533+
- List of well-known values. If one of them applies, then the respective value MUST be used, otherwise a custom value MAY be used:
534+
- `alibaba_cloud` - Alibaba Cloud
535+
- `aws` - Amazon Web Services
536+
- `azure` - Microsoft Azure
537+
- `gcp` - Google Cloud Platform
538+
- `ibm_cloud` - IBM Cloud
539+
- `tencent_cloud` - Tencent Cloud
540+
- Example: `aws`
541+
542+
`cloud.account.id`
543+
544+
: _Optional_. The cloud account ID the resource is assigned to.
545+
546+
- Example: `111111111111`
547+
548+
`cloud.region`
549+
550+
: _Optional_. The geographical region the resource is running.
551+
552+
- Example: `us-central1` or `us-east-1`
553+
554+
`cloud.availability_zone`
555+
556+
: _Optional_. Cloud regions often have multiple, isolated locations known as zones to increase availability. Availability zone represents the zone where the resource is running. In Google Cloud this is called `cloud.zone`.
557+
558+
- Example: `us-east-1c`
559+
560+
`cloud.platform`
561+
562+
: _Optional_. The cloud platform in use. The prefix of the service SHOULD match the one specified in `cloud.provider`.
563+
564+
- Example: `aws_ecs`
565+
566+
`host.id`
567+
568+
: _Optional_. Unique host ID.
569+
570+
- Example: `3635354529892309001`
571+
572+
`host.type`
573+
574+
: _Optional_. Machine type of host.
575+
576+
- Example: `t4g.medium`
577+
578+
### Example Cloud Resource Context
516579

517580
The following example illustrates the contexts part of the <Link to="/sdk/event-payloads/">event payload</Link> and omits other attributes for simplicity.
518581

519582
```json
520583
{
521584
"contexts": {
522-
"os": {
523-
"name": "Windows"
524-
},
525-
"electron": {
526-
"type": "runtime",
527-
"name": "Electron",
528-
"version": "4.0"
585+
"cloud_resource": {
586+
"cloud.provider": "aws",
587+
"cloud.platform": "aws_ec2",
588+
"cloud.account.id": "499517922981",
589+
"cloud.region": "us-east-1",
590+
"cloud.availability_zone": "us-east-1e",
591+
"host.id": "i-07d3301208fe0a55a",
592+
"host.type": "t2.large"
529593
}
530594
}
531595
}

0 commit comments

Comments
 (0)