Contexts Interface

The Contexts Interface provides additional context data. Typically, this is data related to the current user and the environment. For example, the device or application version. Its canonical name is contexts.

The contexts type can be used to define arbitrary contextual data on the event. It accepts an object of key/value pairs. The key is the “alias” of the context and can be freely chosen. However, as per policy, it should match the type of the context unless there are two values for a type. You can omit type if the key name is the type.

When adding additional data to the event data model contexts are a good fit when you have all the data available at a single point in time. Contexts are not well suited to data that is collected over time as the SDK interfaces for contexts don't afford merging of data.

Unknown data for the contexts is rendered as a key/value list.

In the Sentry Product, certain contexts are rendered in a special way to make it more readable. More details about this can be found in the contexts code on the Sentry UI.

For more details about sending additional data with your event, see the full documentation on Additional Data.

Device Context

Device context describes the device that caused the event. This is most appropriate for mobile applications.

The type and default key is "device".

Required. The name of the device. This is typically a hostname.

Optional. The family of the device. This is usually the common part of model names across generations. For instance, iPhone would be a reasonable family, so would be Samsung Galaxy.

Optional. The model name. This, for example, can be Samsung Galaxy S3.

Optional. An internal hardware revision to identify the device exactly.

Optional. The CPU architecture.

Optional. If the device has a battery, this can be a floating point value defining the battery level (in the range 0-100).

Optional. This can be a string portrait or landscape to define the orientation of a device.

Optional. The manufacturer of the device.

Optional. The brand of the device.

Optional. The screen resolution. (e.g.: 800x600, 3040x1444).

Optional. The height of the screen.

Optional. The width of the screen.

Optional. A floating point denoting the screen density.

Optional. A decimal value reflecting the DPI (dots-per-inch) density.

Optional. Whether the device was online or not.

Optional. Whether the device was charging or not.

Optional. Whether the device was low on memory.

Optional. A flag indicating whether this device is a simulator or an actual device.

Optional. Total system memory available in bytes.

Optional. Free system memory in bytes.

Optional. Memory usable for the app in bytes.

Optional. Total device storage in bytes.

Optional. Free device storage in bytes.

Optional. Total size of an attached external storage in bytes (for example, android SDK card).

Optional. Free size of an attached external storage in bytes (for example, android SDK card).

Optional. A formatted UTC timestamp when the system was booted. For example, "2018-02-08T12:52:12Z".

Optional. The timezone of the device. For example, Europe/Vienna. This field is deprecated, please use timezone of culture context instead.

Optional. The language of the device. For example, en. This field is deprecated, please use locale of culture context instead.

Optional. Number of "logical processors". For example, 8.

Optional. CPU description. For example, Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz.

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

Optional. Kind of device the application is running on. For example, Unknown, Handheld, Console, Desktop.

Optional. Status of the device's battery. For example, Unknown, Charging, Discharging, NotCharging, Full.

Optional. Unique device identifier. This value might only be used if sendDefaultPii is enabled.

Optional. Is vibration available on the device?

Optional. Is accelerometer available on the device?

Optional. Is gyroscope available on the device?

Optional. Is audio available on the device?

Optional. Is the device capable of reporting its location?

OS Context

OS context under the default key "os" describes the operating system on which the crash happened/the event was created.

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

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

    Additionally, the Sentry server will attempt to parse the User-Agent header from the event's Request Interface and create a secondary OS context under the non-default key "client_os".

  • In events reported from a JS web frontend, the SDK typically reports no OS context.

    The server however knows by looking at the platform ("javascript") that the incoming User-Agent can only come from the crashing device, and creates the User-Agent based OS context under the default key "os".

To summarize:

  • "os" key for the device generating the event.

  • "client_os" key for an adjacent client device's OS (that is not the device creating the event) if it's important. The Sentry server sets this as part of User-Agent parsing, but SDKs can set this directly too.

  • If in doubt, just send "os". Any other keys are not searchable in the product and will not be visually pronounced using icons, so using something like "server_os" to clarify what you meant is probably going to backfire with regards to the overall product experience.

    Under the existing mental model, a hypothetical "server_os" key would actually mean you're reporting the operating system of an adjacent "upstream" device that the crashing device is talking to.

    As Kurt Tucholsky said: "The opposite of good is not evil, but good intentions"

Recommended. The name of the operating system. It might be derived from raw_description. It is required if raw_description is not provided.

Optional. The version of the operating system.

Optional. The internal build revision of the operating system.

Optional. An independent kernel version string. This is typically the entire output of the uname syscall.

Optional. A flag indicating whether the OS has been jailbroken or rooted.

Optional. Either light or dark. Describes whether the OS runs in dark mode or not.

Optional. An unprocessed description string obtained by the operating system. For some well-known runtimes, Sentry will attempt to parse name and version from this string, if they are not explicitly given.

Example OS Context

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

  "windows": {
    "type": "os",
    "name": "Windows",
    "version": "10.0.19041",
    "build": "662"
  "mac": {
    "type": "os",
    "name": "macOS",
    "version": "11.1.0",
    "build": "20C69",
    "kernel_version": "20.2.0"
  "linux": {
    "type": "os",
    "name": "Linux",
    "version": "5.10.6",
    "build": "arch1-1"

Runtime Context

Runtime context describes a runtime in more detail. Typically, this context is used multiple times if multiple runtimes are involved (for instance, if you have a JavaScript application running on top of JVM).

The type and default key is "runtime".

Recommended. The name of the runtime. It might be derived from raw_description. It is required if raw_description is not provided.

Optional. The version identifier of the runtime.

Optional. An unprocessed description string obtained by the runtime. For some well-known runtimes, Sentry will attempt to parse name and version from this string, if they are not explicitly given.

App Context

App context describes the application. As opposed to the runtime, this is the actual application that was running and carries metadata about the current session.

The type and default key is "app".

Optional. Formatted UTC timestamp when the user started the application.

Optional. Application-specific device identifier.

Optional. String identifying the kind of build. For example, testflight.

Optional. Version-independent application identifier, often a dotted bundle ID.

Optional. Human readable application name, as it appears on the platform.

Optional. Human readable application version, as it appears on the platform.

Optional. Internal build identifier, as it appears on the platform.

Optional. Amount of memory used by the application in bytes.

Optional. A flag indicating whether the app is in foreground or not. An app is in foreground when it's visible to the user.

Browser Context

Browser context carries information about the browser or user agent for web-related errors. This can either be the browser this event occurred in or the user agent of a web request that triggered the event.

The type and default key is "browser".

Required. Display name of the browser application.

Optional. Version string of the browser.

GPU Context

GPU context describes the GPU of the device.

Required. The name of the graphics device.

Optional. The Version of the graphics device.

Optional. The PCI identifier of the graphics device.

Optional. The PCI vendor identifier of the graphics device.

Optional. The vendor name as reported by the graphics device.

Optional. The total GPU memory available in Megabytes.

Optional. The device low-level API type.

Examples: "Apple Metal" or "Direct3D11"

Optional. Whether the GPU has multi-threaded rendering or not.

Optional. The Non-Power-Of-Two-Support support.

Optional. Largest size of a texture that is supported by the graphics hardware. For example, 16384.

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).

Optional. Is GPU draw call instancing supported?

Optional. Is ray tracing available on the device?

Optional. Are compute shaders available on the device?

Optional. Are geometry shaders available on the device?

Example GPU Context

  "contexts": {
    "gpu": {
      "name": "AMD Radeon Pro 560",
      "vendor_name": "Apple",
      "memory_size": 4096,
      "api_type": "Metal",
      "multi_threaded_rendering": true,
      "version": "Metal",
      "npot_support": "Full"

State Context

State context describes the state of the application (e.g.: Redux store object).

The type and default key is "state".

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.

Example State Context

  "contexts": {
    "state": {
      "state": {
        "type": "MobX",
        "value": {
          "flights": [],
          "airports": [],
          "showModal": false

Culture Context

Culture Context describes certain properties of the culture in which the software is used.

The type and default key is "culture".

Optional. For example GregorianCalendar. Free form string.

Optional. Human readable name of the culture. For example English (United States)

Optional. The name identifier, usually following the RFC 4646. For example en-US or pt-BR.

Optional. boolean, either true or false.

Optional. The timezone of the locale. For example, Europe/Vienna.

Cloud Resource Context

Cloud Resource Context describes certain properties of cloud provider the software is running. The data in the context abides to the Cloud and Host semantic conventions of OpenTelemenetry.

The type and default key is "cloud_resource".

Optional. Name of the cloud provider.

  • List of well-known values. If one of them applies, then the respective value MUST be used, otherwise a custom value MAY be used:
    • alibaba_cloud - Alibaba Cloud
    • aws - Amazon Web Services
    • azure - Microsoft Azure
    • gcp - Google Cloud Platform
    • ibm_cloud - IBM Cloud
    • tencent_cloud - Tencent Cloud
  • Example: aws
Optional. The cloud account ID the resource is assigned to.

  • Example: 111111111111

Optional. The geographical region the resource is running.

  • Example: us-central1 or us-east-1

Optional. Cloud regions often have multiple, isolated locations known as zones to increase availability. Availability zone represents the zone where the resource is running.

  • Example: us-east-1c

Optional. The cloud platform in use. The prefix of the service SHOULD match the one specified in cloud.provider.

  • Example: aws_ecs
Optional. Unique host ID.

  • Example: 3635354529892309001

Optional. Machine type of host.

  • Example: t4g.medium

Example Cloud Resource Context

The following example illustrates the contexts part of the event payload and omits other attributes for simplicity.

  "contexts": {
    "cloud_resource": {
      "cloud.provider": "aws",
      "cloud.platform": "aws_ec2",
      "": "499517922981",
      "cloud.region": "us-east-1",
      "cloud.availability_zone": "us-east-1e",
      "": "i-07d3301208fe0a55a",
      "host.type": "t2.large"

Trace Context

Additional information that allows Sentry to connect multiple transactions, spans, and/or errors into one trace.

Required. The trace ID. Determines which trace the Span/Transaction belongs to. The value should be 16 random bytes encoded as a hex string (32 characters long).

  • Example: "8f431b7aa08441bbbd5a0100fd91f9fe"

Required. The ID of the span.

  • Example: "bb8f278130535c3c"

Optional. The ID of the span enclosing this span.

  • Example: null or "a8972eefa820e2ff"

Optional. Short code identifying the type of operation the span is measuring. For more details, see Sentry's conventions around span operations.

  • Example: "http.server"

Optional. Whether the trace failed or succeeded. Currently only used to indicate status of individual transactions.

  • Example: "ok"

  • List of availabale status plus description:

    StateDescriptionHTTP status code equivalent
    okNot an error, returned on success200 and 2XX HTTP statuses
    cancelledThe operation was cancelled, typically by the caller499
    unknown or unknown_errorAn unknown error raised by APIs that don't return enough error information500
    invalid_argumentThe client specified an invalid argument400
    deadline_exceededThe deadline expired before the operation could succeed504
    not_foundContent was not found or request was denied for an entire class of users404
    already_existsThe entity attempted to be created already exists409
    permission_deniedThe caller doesn't have permission to execute the specified operation403
    resource_exhaustedThe resource has been exhausted e.g. per-user quota exhausted, file system out of space429
    failed_preconditionThe client shouldn't retry until the system state has been explicitly handled400
    abortedThe operation was aborted409
    out_of_rangeThe operation was attempted past the valid range e.g. seeking past the end of a file400
    unimplementedThe operation is not implemented or is not supported/enabled for this operation501
    internal_errorSome invariants expected by the underlying system have been broken. This code is reserved for serious errors500
    unavailableThe service is currently available e.g. as a transient condition503
    data_lossUnrecoverable data loss or corruption500
    unauthenticatedThe requester doesn't have valid authentication credentials for the operation401

Optional. The amount of time in milliseconds spent in this transaction span, excluding its immediate child spans.

  • Example: 1.035

Optional. The client-side sample rate.

  • Example: 0.1

Optional. A map or list of tags for this event. Each tag must be less than 200 characters.

  • Example: { "deviceMemory": "8 GB", "effectiveConnectionType": "4g", "routing.instrumentation": "react-router-v3" }

Optional. The Dynamic Sampling Context.

  • Example: { "trace_id": "12312012123120121231201212312012", "sample_rate": "1.0", "public_key": "93D0D1125146288EAEE2A9B3AF4F96CCBE3CB316" },

Example Trace Context

  "contexts": {
    "trace": {
      "trace_id": "12312012123120121231201212312012",
      "span_id": "0415201309082013",
      "parent_span_id": null,
      "description": "<OrganizationContext>",
      "op": "http.server",
      "tags": {
        "deviceMemory": "8 GB",
        "effectiveConnectionType": "4g",
        "routing.instrumentation": "react-router-v3"
      "dynamic_sampling_context": {
        "trace_id": "12312012123120121231201212312012",
        "sample_rate": "1.0",
        "public_key": "93D0D1125146288EAEE2A9B3AF4F96CCBE3CB316"
You can edit this page on GitHub.