Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 30 additions & 32 deletions src/sentry/publish/sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
2 changes: 2 additions & 0 deletions src/sentry/src/Factory/ClientBuilderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class ClientBuilderFactory
'transport_channel_size',
'transport_concurrent_limit',
'tracing',
'tracing_spans',
'tracing_tags',
];

public function __invoke(ContainerInterface $container): ClientBuilder
Expand Down
18 changes: 11 additions & 7 deletions src/sentry/src/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
35 changes: 18 additions & 17 deletions src/sentry/src/Listener/SetupSentryListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
26 changes: 2 additions & 24 deletions src/sentry/src/Switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', []);
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/src/Tracing/Aspect/DbAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/src/Tracing/Aspect/ElasticsearchAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/src/Tracing/Aspect/GuzzleHttpClientAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/src/Tracing/Aspect/RedisAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/src/Tracing/Aspect/RpcAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/src/Tracing/Aspect/TraceAnnotationAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/src/Tracing/Listener/EventHandleListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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]);
}

Expand Down
12 changes: 5 additions & 7 deletions tests/Sentry/FeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,18 @@
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,
],
],
]);
$this->feature = new Feature($config);
});

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],
Expand Down