Skip to content

Problematic API: Scope.setTransactionName() #5660

Closed
@lforst

Description

@lforst

We've identified this API, or rather its implementation as problematic.

Scope.setTransactionName() will populate the transaction field of any event that comes after that call on that scope (and any scopes that were cloned from that scope).

The transaction field is used for associating an error with a transaction (not an actual transaction event in Sentry but rather a route or error origin) when dealing with an error event, and it contains the name of a transaction when dealing with a transaction event.

While this sounds nice and all, overwriting the name of transactions like this is a bit problematic:

  1. It's a bit opaque that this is the behaviour of Scope.setTransactionName()
  2. Often times we already have a high-quality transaction name through auto-instrumentation (source: route) and we don't want to have it overridden by the user. While we should provide users to overwrite high quality transaction names if they really want to, they probably shouldn't do it with Scope.setTransactionName(). It's very likely that this function just causes side-effects that the user didn't intend to introduce.
  3. If transaction is overriden by Scope.setTransactionName() we're not updating the source of the transaction to custom. We need source to be correct for Dynamic Sampling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions