|
44 | 44 | import warnings
|
45 | 45 | from copy import deepcopy
|
46 | 46 | from datetime import timedelta
|
47 |
| -from typing import Optional, Sequence, Tuple |
| 47 | +from types import TracebackType |
| 48 | +from typing import Any, Optional, Sequence, Tuple, Type, Union |
48 | 49 |
|
49 | 50 | import elasticapm
|
50 | 51 | from elasticapm.conf import Config, VersionedConfig, constants
|
51 | 52 | from elasticapm.conf.constants import ERROR
|
52 | 53 | from elasticapm.metrics.base_metrics import MetricsRegistry
|
53 |
| -from elasticapm.traces import DroppedSpan, Tracer, execution_context |
| 54 | +from elasticapm.traces import DroppedSpan, Tracer, Transaction, execution_context |
54 | 55 | from elasticapm.utils import cgroup, cloud, compat, is_master_process, stacks, varmap
|
55 | 56 | from elasticapm.utils.disttracing import TraceParent
|
56 | 57 | from elasticapm.utils.encoding import enforce_label_format, keyword_field, shorten, transform
|
@@ -261,15 +262,22 @@ def capture(self, event_type, date=None, context=None, custom=None, stack=None,
|
261 | 262 | self.queue(ERROR, data, flush=not handled)
|
262 | 263 | return data["id"]
|
263 | 264 |
|
264 |
| - def capture_message(self, message=None, param_message=None, **kwargs): |
| 265 | + def capture_message(self, message: Optional[str] = None, param_message=None, **kwargs: Any) -> str: |
265 | 266 | """
|
266 | 267 | Creates an event from ``message``.
|
267 | 268 |
|
268 | 269 | >>> client.capture_message('My event just happened!')
|
269 | 270 | """
|
270 | 271 | return self.capture("Message", message=message, param_message=param_message, **kwargs)
|
271 | 272 |
|
272 |
| - def capture_exception(self, exc_info=None, handled=True, **kwargs): |
| 273 | + def capture_exception( |
| 274 | + self, |
| 275 | + exc_info: Union[ |
| 276 | + None, bool, Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] |
| 277 | + ] = None, |
| 278 | + handled: bool = True, |
| 279 | + **kwargs: Any |
| 280 | + ) -> str: |
273 | 281 | """
|
274 | 282 | Creates an event from an exception.
|
275 | 283 |
|
@@ -317,7 +325,9 @@ def begin_transaction(
|
317 | 325 | transaction_type, trace_parent=trace_parent, start=start, auto_activate=auto_activate, links=links
|
318 | 326 | )
|
319 | 327 |
|
320 |
| - def end_transaction(self, name=None, result="", duration=None): |
| 328 | + def end_transaction( |
| 329 | + self, name: Optional[str] = None, result: str = "", duration: Optional[Union[float, timedelta]] = None |
| 330 | + ) -> Transaction: |
321 | 331 | """
|
322 | 332 | End the current transaction.
|
323 | 333 |
|
|
0 commit comments