Skip to content

Commit 6cc020f

Browse files
chore(profiling): improve typing (#15232)
## Description As title says. Should be a no-op functionally.
1 parent 466fcfa commit 6cc020f

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

ddtrace/internal/datadog/profiling/ddup/_ddup.pyi

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ from typing import Union
44
from .._types import StringType
55
from ddtrace._trace.span import Span
66
from ddtrace._trace.tracer import Tracer
7+
import ddtrace
78

89
def config(
9-
env: StringType,
10-
service: StringType,
11-
version: StringType,
12-
tags: Optional[Dict[Union[str, bytes], Union[str, bytes]]],
13-
max_nframes: Optional[int],
14-
timeline_enabled: Optional[bool],
15-
output_filename: Optional[str],
16-
sample_pool_capacity: Optional[int],
17-
timeout: Optional[int],
10+
env: StringType = None,
11+
service: StringType = None,
12+
version: StringType = None,
13+
tags: Optional[Dict[Union[str, bytes], Union[str, bytes]]] = None,
14+
max_nframes: Optional[int] = None,
15+
timeline_enabled: Optional[bool] = None,
16+
output_filename: Optional[str] = None,
17+
sample_pool_capacity: Optional[int] = None,
18+
timeout: Optional[int] = None,
1819
) -> None: ...
1920
def start() -> None: ...
20-
def upload(tracer: Optional[Tracer], enable_code_provenance: Optional[bool]) -> None: ...
21+
def upload(tracer: Optional[Tracer] = ddtrace.tracer, enable_code_provenance: Optional[bool] = None) -> None: ...
2122

2223
class SampleHandle:
2324
def flush_sample(self) -> None: ...

ddtrace/profiling/collector/stack.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ from ddtrace.profiling import collector
55

66
class StackCollector(collector.PeriodicCollector):
77
tracer: typing.Optional[Tracer]
8+
min_interval_time: float
9+
10+
def _init(self) -> None: ...
11+
def _compute_new_interval(self, used_wall_time_ns: int) -> float: ...

tests/profiling/collector/test_stack.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def test_collect_once(tmp_path):
9696

9797
ddup.upload()
9898
# assert len(all_events) == 0
99+
assert all_events is not None
99100
assert len(all_events) == 2
100101

101102
stack_events = all_events[0]
@@ -338,6 +339,8 @@ def test_ignore_profiler(tmp_path, ignore_profiler):
338339
with s:
339340
for _ in range(10):
340341
time.sleep(0.1)
342+
343+
assert s._worker is not None
341344
collector_worker_thread_id = s._worker.ident
342345

343346
ddup.upload()
@@ -392,6 +395,8 @@ def test_ignore_profiler_gevent_task():
392395
with s:
393396
for _ in range(10):
394397
time.sleep(0.1)
398+
399+
assert s._worker is not None
395400
collector_worker_thread_id = s._worker.ident
396401

397402
ddup.upload()

0 commit comments

Comments
 (0)