-
-
Notifications
You must be signed in to change notification settings - Fork 511
Open
Labels
EnhancementThis is a new feature or requestThis is a new feature or request
Description
Summary
Allow setting after exception hooks for OTEL config. Would allow to change behavior when exception is raised for a span.
Basic Example
Currently I do something like this without which the exceptions in internal spans are simply swallowed
async def otel_after_exception(exc: Exception, _scope: Scope) -> None:
span = get_current_span()
span.record_exception(exc)
span.set_status(Status(StatusCode.ERROR, str(exc)))
@dataclass
class OpenTelemetryConfig(BaseOpenTelemetryConfig):
after_exception: list[Callable[[Exception, Scope], Awaitable[None]]] = field(
default_factory=lambda: [otel_after_exception]
)class OpenTelemetryPlugin(BaseOpenTelemetryPlugin):
"""Opentelemetry Plugin."""
@override
def on_app_init(self, app_config: AppConfig) -> AppConfig:
app_config = super().on_app_init(app_config)
if isinstance(self.config, OpenTelemetryConfig):
app_config.after_exception.extend(self.config.after_exception)
return app_configDrawbacks and Impact
Extra parameter, should not affect default behavior
Unresolved questions
Should we also include a default change in behavior as in my example?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
EnhancementThis is a new feature or requestThis is a new feature or request