Skip to content

feat(tracing): auto-detect git information - #48

Merged
Naoray merged 2 commits into
mainfrom
feat/auto-detect-git-info
Feb 8, 2026
Merged

feat(tracing): auto-detect git information#48
Naoray merged 2 commits into
mainfrom
feat/auto-detect-git-info

Conversation

@Naoray

@Naoray Naoray commented Feb 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • Auto-detect git information (hash, branch, tag, dirty status) in the EnvironmentCollector using proc_open with a 1-second timeout
  • New GitInfoDetector class with static caching so git commands run only once per process
  • Graceful fallback when git is unavailable or not in a git repo (fields are simply omitted)
  • config('app.git_commit') still works as an override for git_hash
  • New git toggle under tracing config (default: true)
  • Backward compatible: git_commit key is preserved in environment data

Closes #38

Test plan

  • Existing EnvironmentCollector test still passes
  • Git data is included in environment context when available (mocked)
  • Graceful fallback when git is not available returns empty git info
  • config('app.git_commit') override takes precedence over auto-detected hash
  • Git detection is skipped when tracing.git config is false
  • git_commit backward-compatible key is set from git_hash
  • Git tracing is enabled by default
  • GitInfoDetector integration tests verify real git commands work
  • Static cache works correctly across multiple calls
  • Full test suite passes (289 tests, 914 assertions)

🤖 Generated with Claude Code

Closes #38

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Naoray

Naoray commented Feb 8, 2026

Copy link
Copy Markdown
Owner Author

Do we really need this? Does it add value?

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Naoray

Naoray commented Feb 8, 2026

Copy link
Copy Markdown
Owner Author

I think this does add value - knowing the deployed commit hash and branch when an error occurs is useful for debugging. I've simplified the implementation by replacing the raw proc_open with Laravel's Process facade, reducing runGitCommand() from ~50 lines to 3. The static cache ensures git commands only run once per process.

@Naoray
Naoray merged commit 3c29a81 into main Feb 8, 2026
11 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.

Auto-detect git information (branch, dirty status, tag)

1 participant