Skip to content

Commit e203a64

Browse files
committed
[Python-Conprof] Update ddtrace to 4.1.1(latest) for Python 3.14
1 parent 61fb7f4 commit e203a64

File tree

2 files changed

+21
-28
lines changed

2 files changed

+21
-28
lines changed

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
author="Blackfire.io",
1616
packages=['blackfire_conprof', 'blackfire_conprof.bootstrap'],
1717
author_email="[email protected]",
18-
install_requires=["ddtrace==3.2.1"],
18+
install_requires=["ddtrace==4.1.1"],
1919
description="Blackfire Continuous Profiler",
2020
long_description=long_description,
2121
long_description_content_type="text/markdown",
@@ -27,11 +27,11 @@
2727
url=HOMEPAGE,
2828
classifiers=[
2929
"Programming Language :: Python",
30-
"Programming Language :: Python :: 3.8",
3130
"Programming Language :: Python :: 3.9",
3231
"Programming Language :: Python :: 3.10",
3332
"Programming Language :: Python :: 3.11",
3433
"Programming Language :: Python :: 3.12",
3534
"Programming Language :: Python :: 3.13",
35+
"Programming Language :: Python :: 3.14",
3636
],
3737
)

tests/test_profiler.py

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import time
33
import os
44
from blackfire_conprof.profiler import Profiler
5-
from ddtrace.settings.profiling import config as profiling_config
65

76
from contextlib import contextmanager
87

@@ -34,7 +33,6 @@ def test_profiler_dd_envvars(self):
3433
# ensure os.environ is preserved
3534
self.assertEqual(os.environ['DD_PROFILING_ENABLED'], '1')
3635

37-
@unittest.skip(not profiling_config.export.libdd_enabled)
3836
def test_profiler_basic_lib_dd(self):
3937
class _context:
4038
nexportcalls = 0
@@ -48,24 +46,17 @@ def _upload(*args, **kwargs):
4846
prof.stop()
4947
self.assertTrue(_context.nexportcalls >= 1)
5048

51-
@unittest.skip(profiling_config.export.libdd_enabled)
5249
def test_profiler_basic(self):
5350
def foo(t):
5451
time.sleep(t)
5552

5653
class _context:
5754
nexportcalls = 0
58-
def _export(instance, events, start_time_ns, end_time_ns):
59-
from ddtrace.profiling.collector import stack_event
60-
61-
stack_events = events.get(stack_event.StackSampleEvent, [])
62-
63-
self.assertTrue(len(stack_events) > 0)
64-
self.assertTrue('foo' in str(stack_events))
55+
def _upload(*args, **kwargs):
6556
_context.nexportcalls += 1
66-
67-
from ddtrace.profiling.exporter import http as dd_http_exporter
68-
with _patch(dd_http_exporter.PprofHTTPExporter, "export", _export):
57+
58+
from ddtrace.internal.datadog.profiling import ddup
59+
with _patch(ddup, "upload", _upload):
6960
prof = Profiler(period=0.1)
7061
prof.start()
7162
foo(0.3+0.2)
@@ -96,24 +87,26 @@ def test_profiler_params(self):
9687
self.assertTrue('probe_version' in prof._profiler.tags)
9788
self.assertTrue(prof._profiler.tags.get('project_id') == 'id-1')
9889

99-
@unittest.skip(profiling_config.export.libdd_enabled)
10090
def test_profiler_creds(self):
101-
def _upload(instance, client, path, body, headers):
102-
self.assertTrue(headers.get('DD-API-KEY').decode()=='id-1:token-1')
91+
class _context:
92+
upload_calls = 0
93+
94+
def _upload(*args, **kwargs):
95+
_context.upload_calls += 1
96+
97+
from ddtrace.internal.datadog.profiling import ddup
10398

104-
from ddtrace.profiling.exporter import http as dd_http_exporter
105-
with _patch(dd_http_exporter.PprofHTTPExporter, "_upload", _upload):
99+
# Test with credentials
100+
with _patch(ddup, "upload", _upload):
106101
prof = Profiler(server_id='id-1', server_token='token-1', period=0.1)
102+
self.assertEqual(prof._profiler.api_key, 'id-1:token-1')
107103
prof.start()
108104
time.sleep(0.2)
109105
prof.stop()
110106

111-
def _upload2(instance, client, path, body, headers):
112-
self.assertEqual(headers.get('DD-API-KEY'), None)
107+
self.assertGreater(_context.upload_calls, 0)
113108

114-
# no token
115-
with _patch(dd_http_exporter.PprofHTTPExporter, "_upload", _upload2):
116-
prof = Profiler(server_id='id-1', period=0.1)
117-
prof.start()
118-
time.sleep(0.2)
119-
prof.stop()
109+
# Test without token (server_id only)
110+
prof2 = Profiler(server_id='id-1', period=0.1)
111+
self.assertEqual(prof2._profiler.api_key, '')
112+
prof2.stop()

0 commit comments

Comments
 (0)