DataDog / dd-trace-php

Datadog PHP Clients
https://docs.datadoghq.com/tracing/setup/php
Other
487 stars 152 forks source link

feat: Source Code Integration #2731

Closed PROFeNoM closed 2 months ago

PROFeNoM commented 3 months ago

AIDM-195

TODO

Description

Add three environment variables:

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:

Reviewer checklist

pr-commenter[bot] commented 3 months ago

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

scenario:LogsInjectionBench/benchLogsInfoInjection

scenario:PDOBench/benchPDOOverheadWithDBM

scenario:PHPRedisBench/benchRedisOverhead-opcache

scenario:SpanBench/benchOpenTelemetryAPI

scenario:SpanBench/benchOpenTelemetryAPI-opcache

codecov-commenter commented 3 months ago

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](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731/graphs/tree.svg?width=650&height=150&src=pr&token=eXio8H7vwF&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog)](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) ```diff @@ 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](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | Coverage Δ | | |---|---|---| | [appsec-extension](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `69.19% <ø> (?)` | | | [tracer-extension](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `78.80% <78.43%> (-0.01%)` | :arrow_down: | | [tracer-php](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | `75.78% <ø> (-4.77%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) | Coverage Δ | | |---|---|---| | [ext/configuration.h](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731?src=pr&el=tree&filepath=ext%2Fconfiguration.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#diff-ZXh0L2NvbmZpZ3VyYXRpb24uaA==) | `100.00% <ø> (ø)` | | | [ext/ddtrace.c](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731?src=pr&el=tree&filepath=ext%2Fddtrace.c&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#diff-ZXh0L2RkdHJhY2UuYw==) | `74.65% <100.00%> (+0.25%)` | :arrow_up: | | [ext/ddtrace.h](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731?src=pr&el=tree&filepath=ext%2Fddtrace.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#diff-ZXh0L2RkdHJhY2UuaA==) | `62.50% <ø> (ø)` | | | [ext/ddtrace\_arginfo.h](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731?src=pr&el=tree&filepath=ext%2Fddtrace_arginfo.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#diff-ZXh0L2RkdHJhY2VfYXJnaW5mby5o) | `100.00% <100.00%> (ø)` | | | [ext/serializer.c](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731?src=pr&el=tree&filepath=ext%2Fserializer.c&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#diff-ZXh0L3NlcmlhbGl6ZXIuYw==) | `81.44% <100.00%> (+0.16%)` | :arrow_up: | | [ext/span.h](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731?src=pr&el=tree&filepath=ext%2Fspan.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#diff-ZXh0L3NwYW4uaA==) | `100.00% <ø> (ø)` | | | [ext/git.c](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731?src=pr&el=tree&filepath=ext%2Fgit.c&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog#diff-ZXh0L2dpdC5j) | `74.17% <74.17%> (ø)` | | ... and [30 files with indirect coverage changes](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731?dropdown=coverage&src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog). Last update [ce7d3a5...f69e3a9](https://app.codecov.io/gh/DataDog/dd-trace-php/pull/2731?dropdown=coverage&src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DataDog).
PROFeNoM commented 3 months ago

Converting to draft until I add the new tests.