-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
- Loading branch information
Showing
24 changed files
with
509 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/Integrations/Integrations/Frankenphp/FrankenphpIntegration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace DDTrace\Integrations\Frankenphp; | ||
|
||
use DDTrace\HookData; | ||
use DDTrace\Integrations\Integration; | ||
use DDTrace\SpanStack; | ||
use DDTrace\Tag; | ||
use DDTrace\Type; | ||
|
||
use function DDTrace\consume_distributed_tracing_headers; | ||
|
||
class FrankenphpIntegration extends Integration | ||
{ | ||
const NAME = 'frankenphp'; | ||
|
||
public function getName() | ||
{ | ||
return self::NAME; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function requiresExplicitTraceAnalyticsEnabling() | ||
{ | ||
return false; | ||
} | ||
|
||
public function init() | ||
{ | ||
$integration = $this; | ||
|
||
ini_set("datadog.trace.auto_flush_enabled", 1); | ||
ini_set("datadog.trace.generate_root_span", 0); | ||
|
||
\DDTrace\install_hook('frankenphp_handle_request', function (HookData $hook) use ($integration) { | ||
$hook->data = \DDTrace\install_hook( | ||
$hook->args[0], | ||
function (HookData $hook) use ($integration) { | ||
$rootSpan = $hook->span(new SpanStack()); | ||
$rootSpan->name = "web.request"; | ||
$rootSpan->service = \ddtrace_config_app_name('frankenphp'); | ||
$rootSpan->type = Type::WEB_SERVLET; | ||
$rootSpan->meta[Tag::COMPONENT] = FrankenphpIntegration::NAME; | ||
$rootSpan->meta[Tag::SPAN_KIND] = Tag::SPAN_KIND_VALUE_SERVER; | ||
unset($rootSpan->meta["closure.declaration"]); | ||
$integration->addTraceAnalyticsIfEnabled($rootSpan); | ||
|
||
consume_distributed_tracing_headers(null); | ||
}, function (HookData $hook) { | ||
var_dump($hook->span()); | ||
} | ||
); | ||
}, function (HookData $hook) { | ||
\DDTrace\remove_hook($hook->data); | ||
}); | ||
|
||
return Integration::LOADED; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
// Prevent worker script termination when a client connection is interrupted | ||
ignore_user_abort(true); | ||
|
||
$handler = static function () { | ||
switch (explode("?", $_SERVER["REQUEST_URI"])[0]) { | ||
case "/error": | ||
throw new \Exception("Error page"); | ||
default: | ||
echo "Hello FrankenPHP!"; | ||
} | ||
error_log(var_export($_SERVER, true)); | ||
}; | ||
|
||
for ($running = true; $running;) { | ||
$running = \frankenphp_handle_request($handler); | ||
// error_log(var_export(\dd_trace_serialize_closed_spans(), true)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.