Skip to content

Add git detector to telemetry#2409

Draft
jdecool wants to merge 3 commits into
flow-php:1.xfrom
jdecool:git-detector
Draft

Add git detector to telemetry#2409
jdecool wants to merge 3 commits into
flow-php:1.xfrom
jdecool:git-detector

Conversation

@jdecool

@jdecool jdecool commented May 31, 2026

Copy link
Copy Markdown
Contributor

Change Log


Added

  • Add git detector to telemetry
  • Add git detector to phpunit telemetry

Fixed

Changed

Removed

Deprecated

Security

Description


Sending PHPUnit data is very useful to see what happens during test execution.

But when used in an active project, where there are a lot of tests running, it's very interesting to have Git repository-related information.

So this PR adds a Git detector to attach some VCS information. As it could be interesting outside of the PHPUnit context, I've added it to the telemetry module.

@jdecool jdecool requested a review from norberttech as a code owner May 31, 2026 21:07
@codecov

codecov Bot commented May 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.89796% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.20%. Comparing base (6bfba82) to head (cdb3624).
⚠️ Report is 24 commits behind head on 1.x.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##                1.x    #2409      +/-   ##
============================================
+ Coverage     84.94%   85.20%   +0.25%     
- Complexity    20648    20971     +323     
============================================
  Files          1570     1588      +18     
  Lines         63532    64612    +1080     
============================================
+ Hits          53968    55050    +1082     
+ Misses         9564     9562       -2     
Components Coverage Δ
etl 89.35% <ø> (ø)
cli 89.40% <ø> (ø)
lib-array-dot 81.44% <ø> (ø)
lib-azure-sdk 64.44% <ø> (ø)
lib-doctrine-dbal-bulk 93.61% <ø> (ø)
lib-filesystem 85.03% <ø> (ø)
lib-types 91.98% <ø> (ø)
lib-parquet 68.89% <14.28%> (ø)
lib-parquet-viewer 82.26% <ø> (ø)
lib-snappy 89.82% <ø> (-0.45%) ⬇️
lib-dremel 0.00% <ø> (ø)
lib-postgresql 88.58% <33.33%> (+<0.01%) ⬆️
lib-telemetry 86.39% <99.04%> (+2.08%) ⬆️
bridge-filesystem-async-aws 92.74% <ø> (ø)
bridge-filesystem-azure 90.45% <ø> (ø)
bridge-monolog-http 97.86% <ø> (ø)
bridge-monolog-telemetry 94.11% <ø> (ø)
bridge-openapi-specification 92.07% <ø> (ø)
symfony-http-foundation 78.57% <ø> (ø)
bridge-psr18-telemetry 100.00% <ø> (ø)
bridge-psr3-telemetry 97.84% <ø> (ø)
bridge-psr7-telemetry 100.00% <ø> (ø)
bridge-telemetry-otlp 90.50% <ø> (ø)
bridge-symfony-http-foundation-telemetry 89.47% <ø> (ø)
bridge-symfony-filesystem-bundle 91.54% <100.00%> (ø)
bridge-symfony-filesystem-cache 98.14% <ø> (ø)
bridge-symfony-postgresql-bundle 94.55% <ø> (ø)
bridge-symfony-postgresql-cache 94.41% <ø> (ø)
bridge-symfony-postgresql-messenger 98.80% <ø> (ø)
bridge-symfony-postgresql-session 93.65% <ø> (ø)
bridge-symfony-telemetry-bundle 79.94% <95.58%> (+3.93%) ⬆️
adapter-chartjs 84.05% <ø> (ø)
adapter-csv 91.16% <ø> (ø)
adapter-doctrine 90.79% <ø> (ø)
adapter-elasticsearch 92.07% <ø> (ø)
adapter-google-sheet 99.18% <ø> (ø)
adapter-http 73.04% <ø> (ø)
adapter-json 88.63% <ø> (ø)
adapter-logger 50.00% <ø> (ø)
adapter-parquet 81.75% <ø> (ø)
adapter-text 74.13% <ø> (ø)
adapter-xml 83.40% <ø> (ø)
adapter-avro 0.00% <ø> (ø)
adapter-excel 94.21% <ø> (ø)
adapter-postgresql 91.42% <95.74%> (+0.53%) ⬆️
bridge-phpunit-postgresql 75.30% <ø> (ø)
bridge-phpunit-telemetry 80.12% <100.00%> (+0.03%) ⬆️
bridge-phpstan-types 0.00% <ø> (ø)
bridge-postgresql-valinor 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/lib/telemetry/src/Flow/Telemetry/Resource/Detector/GitDetector.php Outdated
@norberttech

Copy link
Copy Markdown
Member

@jdecool I really appreciate the PR but it's a bigger addition that should go through a Proposal Process since there are many architectural choices required in the implementation (like how to call git for example).
There is also a part that is not covered at all, it should be also possible to configure this detector through symfony telemetry bundle (which could be another task and this is what the proposal process is for).

We can keep this PR and work on it directly, but in the future I would appreciate opening a proper Proposal so we can first talk about how to implement the feature before writing any code

@jdecool

jdecool commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for your review and your comments.

No problem, I'm going to start the proposal process.

To explain this PR, I've initially planned to try to add custom detectors dynamically during the PHPUnit process, but I think that git detector could be added by default.

But you are right, it's a big change and should be discussed before implementing it.

@norberttech

Copy link
Copy Markdown
Member

To explain this PR, I've initially planned to try to add custom detectors dynamically during the PHPUnit process, but I think that git detector could be added by default.

I fully agree, git detector should be part of the telemetry, it should be optional though, but also exposed to the whole telemetry not only phpunit bridge

But you are right, it's a big change and should be discussed before implementing it.

I'm glad we are on the same page!

@norberttech

Copy link
Copy Markdown
Member

@jdecool if you would like to brainstorm this first, or have any questions about implementation, scope etc, you can always find me on Flow discord: https://discord.gg/flow-php or you can schedule with me a session online

@jdecool

jdecool commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @norberttech I've joined the discord.

I plan to work on this PR and the proposal process this weekend.

@github-actions github-actions Bot added size: L and removed size: M labels Jun 9, 2026
@github-actions github-actions Bot added size: M and removed size: L labels Jun 9, 2026
@github-actions github-actions Bot added size: L and removed size: M labels Jun 9, 2026
@jdecool jdecool marked this pull request as draft June 9, 2026 21:16
@@ -40,6 +41,7 @@ public static function create(Configuration $config): Telemetry
{
$telemetryResource = resource_detector()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would pass git_detector() here with other default detectors:

resource_detector([
  os_detector(),
  host_detector(),
  process_detector(),
  composer_detector(),
  environment_detector(),
  git_detector() 
]);

but ideally (can be handled in next pr) we should probably allow users to configure which detectors they want to use

* SCP-like SSH remotes (e.g. "git@github.com:org/repo.git") carry no secret and
* are returned untouched, as are URLs that cannot be parsed.
*/
private function sanitizeRepositoryUrl(string $url): string

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure how much I like that sanitization is embedded into GitDetector which seems to be breaking his single responsibility.

I think this whole sanitization logic should be extracted to standalone class, properly unit tested and used in GitDetector as (new RemoteUrlSanitizer())->sanitize($remoteUrl)

@norberttech

Copy link
Copy Markdown
Member

its looking good @jdecool !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants