Skip to content

Commit

Permalink
Add http.route and appsec params to wordpress
Browse files Browse the repository at this point in the history
  • Loading branch information
estringana committed Dec 28, 2023
1 parent cd8c66e commit a35d80b
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ public function load(WordPressIntegration $integration)
$span->meta[Tag::COMPONENT] = WordPressIntegration::NAME;
});

\DDTrace\hook_method('WP', 'main', null, function ($This, $scope, $args) {
if (\property_exists($This, 'did_permalink') && $This->did_permalink === true) {
$rootSpan = \DDTrace\root_span();
if (\property_exists($This, 'matched_rule')) {
$rootSpan->meta[Tag::HTTP_ROUTE] = $This->matched_rule;
}
if (\method_exists($route, 'parameters') &&
function_exists('\datadog\appsec\push_params') &&
\property_exists($This, 'query_vars')) {
$parameters = $This->query_vars;
if (count($parameters) > 0) {
\datadog\appsec\push_params($parameters);
}
}
}
});

\DDTrace\trace_method('WP', 'init', function (SpanData $span) use ($service) {
$span->name = $span->resource = 'WP.init';
$span->type = Type::WEB_SERVLET;
Expand Down

0 comments on commit a35d80b

Please sign in to comment.