Skip to content

4.8.0 — 2026-05-03

← 4.8.1 | 4.7.1 → | ↑ 4.x series

Added

Helpers - Tracing

  • async_capture_transaction Decorator — New async-only transaction tracing decorator that enforces coroutine functions at decoration time, providing early failure detection for misuse.

    • Validates that decorated function is a coroutine using inspect.iscoroutinefunction
    • Raises TypeError immediately at import time if a sync function is passed
    • Mirrors the synchronous capture_transaction API with name and op parameters
  • async_capture_span Decorator — New async-only span tracing decorator for capturing child operations within async transactions.

    • Enforces coroutine functions at decoration time
    • Works with both Sentry and Elastic APM backends
    • Provides detailed performance insights for async operations
  • TracingUtils.outcome_for_exception Method — Added static method to determine the appropriate APM outcome string for exceptions.

    • Returns OUTCOME.SUCCESS for BaseError exceptions with HTTP status below 500 (client errors)
    • Returns OUTCOME.FAILURE for 5xx errors or unexpected exceptions
    • Enables accurate transaction outcome reporting in error handling paths

Configs - Sentry

  • SentryConfig.ENVIRONMENT Field — Added optional ENVIRONMENT field (str | None, default None) to explicitly set the Sentry environment name.

Changed

Configs - Base Config

  • Conditional Environment Assignment — Updated BaseConfig._post_init to only set ELASTIC_APM.ENVIRONMENT and SENTRY.ENVIRONMENT when they are None, preserving explicitly configured values.

Helpers - Tracing Utils

  • Initialization Tracking — Added _sentry_initialized and _elastic_apm_initialized class variables to prevent duplicate initialization attempts.
  • Lazy Initialization Enhancementinit_tracing_if_needed now checks initialization state before attempting to initialise each backend.

Helpers - gRPC Interceptors

  • Async gRPC Client Trace Interceptor — Changed from elasticapm.capture_span to elasticapm.async_capture_span for proper async span handling.
  • gRPC Server Trace Interceptor — Refactored to use elasticapm.set_transaction_outcome with OUTCOME constants instead of deprecated transaction.set_success() / transaction.set_failure() methods.
  • Async Servicer Context Wrapper — Added _AsyncServicerContextWrapper class to handle async gRPC server context, ensuring abort() is properly awaited in async servicer methods.

Helpers - App Utils

  • Interceptor Ordering Fix — Fixed AppUtils.create_async_grpc_app to add customized interceptors before creating the gRPC server, ensuring interceptors are properly registered.

Tests

Tests - Tracing

  • Async Decorator Tests — Added comprehensive BDD test scenarios for async_capture_transaction and async_capture_span decorators to verify proper transaction and span capture for async functions.