Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:DataDog/dd-trace-php into labbati/au…
Browse files Browse the repository at this point in the history
…toinstrumentation
  • Loading branch information
labbati committed Jan 21, 2019
2 parents 1d67604 + 5347c1f commit c48b9a8
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 25 deletions.
18 changes: 7 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ aliases:
paths:
- vendor/

- &STEP_COMPOSER_INSTALL_LEGACY
run:
name: Installing composer dependencies without PHPStan
command: composer remove phpstan/phpstan --no-interaction --no-plugins --dev

- &STEP_COMPOSER_INSTALL
run:
name: Installing dependencies with composer
Expand Down Expand Up @@ -253,9 +248,12 @@ jobs:
- <<: *STEP_COMPOSER_CACHE_RESTORE
- <<: *STEP_COMPOSER_INSTALL
- <<: *STEP_COMPOSER_CACHE_SAVE
- run:
name: Install phpstan
command: composer global require phpstan/phpstan
- run:
name: Running phpstan
command: composer static-analyze
command: PATH=$PATH:~/.composer/vendor/bin composer static-analyze

"php-5.4":
working_directory: ~/datadog
Expand Down Expand Up @@ -310,7 +308,6 @@ jobs:
- <<: *STEP_EXT_INSTALL
- <<: *STEP_COMPOSER_SELF_UPDATE
- <<: *STEP_COMPOSER_CACHE_RESTORE
- <<: *STEP_COMPOSER_INSTALL_LEGACY
- <<: *STEP_COMPOSER_CACHE_SAVE
- <<: *STEP_PREPARE_TEST_RESULTS_DIR
- <<: *STEP_EXPORT_CI_ENV
Expand Down Expand Up @@ -345,7 +342,6 @@ jobs:
- <<: *STEP_EXT_INSTALL
- <<: *STEP_COMPOSER_SELF_UPDATE
- <<: *STEP_COMPOSER_CACHE_RESTORE
- <<: *STEP_COMPOSER_INSTALL_LEGACY
- <<: *STEP_COMPOSER_CACHE_SAVE
- <<: *STEP_PREPARE_TEST_RESULTS_DIR
- <<: *STEP_EXPORT_CI_ENV
Expand Down Expand Up @@ -504,11 +500,11 @@ workflows:
jobs:
- "5.4 20100525": &BUILD_PACKAGE_FORKFLOW
filters:
# tags:
# only: /(^build$)|(^[v]?[0-9]+(\.[0-9]+)*$)/
tags:
only: /(^build$)|(^[v]?[0-9]+(\.[0-9]+)*$)/
branches:
# Always build on master
ignore: /^(?!labbati).*/
ignore: /^((?!master)|(?!dev)).*/
- "5.6 20131106": *BUILD_PACKAGE_FORKFLOW
- "7.0 20151012": *BUILD_PACKAGE_FORKFLOW
- "7.1 20160303": *BUILD_PACKAGE_FORKFLOW
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"require-dev": {
"g1a/composer-test-scenarios": "~3.0",
"mockery/mockery": "*",
"phpstan/phpstan": "^0.10.5",
"phpunit/phpunit": "^4",
"squizlabs/php_codesniffer": "^3.3.0",
"symfony/process": "*"
Expand Down Expand Up @@ -96,6 +95,7 @@
"test-integrations-54": [
"@composer scenario:update",
"@composer scenario default",
<<<<<<< HEAD
"@composer test -- tests/Integrations/Curl",
"@composer test -- tests/Integrations/Memcached",
"@composer test -- tests/Integrations/Mysqli",
Expand All @@ -107,6 +107,9 @@
"@composer scenario predis1",
"@composer test -- tests/Integrations/Predis",
"@composer scenario default"
=======
"@composer test -- tests/Integrations/PDO"
>>>>>>> 5347c1feff4c08016e629817ac30da9b758e9aa1
],
"test-integrations-56": [
"@composer scenario:update",
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ x-aliases:
services:
'5.4-debug': { <<: *base_php_service, build: 'dockerfiles/debug_php-5.4' }
'5.4': { <<: *base_php_service, image: 'datadog/docker-library:ddtrace_php_5_4' }

'5.6': { <<: *base_56_service, image: 'datadog/docker-library:ddtrace_php_5_6' }
'5.6-zts': { <<: *base_56_service, image: 'circleci/php:5.6-zts' }
'5.6-debug': { <<: *base_56_service, build: 'dockerfiles/debug_php-5.6' }
Expand Down
6 changes: 3 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
parameters:
excludes_analyse:
- %rootDir%/../../../src/DDTrace/Integrations
- %rootDir%/../../../src/DDTrace/OpenTracer
- src/DDTrace/Integrations
- src/DDTrace/OpenTracer
# Temporarily disabling as it uses \OpenTracing\GlobalTracer.php
- %rootDir%/../../../src/DDTrace/GlobalTracer.php
- src/DDTrace/GlobalTracer.php
3 changes: 2 additions & 1 deletion src/DDTrace/Integrations/Curl/CurlIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use DDTrace\Type;
use DDTrace\Util\ArrayKVStore;
use DDTrace\GlobalTracer;
use DDTrace\Util\Environment;

/**
* Integration for curl php client.
Expand All @@ -24,7 +25,7 @@ class CurlIntegration
*/
public static function load()
{
if (!function_exists('curl_exec')) {
if (!function_exists('curl_exec') || Environment::matchesPhpVersion('5.4')) {
// `curl_exec` doesn't come from an autoloader, if it does not exists we can return this integration as
// not available.
return Integration::NOT_AVAILABLE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use DDTrace\Span;
use DDTrace\Tag;
use DDTrace\Type;
use DDTrace\Util\Environment;

/**
* ElasticSearch driver v1 Integration
Expand All @@ -18,7 +19,7 @@ class ElasticSearchIntegration

public static function load()
{
if (!class_exists('Elasticsearch\Client')) {
if (!class_exists('Elasticsearch\Client') || Environment::matchesPhpVersion('5.4')) {
return Integration::NOT_LOADED;
}

Expand Down
3 changes: 2 additions & 1 deletion src/DDTrace/Integrations/Eloquent/EloquentIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use DDTrace\Integrations\Integration;
use DDTrace\Tag;
use DDTrace\Type;
use DDTrace\Util\Environment;
use DDTrace\Util\TryCatchFinally;
use DDTrace\GlobalTracer;

Expand All @@ -14,7 +15,7 @@ class EloquentIntegration

public static function load()
{
if (!class_exists('Illuminate\Database\Eloquent\Builder')) {
if (!class_exists('Illuminate\Database\Eloquent\Builder') || Environment::matchesPhpVersion('5.4')) {
return Integration::NOT_LOADED;
}

Expand Down
5 changes: 5 additions & 0 deletions src/DDTrace/Integrations/Guzzle/V5/GuzzleIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use DDTrace\GlobalTracer;
use DDTrace\Http\Urls;
use DDTrace\Integrations\Integration;
use DDTrace\Util\Environment;
use GuzzleHttp\Message\ResponseInterface;

class GuzzleIntegration extends Integration
Expand All @@ -19,6 +20,10 @@ class GuzzleIntegration extends Integration

protected static function loadIntegration()
{
if (Environment::matchesPhpVersion('5.4')) {
return;
}

self::traceMethod('send', function (Span $span, array $args) {
list($request) = $args;
GuzzleIntegration::injectDistributedTracingHeaders($request, $span);
Expand Down
3 changes: 2 additions & 1 deletion src/DDTrace/Integrations/Memcached/MemcachedIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use DDTrace\Obfuscation;
use DDTrace\Tag;
use DDTrace\Type;
use DDTrace\Util\Environment;
use DDTrace\Util\TryCatchFinally;
use DDTrace\GlobalTracer;

Expand All @@ -28,7 +29,7 @@ class MemcachedIntegration

public static function load()
{
if (!class_exists('Memcached')) {
if (!class_exists('Memcached') || Environment::matchesPhpVersion('5.4')) {
// Memcached is provided through an extension and not through a class loader.
return Integration::NOT_AVAILABLE;
}
Expand Down
5 changes: 5 additions & 0 deletions src/DDTrace/Integrations/Mongo/MongoClientIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
use DDTrace\Tag;
use DDTrace\Obfuscation;
use DDTrace\Integrations\Integration;
use DDTrace\Util\Environment;

final class MongoClientIntegration extends Integration
{
const CLASS_NAME = 'MongoClient';

protected static function loadIntegration()
{
if (Environment::matchesPhpVersion('5.4')) {
return;
}

// MongoClient::__construct ([ string $server = "mongodb://localhost:27017"
// [, array $options = array("connect" => TRUE) [, array $driver_options ]]] )
self::traceMethod('__construct', function (Span $span, array $args) {
Expand Down
5 changes: 5 additions & 0 deletions src/DDTrace/Integrations/Mongo/MongoCollectionIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
use DDTrace\Span;
use DDTrace\Tag;
use DDTrace\Integrations\Integration;
use DDTrace\Util\Environment;

final class MongoCollectionIntegration extends Integration
{
const CLASS_NAME = 'MongoCollection';

protected static function loadIntegration()
{
if (Environment::matchesPhpVersion('5.4')) {
return;
}

// MongoCollection::__construct ( MongoDB $db , string $name )
self::traceMethod('__construct', function (Span $span, array $args) {
$span->setTag(Tag::MONGODB_DATABASE, (string) $args[0]);
Expand Down
5 changes: 5 additions & 0 deletions src/DDTrace/Integrations/Mongo/MongoDBIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
use DDTrace\Span;
use DDTrace\Tag;
use DDTrace\Integrations\Integration;
use DDTrace\Util\Environment;

final class MongoDBIntegration extends Integration
{
const CLASS_NAME = 'MongoDB';

protected static function loadIntegration()
{
if (Environment::matchesPhpVersion('5.4')) {
return;
}

// array MongoDB::command ( array $command [, array $options = array() [, string &$hash ]] )
self::traceMethod('command', function (Span $span, array $args) {
if (isset($args[0]['query'])) {
Expand Down
4 changes: 3 additions & 1 deletion src/DDTrace/Integrations/Mongo/MongoIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
use DDTrace\Tag;
use DDTrace\Type;
use DDTrace\Integrations\Integration;
use DDTrace\Util\Environment;

final class MongoIntegration
{
const NAME = 'mongo';

public static function load()
{
if (!extension_loaded('mongo')) {
if (!extension_loaded('mongo') || Environment::matchesPhpVersion('5.4')) {
// Mongodb integration is provided through an extension and not through a class loader.
return Integration::NOT_AVAILABLE;
}

MongoClientIntegration::load();
MongoDBIntegration::load();
MongoCollectionIntegration::load();
Expand Down
3 changes: 2 additions & 1 deletion src/DDTrace/Integrations/Mysqli/MysqliIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use DDTrace\Integrations\Integration;
use DDTrace\Tag;
use DDTrace\Type;
use DDTrace\Util\Environment;
use DDTrace\Util\ObjectKVStore;
use DDTrace\Util\TryCatchFinally;
use DDTrace\GlobalTracer;
Expand All @@ -15,7 +16,7 @@ class MysqliIntegration

public static function load()
{
if (!extension_loaded('mysqli')) {
if (!extension_loaded('mysqli') || Environment::matchesPhpVersion('5.4')) {
// Memcached is provided through an extension and not through a class loader.
return Integration::NOT_AVAILABLE;
}
Expand Down
3 changes: 2 additions & 1 deletion src/DDTrace/Integrations/Predis/PredisIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use DDTrace\Tag;
use DDTrace\Type;
use DDTrace\GlobalTracer;
use DDTrace\Util\Environment;
use DDTrace\Util\TryCatchFinally;
use Predis\Configuration\OptionsInterface;
use Predis\Pipeline\Pipeline;
Expand All @@ -29,7 +30,7 @@ class PredisIntegration
*/
public static function load()
{
if (!class_exists('\Predis\Client')) {
if (!class_exists('\Predis\Client') || Environment::matchesPhpVersion('5.4')) {
return Integration::NOT_LOADED;
}

Expand Down
4 changes: 2 additions & 2 deletions src/ext/ddtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ static PHP_FUNCTION(dd_trace_noop) {
}

static const zend_function_entry ddtrace_functions[] = {PHP_FE(dd_trace, NULL) PHP_FE(dd_trace_reset, NULL)
PHP_FE(dd_trace_noop, NULL)
PHP_FE(dd_untrace, NULL) ZEND_FE_END};
PHP_FE(dd_trace_noop, NULL) PHP_FE(dd_untrace, NULL)
ZEND_FE_END};

zend_module_entry ddtrace_module_entry = {STANDARD_MODULE_HEADER, PHP_DDTRACE_EXTNAME, ddtrace_functions,
PHP_MINIT(ddtrace), PHP_MSHUTDOWN(ddtrace), PHP_RINIT(ddtrace),
Expand Down
5 changes: 5 additions & 0 deletions src/ext/dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ static zend_always_inline zend_bool wrap_and_run(zend_execute_data *execute_data

zval *return_value = (RETURN_VALUE_USED(opline) ? EX_VAR(EX(opline)->result.var) : &rv);
execute_fcall(dispatch, EX(call), &return_value TSRMLS_CC);

if (!RETURN_VALUE_USED(opline)) {
zval_dtor(&rv);
}
#endif

dispatch->flags ^= BUSY_FLAG;
Expand Down Expand Up @@ -378,6 +382,7 @@ static int update_opcode_leave(zend_execute_data *execute_data TSRMLS_DC) {

zend_vm_stack_clear_multiple(TSRMLS_CC);
#elif PHP_VERSION_ID < 70000
zend_vm_stack_clear_multiple(0 TSRMLS_CC);
EX(call)--;

zend_vm_stack_clear_multiple(0 TSRMLS_CC);
Expand Down
4 changes: 4 additions & 0 deletions src/ext/dispatch_compat_php5.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,15 @@ static zend_always_inline void setup_fcal_name(zend_execute_data *execute_data,
fci->params = (zval ***)safe_emalloc(sizeof(zval *), fci->param_count, 0);
zend_get_parameters_array_ex(fci->param_count, fci->params);
}
#if PHP_VERSION_ID < 50600
if (EG(return_value_ptr_ptr)) {
fci->retval_ptr_ptr = EG(return_value_ptr_ptr);
} else {
fci->retval_ptr_ptr = result;
}
#else
fci->retval_ptr_ptr = result;
#endif
}

void ddtrace_setup_fcall(zend_execute_data *execute_data, zend_fcall_info *fci, zval **result TSRMLS_DC) {
Expand Down

0 comments on commit c48b9a8

Please sign in to comment.