4.8.0 — 2026-05-03¶
← 4.8.1 | 4.7.1 → | ↑ 4.x series
Added¶
Helpers - Tracing¶
-
async_capture_transactionDecorator — 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
TypeErrorimmediately at import time if a sync function is passed - Mirrors the synchronous
capture_transactionAPI withnameandopparameters
- Validates that decorated function is a coroutine using
-
async_capture_spanDecorator — 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_exceptionMethod — Added static method to determine the appropriate APM outcome string for exceptions.- Returns
OUTCOME.SUCCESSforBaseErrorexceptions with HTTP status below 500 (client errors) - Returns
OUTCOME.FAILUREfor 5xx errors or unexpected exceptions - Enables accurate transaction outcome reporting in error handling paths
- Returns
Configs - Sentry¶
SentryConfig.ENVIRONMENTField — Added optionalENVIRONMENTfield (str | None, defaultNone) to explicitly set the Sentry environment name.
Changed¶
Configs - Base Config¶
- Conditional Environment Assignment — Updated
BaseConfig._post_initto only setELASTIC_APM.ENVIRONMENTandSENTRY.ENVIRONMENTwhen they areNone, preserving explicitly configured values.
Helpers - Tracing Utils¶
- Initialization Tracking — Added
_sentry_initializedand_elastic_apm_initializedclass variables to prevent duplicate initialization attempts. - Lazy Initialization Enhancement —
init_tracing_if_needednow checks initialization state before attempting to initialise each backend.
Helpers - gRPC Interceptors¶
- Async gRPC Client Trace Interceptor — Changed from
elasticapm.capture_spantoelasticapm.async_capture_spanfor proper async span handling. - gRPC Server Trace Interceptor — Refactored to use
elasticapm.set_transaction_outcomewithOUTCOMEconstants instead of deprecatedtransaction.set_success()/transaction.set_failure()methods. - Async Servicer Context Wrapper — Added
_AsyncServicerContextWrapperclass to handle async gRPC server context, ensuringabort()is properly awaited in async servicer methods.
Helpers - App Utils¶
- Interceptor Ordering Fix — Fixed
AppUtils.create_async_grpc_appto 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_transactionandasync_capture_spandecorators to verify proper transaction and span capture for async functions.