Skip to content

Commit

Permalink
style: Remove some debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
PROFeNoM committed Feb 19, 2025
1 parent f0ccfa3 commit 43f3bf1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
28 changes: 8 additions & 20 deletions src/DDTrace/Integrations/Roadrunner/RoadrunnerIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use DDTrace\HookData;
use DDTrace\Integrations\Integration;
use DDTrace\Log\Logger;
use DDTrace\Tag;
use DDTrace\Type;
use DDTrace\Util\Normalizer;
Expand Down Expand Up @@ -158,28 +157,22 @@ function (HookData $hook) use (&$inferredSpan, &$activeSpan, &$suppressResponse,
return;
}

$inferredProxyServicesEnabled = \dd_trace_env_config('DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED');
$inferredSpan = null;
if ($inferredProxyServicesEnabled && $retval && $retval->headers) {
// $retval->headers is an array of arrays, so we need to flatten it
// for instance: "X-Dd-Proxy" -> {0: "aws-apigateway"}
// should become: "x-dd-proxy" -> "aws-apigateway"
$headers = [];
$headers = [];
if ($retval) {
foreach ($retval->headers as $headername => $header) {
$header = implode(", ", $header); // Headers that we are interested in should be single-valued
$header = implode(", ", $header);
$headers[strtolower($headername)] = $header;
}
Logger::get()->debug(var_export($headers, true));
// Convert $retval->headers keys to lowercase
}

$inferredProxyServicesEnabled = \dd_trace_env_config('DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED');
$inferredSpan = null;
if ($inferredProxyServicesEnabled && $headers) {
$inferredSpan = \DDTrace\start_inferred_span($headers);
Logger::get()->debug("Inferred span? " . ($inferredSpan ? "yes" : "no"));
}
$hook->data['inferredSpan'] = $inferredSpan;

Logger::get()->debug("Starting request span");
$activeSpan = $inferredSpan ? \DDTrace\start_span() : \DDTrace\start_trace_span();
Logger::get()->debug("Active Span ID: " . $activeSpan->id);
Logger::get()->debug("Created root span");

$activeSpan->service = $service;
$activeSpan->name = "web.request";
Expand All @@ -199,11 +192,6 @@ function (HookData $hook) use (&$inferredSpan, &$activeSpan, &$suppressResponse,
$activeSpan = null;
$inferredSpan = null;
} else {
$headers = [];
foreach ($retval->headers as $headername => $header) {
$header = implode(", ", $header);
$headers[strtolower($headername)] = $header;
}
\DDTrace\consume_distributed_tracing_headers(function ($headername) use ($headers) {
return $headers[$headername] ?? null;
});
Expand Down
7 changes: 1 addition & 6 deletions src/DDTrace/Integrations/Swoole/SwooleIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use DDTrace\HookData;
use DDTrace\Integrations\Integration;
use DDTrace\Log\Logger;
use DDTrace\SpanStack;
use DDTrace\Tag;
use DDTrace\Type;
Expand Down Expand Up @@ -44,12 +43,10 @@ function (HookData $hook) use ($integration, $server, $scheme) {
$inferredSpan = null;
if ($inferredProxyServicesEnabled) {
$inferredSpan = \DDTrace\start_inferred_span($request->header);
Logger::get()->debug("Inferred span? " . ($inferredSpan ? "yes" : "no"));
}
$hook->data['inferredSpan'] = $inferredSpan;

$rootSpan = $hook->span($inferredSpan ?: new SpanStack());
Logger::get()->debug("Created root span");
$rootSpan->name = "web.request";
$rootSpan->service = \ddtrace_config_app_name('swoole');
$rootSpan->type = Type::WEB_SERVLET;
Expand Down Expand Up @@ -117,12 +114,10 @@ function (HookData $hook) use ($integration, $server, $scheme) {
function (HookData $hook) {
$inferredSpan = $hook->data['inferredSpan'];
if ($inferredSpan) {
Logger::get()->debug("Closing inferred span");
$autofinishConfig = ini_get('datadog.autofinish_spans');
ini_set('datadog.autofinish_spans', 'true');
\DDTrace\switch_stack($inferredSpan);
dd_trace_close_all_spans_and_flush();
//dd_trace_synchronous_flush(1);
//set_distributed_tracing_context("0", "0");
ini_set('datadog.autofinish_spans', $autofinishConfig);
}
}
Expand Down

0 comments on commit 43f3bf1

Please sign in to comment.