コード例 #1
0
         nframes=3,
         sample_size=512 * 1024,
     ),
 ],
 stack.StackSampleEvent: [
     stack.StackSampleEvent(
         timestamp=1,
         thread_id=67892304,
         thread_native_id=123987,
         thread_name="MainThread",
         trace_id=1322219321,
         trace_resource="myresource",
         trace_type=ext.SpanTypes.WEB.value,
         frames=[
             ("foobar.py", 23, "func1"),
             ("foobar.py", 44, "func2"),
             ("foobar.py", 19, "func5"),
         ],
         task_id=123,
         task_name="sometask",
         span_id=49343,
         wall_time_ns=1324,
         cpu_time_ns=1321,
         sampling_period=1000000,
         nframes=3,
     ),
     stack.StackSampleEvent(
         timestamp=2,
         thread_id=67892304,
         thread_native_id=123987,
         thread_name="MainThread",
コード例 #2
0
             ("foobar.py", 49, "func2"),
             ("foobar.py", 19, "func5"),
         ],
         nframes=3,
         exc_type=IOError,
     ),
 ],
 stack.StackSampleEvent: [
     stack.StackSampleEvent(
         timestamp=1,
         thread_id=67892304,
         thread_native_id=123987,
         thread_name="MainThread",
         trace_ids=set([1322219321]),
         frames=[
             ("foobar.py", 23, "func1"),
             ("foobar.py", 44, "func2"),
             ("foobar.py", 19, "func5"),
         ],
         wall_time_ns=1324,
         cpu_time_ns=1321,
         sampling_period=1000000,
         nframes=3,
     ),
     stack.StackSampleEvent(
         timestamp=2,
         thread_id=67892304,
         thread_native_id=123987,
         thread_name="MainThread",
         trace_ids=set([1322219321]),
         frames=[
             ("foobar.py", 23, "func1"),
コード例 #3
0
import os
import sys

from ddtrace.profiling import Profiler
from ddtrace.profiling.collector import stack

p = Profiler()
p.start(profile_children=False, stop_on_exit=False)

e = stack.StackSampleEvent()

p._profiler._recorder.push_event(e)
assert e in list(p._profiler._recorder.reset()[stack.StackSampleEvent])
assert e not in list(p._profiler._recorder.reset()[stack.StackSampleEvent])

pid = os.fork()

if pid == 0:
    e = stack.StackSampleEvent()
    p._profiler._recorder.push_event(e)
    assert list(p._profiler._recorder.reset()[stack.StackSampleEvent]) == []
    assert list(p._profiler._recorder.reset()[stack.StackSampleEvent]) == []
else:
    e = stack.StackSampleEvent()
    p._profiler._recorder.push_event(e)
    assert e in list(p._profiler._recorder.reset()[stack.StackSampleEvent])
    assert e not in list(p._profiler._recorder.reset()[stack.StackSampleEvent])
    p.stop(flush=False)
    pid, status = os.waitpid(pid, 0)
    sys.exit(os.WEXITSTATUS(status))