androidsentry

Do not report certain tags to Sentry


There seems to be quite a bunch of tags that sentry on Android sends alongside all its events: For instance device, isSideLoaded or os.name. It happens that all these (and some more) are very irrelevant for our purposes, as they are basically constant.

The problem is not network bandwith, but the the discover or issue views in the Sentry UI. They have a quite handy list of “top tags” including value distribution. However, most of the list of polluted by the standard tags with 100% for a single value.

I tried to configure the SentryAndroidOptions with something like the following, but to no avail:

options.beforeSend  = BeforeSendCallback { event, _ ->
    event.removeTag("device")
    event.removeTag("isSideLoaded")
    event.removeTag("os.name")
    // …
    return@BeforeSendCallback event
}

It has no effect, it seems to happen too early. (In fact, only isSideLoaded is already set when entering the callback.) Which other options can I try?


Solution

  • The problem is that these tags are actually extracted on the backend site (except isSideLoaded which will also be deprecated and removed as a tag soon), and they are extracted from so-called Contexts. So to achieve what you want you'd have to do something like:

    options.beforeSend  = BeforeSendCallback { event, _ ->
        event.removeTag("isSideLoaded")
        event.contexts.remove(Device.TYPE)
        event.contexts.operatingSystem?.name = null
        // and so on
        return@BeforeSendCallback event
    }
    

    You can read up more on what kinds of Context the SDK sends in this doc: https://develop.sentry.dev/sdk/event-payloads/contexts/