Skip to content

Add deadlineTimeout Option for Auto Transactions #6788

@philprime

Description

@philprime

Description

Problem Statement

Currently, the iOS SDK uses a hardcoded 30-second deadline timeout (SENTRY_AUTO_TRANSACTION_DEADLINE) for auto-generated transactions. This prevents users from configuring the timeout duration for their specific use cases.

The Android SDK already has a configurable deadlineTimeout option (see Android docs), but iOS lacks this capability.

Solution

Add a new deadlineTimeout option to SentryOptions that:

  • Defaults to 30 seconds (maintaining backward compatibility)
  • Can be configured by users to match their transaction duration requirements
  • Is passed through to SentryTracer via SentryTracerConfiguration
  • Replaces the hardcoded SENTRY_AUTO_TRANSACTION_DEADLINE constant

Implementation Requirements

1. Add Public Option to SentryOptions

File: Sources/Swift/Options.swift

Add a new property:

/// The maximum duration in seconds for auto-generated transactions before they are automatically finished
/// with a deadline_exceeded status. Only applies to auto-generated transactions (UI events, etc.).
/// @note The default is 30 seconds.
@objc public var deadlineTimeout: TimeInterval = 30.0

File: Sources/Sentry/SentryOptionsInternal.m

Add parsing support for the option in the initWithDict:validOptions: method:

if ([options[@"deadlineTimeout"] isKindOfClass:[NSNumber class]]) {
    sentryOptions.deadlineTimeout = [options[@"deadlineTimeout"] doubleValue];
}

2. Pass Option to SentryTracer

File: Sources/Sentry/include/SentryTracerConfiguration.h
Add a new property:

/**
 * The maximum duration in seconds for auto-generated transactions before they are automatically finished
 * with a deadline_exceeded status.
 *
 * Default is 30 seconds.
 */
@property (nonatomic) NSTimeInterval deadlineTimeout;

File: Sources/Sentry/SentryTracerConfiguration.m

Initialize the property in init:

self.deadlineTimeout = 30.0;

File: Sources/Sentry/SentryTracer.m

  • Replace the hardcoded SENTRY_AUTO_TRANSACTION_DEADLINE constant usage with _configuration.deadlineTimeout
  • Update startDeadlineTimeout method to use the configuration value instead of the constant

File: Sources/Sentry/SentryUIEventTrackerTransactionMode.m

Pass the deadlineTimeout from options to the tracer configuration when creating auto transactions.

3. Documentation

Repository: getsentry/sentry-docs

Add documentation for the new option in the iOS configuration options page:

  • Location: Similar to how idleTimeout is documented
  • Include description, default value, and use cases
  • Reference the Android equivalent for consistency

Testing Requirements

  • Unit tests verifying the default value (30 seconds)
  • Unit tests verifying custom values are respected
  • Integration tests ensuring auto transactions respect the configured timeout
  • Verify backward compatibility (existing behavior unchanged when not configured)

Related Code

  • Sources/Sentry/SentryTracer.m:50 - Hardcoded constant SENTRY_AUTO_TRANSACTION_DEADLINE
  • Sources/Sentry/SentryTracer.m:256-273 - startDeadlineTimeout method
  • Sources/Sentry/SentryTracer.m:155-157 - Auto transaction deadline timeout initialization
  • Android equivalent: deadlineTimeout option

References

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions