Describe the bug:
capture_span() types start as int instead of float
To Reproduce
- apm_client.start_transaction()
- t0 = time.time()
- do_something()
- t1 = time.time()
- dur = t1-t0
- do_something_else()
- span = elasticapm.capture_span(start=int(t0), duration=dur)
- with span as s: pass
- apm_client.end_transaction()
- Note that span will not fall in transaction time frame correctly.
Environment (please complete the following information)
- OS: mac
- Python version: 3.12.10
- Framework and version: FastApi 0.111.1
- APM Server version: 6.23.0
- Agent version: N/A
Additional context
elasticapm.capture_span() takes an optional argument start, which is typed to be an int. This works well enough with a time.time() float, but if you are using mypy, you will realize that it needs an int. Only problem is that capture_span() passes start to Span(BaseSpan), which calls super().__init__() which initializes start as a float, passing it through time_to_perf_counter(start). This method fails miserably with an int representation of time.time().
Describe the bug:
capture_span()typesstartasintinstead offloatTo Reproduce
Environment (please complete the following information)
Additional context
elasticapm.capture_span()takes an optional argumentstart, which is typed to be an int. This works well enough with atime.time()float, but if you are using mypy, you will realize that it needs anint. Only problem is thatcapture_span()passes start toSpan(BaseSpan), which callssuper().__init__()which initializes start as afloat, passing it throughtime_to_perf_counter(start). This method fails miserably with an int representation oftime.time().