Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Symfony Command Hook After Execution #2492

Merged
merged 2 commits into from
Jan 30, 2024
Merged

Conversation

PROFeNoM
Copy link
Contributor

Description

Fixes #2427

This PR should have been included with #2436

TL;DR of the issue:

Could not add hook to MyCommand::run with more than datadog.trace.hook_limit = 100 installed hooks in /opt/datadog-php/dd-trace-sources/bridge/_generated_integrations.php on line 4014; This message is only displayed once. Specify DD_TRACE_ONCE_LOGS=0 to show all messages.

The current implementation of the command hooks adds a hook to a <scope>::run if it wasn't already added. This could, theoretically, lead to multiple hooks added when considering numerous inheritors.

About the fix: Considering that in the previous version the hook was made on Symfony\Component\Console\Command\Command::__construct, it means that $scope fundamentally represents a Symfony\Component\Console\Command\Command instance. From this, the new implementation directly hooks Symfony\Component\Console\Command\Command::run instead of adding a seemingly unnecessary intermediary step.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@PROFeNoM PROFeNoM requested a review from a team as a code owner January 29, 2024 12:12
@PROFeNoM PROFeNoM self-assigned this Jan 29, 2024
@PROFeNoM PROFeNoM changed the base branch from ddtrace-0.97.0 to master January 29, 2024 12:12
@PROFeNoM PROFeNoM added 🐛 bug Something isn't working cat:integration labels Jan 29, 2024
@PROFeNoM PROFeNoM changed the title Remove Symfony Command Hook After Execution #2436 Remove Symfony Command Hook After Execution Jan 29, 2024

$symfonyCommandsIntegrated[$scope] = true;

\DDTrace\trace_method($scope, 'run', [
Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume this was an artifact of pre-historical times when we had no support for abstract method hooks?

At a glance this fix looks pretty good to me.

@pr-commenter
Copy link

pr-commenter bot commented Jan 29, 2024

Benchmarks

Benchmark execution time: 2024-01-29 13:18:43

Comparing candidate commit 210f0c0 in PR branch alex/issue/gh2427-bis with baseline commit 8beff3e in branch master.

Found 1 performance improvements and 0 performance regressions! Performance is the same for 40 metrics, 49 unstable metrics.

scenario:PHPRedisBench/benchRedisBaseline

  • 🟩 execution_time [-386.206µs; -258.906µs] or [-12.119%; -8.124%]

@PROFeNoM PROFeNoM merged commit 679da8e into master Jan 30, 2024
528 of 530 checks passed
@PROFeNoM PROFeNoM deleted the alex/issue/gh2427-bis branch January 30, 2024 16:06
@github-actions github-actions bot added this to the 0.98.0 milestone Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working cat:integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Memory leaking with hooks limit reached after upgrade from 0.90.0 to 0.91.2
2 participants