diff --git a/src/sentry/publish/sentry.php b/src/sentry/publish/sentry.php index 8fbfa03b8..b29c88d38 100644 --- a/src/sentry/publish/sentry.php +++ b/src/sentry/publish/sentry.php @@ -95,38 +95,36 @@ // Performance monitoring specific configuration 'tracing' => [ - 'enable' => [ - 'amqp' => env('SENTRY_TRACING_ENABLE_AMQP', true), - 'async_queue' => env('SENTRY_TRACING_ENABLE_ASYNC_QUEUE', true), - 'command' => env('SENTRY_TRACING_ENABLE_COMMAND', true), - 'crontab' => env('SENTRY_TRACING_ENABLE_CRONTAB', true), - 'kafka' => env('SENTRY_TRACING_ENABLE_KAFKA', true), - 'missing_routes' => env('SENTRY_TRACING_ENABLE_MISSING_ROUTES', true), - 'request' => env('SENTRY_TRACING_ENABLE_REQUEST', true), - ], - 'spans' => [ - 'cache' => env('SENTRY_TRACING_SPANS_CACHE', true), - 'coroutine' => env('SENTRY_TRACING_SPANS_COROUTINE', true), - 'db' => env('SENTRY_TRACING_SPANS_DB', true), - 'elasticsearch' => env('SENTRY_TRACING_SPANS_ELASTICSEARCH', true), - 'filesystem' => env('SENTRY_TRACING_SPANS_FILESYSTEM', true), - 'guzzle' => env('SENTRY_TRACING_SPANS_GUZZLE', true), - 'rpc' => env('SENTRY_TRACING_SPANS_RPC', true), - 'grpc' => env('SENTRY_TRACING_SPANS_GRPC', true), - 'redis' => env('SENTRY_TRACING_SPANS_REDIS', true), - 'sql_queries' => env('SENTRY_TRACING_SPANS_SQL_QUERIES', true), - 'view' => env('SENTRY_TRACING_SPANS_VIEW', true), - ], - 'extra_tags' => [ - 'amqp.result' => false, - 'annotation.result' => false, - 'db.sql.bindings' => true, - 'db.result' => false, - 'elasticsearch.result' => false, - 'http.response.body.contents' => false, - 'redis.result' => false, - 'rpc.result' => false, - ], + 'amqp' => env('SENTRY_TRACING_ENABLE_AMQP', true), + 'async_queue' => env('SENTRY_TRACING_ENABLE_ASYNC_QUEUE', true), + 'command' => env('SENTRY_TRACING_ENABLE_COMMAND', true), + 'crontab' => env('SENTRY_TRACING_ENABLE_CRONTAB', true), + 'kafka' => env('SENTRY_TRACING_ENABLE_KAFKA', true), + 'missing_routes' => env('SENTRY_TRACING_ENABLE_MISSING_ROUTES', true), + 'request' => env('SENTRY_TRACING_ENABLE_REQUEST', true), + ], + 'tracing_spans' => [ + 'cache' => env('SENTRY_TRACING_SPANS_CACHE', true), + 'coroutine' => env('SENTRY_TRACING_SPANS_COROUTINE', true), + 'db' => env('SENTRY_TRACING_SPANS_DB', true), + 'elasticsearch' => env('SENTRY_TRACING_SPANS_ELASTICSEARCH', true), + 'filesystem' => env('SENTRY_TRACING_SPANS_FILESYSTEM', true), + 'guzzle' => env('SENTRY_TRACING_SPANS_GUZZLE', true), + 'rpc' => env('SENTRY_TRACING_SPANS_RPC', true), + 'grpc' => env('SENTRY_TRACING_SPANS_GRPC', true), + 'redis' => env('SENTRY_TRACING_SPANS_REDIS', true), + 'sql_queries' => env('SENTRY_TRACING_SPANS_SQL_QUERIES', true), + 'view' => env('SENTRY_TRACING_SPANS_VIEW', true), + ], + 'tracing_tags' => [ + 'amqp.result' => false, + 'annotation.result' => false, + 'db.sql.bindings' => true, + 'db.result' => false, + 'elasticsearch.result' => false, + 'http.response.body.contents' => false, + 'redis.result' => false, + 'rpc.result' => false, ], 'crons' => [ diff --git a/src/sentry/src/Factory/ClientBuilderFactory.php b/src/sentry/src/Factory/ClientBuilderFactory.php index 8a6f5839d..aaa970ab1 100644 --- a/src/sentry/src/Factory/ClientBuilderFactory.php +++ b/src/sentry/src/Factory/ClientBuilderFactory.php @@ -34,6 +34,8 @@ class ClientBuilderFactory 'transport_channel_size', 'transport_concurrent_limit', 'tracing', + 'tracing_spans', + 'tracing_tags', ]; public function __invoke(ContainerInterface $container): ClientBuilder diff --git a/src/sentry/src/Feature.php b/src/sentry/src/Feature.php index 3eff414fd..6f052b672 100644 --- a/src/sentry/src/Feature.php +++ b/src/sentry/src/Feature.php @@ -33,11 +33,7 @@ public function isBreadcrumbEnabled(string $key, bool $default = true): bool public function isTracingEnabled(string $key, bool $default = true): bool { - if (! $this->config->get('sentry.enable_tracing', true)) { - return false; - } - - return (bool) $this->config->get('sentry.tracing.enable.' . $key, $default); + return (bool) $this->config->get('sentry.tracing.' . $key, $default); } public function isTracingSpanEnabled(string $key, bool $default = true): bool @@ -46,12 +42,20 @@ public function isTracingSpanEnabled(string $key, bool $default = true): bool return false; } - return (bool) $this->config->get('sentry.tracing.spans.' . $key, $default); + return (bool) $this->config->get('sentry.tracing_spans.' . $key, $default); + } + + public function isTracingTagEnabled(string $key, bool $default = false): bool + { + return (bool) ($this->config->get('sentry.tracing_tags', [])[$key] ?? $default); } + /** + * @deprecated since v3.1, will be removed in v3.2, use `isTracingTagEnabled` instead. + */ public function isTracingExtraTagEnabled(string $key, bool $default = false): bool { - return (bool) ($this->config->get('sentry.tracing.extra_tags', [])[$key] ?? $default); + return $this->isTracingTagEnabled($key, $default); } public function isCronsEnabled(): bool diff --git a/src/sentry/src/Listener/SetupSentryListener.php b/src/sentry/src/Listener/SetupSentryListener.php index cdfb46887..9fd11f9d4 100644 --- a/src/sentry/src/Listener/SetupSentryListener.php +++ b/src/sentry/src/Listener/SetupSentryListener.php @@ -41,25 +41,26 @@ class SetupSentryListener implements ListenerInterface 'sentry.breadcrumbs.redis', 'sentry.breadcrumbs.guzzle', 'sentry.breadcrumbs.logs', - // Tracing - 'sentry.enable_tracing', // Enable for tracing integrations - 'sentry.tracing.enable.amqp', - 'sentry.tracing.enable.async_queue', - 'sentry.tracing.enable.cache', - 'sentry.tracing.enable.command', - 'sentry.tracing.enable.crontab', - 'sentry.tracing.enable.kafka', - 'sentry.tracing.enable.request', + 'sentry.tracing.amqp', + 'sentry.tracing.async_queue', + 'sentry.tracing.command', + 'sentry.tracing.crontab', + 'sentry.tracing.kafka', + 'sentry.tracing.missing_routes', + 'sentry.tracing.request', // Enable for tracing Spans - 'sentry.tracing.spans.cache', - 'sentry.tracing.spans.coroutine', - 'sentry.tracing.spans.db', - 'sentry.tracing.spans.elasticsearch', - 'sentry.tracing.spans.guzzle', - 'sentry.tracing.spans.rpc', - 'sentry.tracing.spans.redis', - 'sentry.tracing.spans.sql_queries', + 'sentry.tracing_spans.cache', + 'sentry.tracing_spans.coroutine', + 'sentry.tracing_spans.db', + 'sentry.tracing_spans.elasticsearch', + 'sentry.tracing_spans.filesystem', + 'sentry.tracing_spans.guzzle', + 'sentry.tracing_spans.rpc', + 'sentry.tracing_spans.grpc', + 'sentry.tracing_spans.redis', + 'sentry.tracing_spans.sql_queries', + 'sentry.tracing_spans.view', ]; public function __construct( diff --git a/src/sentry/src/Switcher.php b/src/sentry/src/Switcher.php index 5f4151eb4..9cea61e6b 100644 --- a/src/sentry/src/Switcher.php +++ b/src/sentry/src/Switcher.php @@ -14,54 +14,35 @@ use Throwable; /** - * @deprecated since v3.1, use Feature instead, will be removed in v3.2 + * @deprecated since v3.1, use `Feature` instead, will be removed in v3.2 */ class Switcher extends Feature { - /** - * @deprecated since v3.1, use Feature::isEnabled() instead, will be removed in v3.2 - */ public function isEnable(string $key, bool $default = true): bool { return $this->isEnabled($key, $default); } - /** - * @deprecated since v3.1, use Feature::isBreadcrumbEnabled() instead, will be removed in v3.2 - */ public function isBreadcrumbEnable(string $key, bool $default = true): bool { return $this->isBreadcrumbEnabled($key, $default); } - /** - * @deprecated since v3.1, use Feature::isTracingEnabled() instead, will be removed in v3.2 - */ public function isTracingEnable(string $key, bool $default = true): bool { return $this->isTracingEnabled($key, $default); } - /** - * @deprecated since v3.1, use Feature::isTracingSpanEnabled() instead, will be removed in v3.2 - */ public function isTracingSpanEnable(string $key, bool $default = true): bool { return $this->isTracingSpanEnabled($key, $default); } - /** - * @deprecated since v3.1, use Feature::isTracingExtraTagEnabled() instead, will be removed in v3.2 - */ public function isTracingExtraTagEnable(string $key, bool $default = false): bool { - return $this->isTracingExtraTagEnabled($key, $default); + return $this->isTracingTagEnabled($key, $default); } - /** - * @deprecated since v3.1, use isExceptionIgnored instead, will be removed in v3.2 - * @see https://docs.sentry.io/platforms/php/configuration/options/#ignore_exceptions - */ public function isExceptionIgnored(string|Throwable $exception): bool { $ignoreExceptions = (array) $this->config->get('sentry.ignore_exceptions', []); @@ -75,9 +56,6 @@ public function isExceptionIgnored(string|Throwable $exception): bool return false; } - /** - * @deprecated since v3.1, use Feature::isCronsEnabled() instead, will be removed in v3.2 - */ public function isCronsEnable(): bool { return $this->isCronsEnabled(); diff --git a/src/sentry/src/Tracing/Aspect/DbAspect.php b/src/sentry/src/Tracing/Aspect/DbAspect.php index 50eed1971..f8e97902e 100644 --- a/src/sentry/src/Tracing/Aspect/DbAspect.php +++ b/src/sentry/src/Tracing/Aspect/DbAspect.php @@ -76,14 +76,14 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint) // 'server.port' => '', ]; - if ($this->feature->isTracingExtraTagEnabled('db.sql.bindings', true)) { + if ($this->feature->isTracingTagEnabled('db.sql.bindings', true)) { $data['db.sql.bindings'] = $arguments['arguments']['bindings'] ?? []; } return trace( function (Scope $scope) use ($proceedingJoinPoint) { $result = $proceedingJoinPoint->process(); - if ($this->feature->isTracingExtraTagEnabled('db.result')) { + if ($this->feature->isTracingTagEnabled('db.result')) { $scope->getSpan()?->setData([ 'db.result' => json_encode($result, JSON_UNESCAPED_UNICODE), ]); diff --git a/src/sentry/src/Tracing/Aspect/ElasticsearchAspect.php b/src/sentry/src/Tracing/Aspect/ElasticsearchAspect.php index 2274d37b7..08177576a 100644 --- a/src/sentry/src/Tracing/Aspect/ElasticsearchAspect.php +++ b/src/sentry/src/Tracing/Aspect/ElasticsearchAspect.php @@ -63,7 +63,7 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint) return trace( function (Scope $scope) use ($proceedingJoinPoint) { $result = $proceedingJoinPoint->process(); - if ($this->feature->isTracingExtraTagEnabled('elasticsearch.result')) { + if ($this->feature->isTracingTagEnabled('elasticsearch.result')) { $scope->getSpan()?->setData([ 'elasticsearch.result' => (string) json_encode($result, JSON_UNESCAPED_UNICODE), ]); diff --git a/src/sentry/src/Tracing/Aspect/GuzzleHttpClientAspect.php b/src/sentry/src/Tracing/Aspect/GuzzleHttpClientAspect.php index 202a2d51c..1080a7cd8 100644 --- a/src/sentry/src/Tracing/Aspect/GuzzleHttpClientAspect.php +++ b/src/sentry/src/Tracing/Aspect/GuzzleHttpClientAspect.php @@ -113,7 +113,7 @@ function (Scope $scope) use ($proceedingJoinPoint, $options, $guzzleConfig) { 'http.response_transfer_size' => $response->getHeaderLine('Content-Length'), ]); - if ($this->feature->isTracingExtraTagEnabled('http.response.body.contents')) { + if ($this->feature->isTracingTagEnabled('http.response.body.contents')) { $isTextual = \preg_match( '/^(text\/|application\/(json|xml|x-www-form-urlencoded))/i', $response->getHeaderLine('Content-Type') diff --git a/src/sentry/src/Tracing/Aspect/RedisAspect.php b/src/sentry/src/Tracing/Aspect/RedisAspect.php index f37d7e3a8..0567e8f43 100644 --- a/src/sentry/src/Tracing/Aspect/RedisAspect.php +++ b/src/sentry/src/Tracing/Aspect/RedisAspect.php @@ -80,7 +80,7 @@ class_exists(CommandExecuted::class) return trace( function (Scope $scope) use ($proceedingJoinPoint) { return tap($proceedingJoinPoint->process(), function ($result) use ($scope) { - if ($this->feature->isTracingExtraTagEnabled('redis.result')) { + if ($this->feature->isTracingTagEnabled('redis.result')) { $scope->getSpan()?->setData(['redis.result' => $result]); } }); diff --git a/src/sentry/src/Tracing/Aspect/RpcAspect.php b/src/sentry/src/Tracing/Aspect/RpcAspect.php index 43387230a..c3c3077b4 100644 --- a/src/sentry/src/Tracing/Aspect/RpcAspect.php +++ b/src/sentry/src/Tracing/Aspect/RpcAspect.php @@ -112,7 +112,7 @@ function (Scope $scope) use ($proceedingJoinPoint) { $rpcCtx->set(Constants::TRACE_CARRIER, $carrier->toJson()); } return tap($proceedingJoinPoint->process(), function ($result) use ($span) { - if ($span && $this->feature->isTracingExtraTagEnabled('rpc.result')) { + if ($span && $this->feature->isTracingTagEnabled('rpc.result')) { $span->setData(['rpc.result' => $result]); } }); diff --git a/src/sentry/src/Tracing/Aspect/TraceAnnotationAspect.php b/src/sentry/src/Tracing/Aspect/TraceAnnotationAspect.php index 0a5cc4182..bf4fa4260 100644 --- a/src/sentry/src/Tracing/Aspect/TraceAnnotationAspect.php +++ b/src/sentry/src/Tracing/Aspect/TraceAnnotationAspect.php @@ -54,7 +54,7 @@ public function process(ProceedingJoinPoint $proceedingJoinPoint) return trace( function (Scope $scope) use ($proceedingJoinPoint) { return tap($proceedingJoinPoint->process(), function ($result) use ($scope) { - if ($this->feature->isTracingExtraTagEnabled('annotation.result')) { + if ($this->feature->isTracingTagEnabled('annotation.result')) { $scope->getSpan()?->setData(['annotation.result' => $result]); } }); diff --git a/src/sentry/src/Tracing/Listener/EventHandleListener.php b/src/sentry/src/Tracing/Listener/EventHandleListener.php index 2562a7c9c..d9473baf9 100644 --- a/src/sentry/src/Tracing/Listener/EventHandleListener.php +++ b/src/sentry/src/Tracing/Listener/EventHandleListener.php @@ -195,7 +195,7 @@ protected function handleDbQueryExecuted(DbEvent\QueryExecuted $event): void 'db.pool.using' => $pool->getCurrentConnections(), ]; - if ($this->feature->isTracingExtraTagEnabled('db.sql.bindings', true)) { + if ($this->feature->isTracingTagEnabled('db.sql.bindings', true)) { $data['db.sql.bindings'] = $event->bindings; } @@ -474,7 +474,7 @@ function (Scope $scope) use ($event) { return; } - if ($this->feature->isTracingExtraTagEnabled('redis.result')) { + if ($this->feature->isTracingTagEnabled('redis.result')) { $span->setData(['db.redis.result' => $event->result]); } diff --git a/tests/Sentry/FeatureTest.php b/tests/Sentry/FeatureTest.php index 24e83b06b..b7e8d12e7 100644 --- a/tests/Sentry/FeatureTest.php +++ b/tests/Sentry/FeatureTest.php @@ -17,12 +17,10 @@ beforeEach(function () { $config = new Config([ 'sentry' => [ - 'tracing' => [ - 'extra_tags' => [ - 'foo.bar' => true, - 'foo.baz' => true, - 'foo.bar.baz' => false, - ], + 'tracing_tags' => [ + 'foo.bar' => true, + 'foo.baz' => true, + 'foo.bar.baz' => false, ], ], ]); @@ -30,7 +28,7 @@ }); test('test is tracing tag enable', function ($key, $expected) { - expect($this->feature->isTracingExtraTagEnabled($key))->toBe($expected); + expect($this->feature->isTracingTagEnabled($key))->toBe($expected); })->with([ ['foo.bar', true], ['foo.baz', true],