Skip to content

CMake Telemetry Modules#23

Merged
ednolan merged 8 commits intobemanproject:mainfrom
steve-downey:telemetry
Apr 13, 2026
Merged

CMake Telemetry Modules#23
ednolan merged 8 commits intobemanproject:mainfrom
steve-downey:telemetry

Conversation

@steve-downey
Copy link
Copy Markdown
Member

@steve-downey steve-downey commented Feb 8, 2026

Configuration and callback scripts for using cmake_instrumentation.

steve-downey pushed a commit to steve-downey/infra that referenced this pull request Feb 14, 2026
Fix missing EOF at end of containers/install_sys.sh
Copy link
Copy Markdown
Member

@ednolan ednolan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to have the following changes made before we merge this in:

  • Because we vendor infra/, including docs/tracing_example.png means we automatically add half a megabyte to the size of all beman repositories; not to mention that if we change the image, the git history needs to include both of them. I don't think we need the image for users to understand what this does.

  • The word "telemetry" can have a connotation, not intended here, of software that collects some information and then "phones home," like Firefox telemetry. I'd rather call this "BuildProfiling" or "BuildTimeProfiling" or "BuildPerformanceProfiling" than "BuildTelemetry".

  • Ever since bemanproject/exemplar@df40a6d, we've been bringing in beman_install_library via a direct include() of the vendored file, rather than with find_package() and -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES. As such, I think we should remove BuildTelemetry.cmake and adjust the documentation in infra to say:

    include(infra/cmake/BuildTelemetryConfig.cmake)
    configure_build_telemetry()

    rather than

    find_package(BuildTelemetry)
    configure_build_telemetry()

    I'm aware that find_package is more of a CMake best practice, but I'm of the opinion that maybe we can transition to using it over direct includes if we convert infra to a proper package-managed package rather than a vendored directory, and as long as it's vendored it doesn't make sense to impose the burden of adding -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES; also, it shouldn't be inconsistent with beman-install-library.cmake.

    I know that this kills the ability to toggle enabling/disabling telemetry by choosing whether to specify the -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES, but since Beman is a project where all the libraries are based on a project template, and we can now bring them all up to date with the latest copy of that template, there's no reason not to just have every library have a call to configure_build_telemetry() in its top level CMakeLists.txt.

Other than those items, looks good.

@steve-downey
Copy link
Copy Markdown
Member Author

I'd prefer to have the following changes made before we merge this in:

  • Because we vendor infra/, including docs/tracing_example.png means we automatically add half a megabyte to the size of all beman repositories; not to mention that if we change the image, the git history needs to include both of them. I don't think we need the image for users to understand what this does.

I've explained this to a few hundred people in the last couple months. Most of them needed pictures. But, I agree, thinking about it, they don't all need the picture in repo. Maybe stash it in a wiki here, or in bemanproject/beman or somewhere else.

  • The word "telemetry" can have a connotation, not intended here, of software that collects some information and then "phones home," like Firefox telemetry. I'd rather call this "BuildProfiling" or "BuildTimeProfiling" or "BuildPerformanceProfiling" than "BuildTelemetry".

Naming is hard, and instrumentation also has a bunch of issues. Telemetry is one of the actual use cases for the ~15K CMake projects I'm applying this to now. Although I don't expect it to change much, I'd like to not have to have this fork drift too far from what I've got going into production to monitor integration build perfomance.

  • Ever since bemanproject/exemplar@df40a6d, we've been bringing in beman_install_library via a direct include() of the vendored file, rather than with find_package() and -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES. As such, I think we should remove BuildTelemetry.cmake and adjust the documentation in infra to say:
    include(infra/cmake/BuildTelemetryConfig.cmake)
    configure_build_telemetry()

We can doc this either way, but as an actual external reused module is how it is being rolled out. Vendoring in and modifying many many packages was a non-starter. The two mechanisms are entirely equivalent.
I'd like to have a better solution for packaging. Although for the loose coupling we have and the rate of change, vendoring in means we don't break everything at once.

rather than

find_package(BuildTelemetry)
configure_build_telemetry()

I'm aware that find_package is more of a CMake best practice, but I'm of the opinion that maybe we can transition to using it over direct includes if we convert infra to a proper package-managed package rather than a vendored directory, and as long as it's vendored it doesn't make sense to impose the burden of adding -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES; also, it shouldn't be inconsistent with beman-install-library.cmake.

You can have both. The include form right now pulls in the same code as the find_package form. It's not one or the other, it's either and both.

include(infra/cmake/BuildTelemetry.cmake)

or

find_package(BuiltTelemetry)

or

-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=BuildTelemetry.cmake

all do the same thing, and compose to make sure they are only done once in any case. Tests are there to check that instrumentation does not get enabled twice.

I know that this kills the ability to toggle enabling/disabling telemetry by choosing whether to specify the -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES, but since Beman is a project where all the libraries are based on a project template, and we can now bring them all up to date with the latest copy of that template, there's no reason not to just have every library have a call to configure_build_telemetry() in its top level CMakeLists.txt.

Good news/Bad news -- I've started using infra outside Beman?

https://github.com/steve-downey/example

and

https://github.com/steve-downey/surround where example needs to be pushed back into soon.

beman_install_library is a big win, and the actions.

steve-downey and others added 8 commits April 13, 2026 09:23
Add tools for configuring and using the cmake_instrumentation available as an
experimental feature in CMake 4.2.

https://cmake.org/cmake/help/latest/command/cmake_instrumentation.html

This module sets the CMAKE_EXPERIMENTAL_INSTRUMENTATION gate with the GUID for
CMake 4.2.

It sets a single callback script and processes all current HOOKs copying the
Google Trace format json files to a known location for further processing.
lint

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
lint

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
reformat

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Improve the diagnostic messages for different versions of CMake.  Remove the
min required call.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@steve-downey
Copy link
Copy Markdown
Member Author

Rebased on main

@ednolan ednolan merged commit 78c9c0f into bemanproject:main Apr 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants