dd-trace-php icon indicating copy to clipboard operation
dd-trace-php copied to clipboard

feat: Source Code Integration

Open PROFeNoM opened this issue 1 year ago • 3 comments
trafficstars

TODO

  • [ ] Check system-tests

Description

Add three environment variables:

  • DD_GIT_REPOSITORY_URL string, default: empty
  • DD_GIT_COMMIT_SHA string, default: empty
  • DD_TRACE_GIT_METADATA_ENABLED bool, default: true

Add following steps:

  1. Check if DD_TRACE_GIT_METADATA_ENABLED is True.
  2. Check if git metadata is already provided by environment variables:
    • Check DD_GIT_REPOSITORY_URL and DD_GIT_COMMIT_SHA, if they exist, use metadata from them.
    • Check DD_TAGS, if it contains git.repository_url and git.commit.sha, use metadata from them.
  3. Exract git metadata from the git ~binary~ HEAD/refs/config files

Add metadata tags to the first span of each chunk:

  • _dd.git.repository_url for repository URL
  • _dd.git.commit.sha for commit hash

Reviewer checklist

  • [ ] Test coverage seems ok.
  • [ ] Appropriate labels assigned.

PROFeNoM avatar Jun 25 '24 12:06 PROFeNoM

Benchmarks

Benchmark execution time: 2024-07-19 14:26:13

Comparing candidate commit f69e3a9ef0ae656679b5dc21022872de7cc6caf7 in PR branch alex/feat/source_code_integration with baseline commit ce7d3a5fca2cfa6a4b32fcaf09896d22287122b8 in branch master.

Found 2 performance improvements and 4 performance regressions! Performance is the same for 172 metrics, 0 unstable metrics.

scenario:EmptyFileBench/benchEmptyFileOverhead

  • 🟩 execution_time [-197.237µs; -75.483µs] or [-7.205%; -2.758%]

scenario:LogsInjectionBench/benchLogsInfoInjection

  • 🟩 execution_time [-370.989ns; -192.411ns] or [-4.221%; -2.189%]

scenario:PDOBench/benchPDOOverheadWithDBM

  • 🟥 execution_time [+7.377µs; +15.061µs] or [+2.485%; +5.073%]

scenario:PHPRedisBench/benchRedisOverhead-opcache

  • 🟥 mem_peak [+66.368KB; +66.368KB] or [+2.267%; +2.267%]

scenario:SpanBench/benchOpenTelemetryAPI

  • 🟥 mem_peak [+898.812KB; +898.820KB] or [+2.737%; +2.737%]

scenario:SpanBench/benchOpenTelemetryAPI-opcache

  • 🟥 mem_peak [+897.431KB; +897.440KB] or [+2.962%; +2.962%]

pr-commenter[bot] avatar Jun 25 '24 13:06 pr-commenter[bot]

Codecov Report

Attention: Patch coverage is 78.43137% with 55 lines in your changes missing coverage. Please review.

Project coverage is 76.33%. Comparing base (ce7d3a5) to head (f69e3a9). Report is 4 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2731      +/-   ##
============================================
- Coverage     79.52%   76.33%   -3.19%     
  Complexity     2216     2216              
============================================
  Files           201      228      +27     
  Lines         22619    26899    +4280     
  Branches          0      989     +989     
============================================
+ Hits          17987    20533    +2546     
- Misses         4632     5840    +1208     
- Partials          0      526     +526     
Flag Coverage Δ
appsec-extension 69.19% <ø> (?)
tracer-extension 78.80% <78.43%> (-0.01%) :arrow_down:
tracer-php 75.78% <ø> (-4.77%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
ext/configuration.h 100.00% <ø> (ø)
ext/ddtrace.c 74.65% <100.00%> (+0.25%) :arrow_up:
ext/ddtrace.h 62.50% <ø> (ø)
ext/ddtrace_arginfo.h 100.00% <100.00%> (ø)
ext/serializer.c 81.44% <100.00%> (+0.16%) :arrow_up:
ext/span.h 100.00% <ø> (ø)
ext/git.c 74.17% <74.17%> (ø)

... and 30 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ce7d3a5...f69e3a9. Read the comment docs.

codecov-commenter avatar Jul 02 '24 14:07 codecov-commenter

Converting to draft until I add the new tests.

PROFeNoM avatar Jul 02 '24 14:07 PROFeNoM