Skip to content

API for outputting different formats from CPython sampling profiler #138383

@taegyunkim

Description

@taegyunkim

Feature or enhancement

Proposal:

CPython 3.15 has statistical sampling profiler which currently only supports outputting

  1. pstats https://docs.python.org/3.15/library/profile.html#pstats.Stats
  2. collapsed format for flamegraphs
    class CollapsedStackCollector(StackTraceCollector):

Since it's still an early stage for the sampling profiler, I thought it would be nice to initiate discussion around how to support multiple different formats from the profiler.

  1. pprof
  2. OTel

are the formats that could potentially be added, but supporting those from CPython would introduce dependencies that might complicate building/testing and distributing CPython.

I'd like to suggest that CPython has an interface to support 3rd party collectors. What do you think?

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/pre-pep-api-for-outputting-different-formats-from-cpython-sampling-profiler/103490

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions