Skip to content

Commit

Permalink
Release 0.65.1 (#1328)
Browse files Browse the repository at this point in the history
* Prevent flushing traces of requests without actual PHP code (#1327)

Signed-off-by: Bob Weinand <[email protected]>

* Release 0.65.1

* fix formatting of notes in package.xml

Co-authored-by: Bob Weinand <[email protected]>
  • Loading branch information
labbati and bwoebi authored Sep 21, 2021
1 parent 7f7dda4 commit d440c99
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 15 deletions.
8 changes: 8 additions & 0 deletions ext/php7/auto_flush.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ ZEND_RESULT_CODE ddtrace_flush_tracer() {
zval trace, traces;
ddtrace_serialize_closed_spans(&trace);

// Prevent traces from requests not executing any PHP code:
// PG(during_request_startup) will only be set to 0 upon execution of any PHP code.
// e.g. php-fpm call with uri pointing to non-existing file, fpm status page, ...
if (PG(during_request_startup)) {
zend_array_destroy(Z_ARR(trace));
return SUCCESS;
}

if (zend_hash_num_elements(Z_ARR(trace)) == 0) {
zend_array_destroy(Z_ARR(trace));
ddtrace_log_debug("No finished traces to be sent to the agent");
Expand Down
8 changes: 8 additions & 0 deletions ext/php8/auto_flush.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ ZEND_RESULT_CODE ddtrace_flush_tracer() {
zval trace, traces;
ddtrace_serialize_closed_spans(&trace);

// Prevent traces from requests not executing any PHP code:
// PG(during_request_startup) will only be set to 0 upon execution of any PHP code.
// e.g. php-fpm call with uri pointing to non-existing file, fpm status page, ...
if (PG(during_request_startup)) {
zend_array_destroy(Z_ARR(trace));
return SUCCESS;
}

if (zend_hash_num_elements(Z_ARR(trace)) == 0) {
zend_array_destroy(Z_ARR(trace));
ddtrace_log_debug("No finished traces to be sent to the agent");
Expand Down
2 changes: 1 addition & 1 deletion ext/version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef PHP_DDTRACE_VERSION
// Must begin with a number for Debian packaging requirements
#define PHP_DDTRACE_VERSION "0.65.0"
#define PHP_DDTRACE_VERSION "0.65.1"
#endif
13 changes: 1 addition & 12 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,8 @@
</stability>
<license uri="https://github.com/DataDog/dd-trace-php/blob/master/LICENSE">BSD 3-Clause</license>
<notes>
**WARNING**: Resource names for “Lumen” applications will change by default to `GET /actual/uri/path` from the previous format `GET action_name` or `GET App\Controller@action_method`. You might need to adjust your monitors and filters for the change. In order to go back to the previous behavior, instead, you can temporarily set `DD_TRACE_URL_AS_RESOURCE_NAMES_ENABLED=false`

### Added
- Add functions ZAI support for PHP 5 and 7 #1300
- Add properties and exceptions ZAI implementations for PHP 5 #1306
- Enhance exception reporting on Laravel 5+ #1322

### Changed
- Remove src/dd-doctor.php #1316
- Honor DD_TRACE_URL_AS_RESOURCE_NAMES_ENABLED in Lumen resource naming #1318

### Fixed
- Fix CLI processes emitting empty root spans when CLI tracing is not enabled #1320
- Prevent flushing traces of requests without actual PHP code #1327
</notes>
<contents>
<dir name="/">
Expand Down
2 changes: 1 addition & 1 deletion src/DDTrace/Tracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class Tracer implements TracerInterface
* Must begin with a number for Debian packaging requirements
* Must use single-quotes for packaging script to work
*/
const VERSION = '0.65.0';
const VERSION = '0.65.1';

/**
* @var Span[][]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace DDTrace\Tests\Integrations\Custom\Autoloaded;

use DDTrace\Tests\Common\WebFrameworkTestCase;
use DDTrace\Tests\Frameworks\Util\Request\GetSpec;

final class NonExecutingEndpointsTracingTest extends WebFrameworkTestCase
{
protected static function getAppIndexScript()
{
return __DIR__ . '/../../../Frameworks/Custom/Version_Autoloaded/public/index.php';
}

public function testStatusPageDoesNotGenerateTraces()
{
if (\getenv('DD_TRACE_TEST_SAPI') != 'fpm-fcgi') {
$this->markTestSkipped('Only run under fpm-fcgi SAPI');
}

$traces = $this->tracesFromWebRequest(function () {
$this->call(GetSpec::create('No spans from status page', '/status'));
});

self::assertEmpty($traces);
}
}
2 changes: 1 addition & 1 deletion tests/Nginx/nginx-default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ http {

error_page 404 /{{index_file}};

location ~ \.php$ {
location ~ (/status|\.php)$ {
fastcgi_pass {{fcgi_host}}:{{fcgi_port}};
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;

Expand Down
1 change: 1 addition & 0 deletions tests/Sapi/PhpFpm/www.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ listen = {{fcgi_host}}:{{fcgi_port}}

pm = static
pm.max_children = 1
pm.status_path = /status
catch_workers_output = yes

{{envs}}
Expand Down

0 comments on commit d440c99

Please sign in to comment.