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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"php": "^7.2||^8.0",
"guzzlehttp/psr7": "^2.1.1",
"jean85/pretty-package-versions": "^1.5||^2.0",
"sentry/sentry": "^4.22.0",
"sentry/sentry": "^4.23.0",
"symfony/cache-contracts": "^1.1||^2.4||^3.0",
"symfony/config": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
"symfony/console": "^4.4.20||^5.0.11||^6.0||^7.0||^8.0",
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ services:
Sentry\SentryBundle\Integration\IntegrationConfigurator:
arguments: [ [], '' ]

Sentry\Integration\OTLPIntegration: ~

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The OTLPIntegration is registered in the DI container but isn't added to the active integrations list, so it remains inactive by default.
Severity: MEDIUM

Suggested Fix

Implement a method in SentryExtension.php similar to configureRequestIntegration(). This new method should add OTLPIntegration to the list of active integrations passed to the Sentry SDK, ensuring it is enabled by default as intended.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/Resources/config/services.yaml#L119

Potential issue: Registering `Sentry\Integration\OTLPIntegration` in `services.yaml`
makes it available in the Symfony DI container, but does not automatically activate it
within the Sentry SDK. The logic in `SentryExtension.php` builds the list of active
integrations but lacks a mechanism to include `OTLPIntegration`, unlike
`RequestIntegration` which is handled by `configureRequestIntegration()`. As a result,
the OTLP integration will be inactive by default unless users manually add it to their
configuration, which contradicts the PR's goal of providing out-of-the-box support.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional so that it can be used but we don't want to add it by default


Sentry\Integration\RequestFetcherInterface:
class: Sentry\SentryBundle\Integration\RequestFetcher
arguments:
Expand Down
5 changes: 4 additions & 1 deletion tests/DependencyInjection/Fixtures/php/full.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
'dsn' => 'https://examplePublicKey@o0.ingest.sentry.io/0',
'logger' => 'app.logger',
'options' => [
'integrations' => ['App\\Sentry\\Integration\\FooIntegration'],
'integrations' => [
'App\\Sentry\\Integration\\FooIntegration',
'Sentry\\Integration\\OTLPIntegration',
],
'default_integrations' => false,
'prefixes' => ['%kernel.project_dir%'],
'sample_rate' => 1,
Expand Down
1 change: 1 addition & 0 deletions tests/DependencyInjection/Fixtures/xml/full.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
strict-trace-continuation="true"
>
<sentry:integration>App\Sentry\Integration\FooIntegration</sentry:integration>
<sentry:integration>Sentry\Integration\OTLPIntegration</sentry:integration>
<sentry:trace-propagation-target>website.invalid</sentry:trace-propagation-target>
<sentry:prefix>%kernel.project_dir%</sentry:prefix>
<sentry:tag name="context">development</sentry:tag>
Expand Down
1 change: 1 addition & 0 deletions tests/DependencyInjection/Fixtures/yml/full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sentry:
options:
integrations:
- App\Sentry\Integration\FooIntegration
- Sentry\Integration\OTLPIntegration
default_integrations: false
prefixes:
- '%kernel.project_dir%'
Expand Down
1 change: 1 addition & 0 deletions tests/DependencyInjection/SentryExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public function testClientIsCreatedFromOptions(): void
$integrationConfiguratorDefinition = $container->getDefinition(IntegrationConfigurator::class);
$expectedIntegrations = [
new Reference('App\\Sentry\\Integration\\FooIntegration'),
new Reference('Sentry\\Integration\\OTLPIntegration'),
];

$this->assertSame(IntegrationConfigurator::class, $integrationConfiguratorDefinition->getClass());
Expand Down
6 changes: 3 additions & 3 deletions tests/End2End/End2EndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public function testMessengerCaptureHardFailure(): void
{
$this->skipIfMessengerIsMissing();

$client = static::createClient();
$client = static::createClient(['debug' => false]);

$client->request('GET', '/dispatch-unrecoverable-message');

Expand All @@ -238,7 +238,7 @@ public function testMessengerCaptureSoftFailCanBeDisabled(): void
{
$this->skipIfMessengerIsMissing();

$client = static::createClient();
$client = static::createClient(['debug' => false]);

$client->request('GET', '/dispatch-message');

Expand All @@ -256,7 +256,7 @@ public function testIsolateBreadcrumbsByMessage(): void
{
$this->skipIfMessengerIsMissing();

$client = static::createClient();
$client = static::createClient(['debug' => false]);

// Create two messages
$client->request('GET', '/dispatch-unrecoverable-message');
Expand Down
4 changes: 4 additions & 0 deletions tests/End2End/Fixtures/config_otlp_default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sentry:
options:
integrations:
- Sentry\Integration\OTLPIntegration
37 changes: 37 additions & 0 deletions tests/End2End/OtlpTracesEndpointEnd2EndTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace Sentry\SentryBundle\Tests\End2End;

use PHPUnit\Framework\TestCase;
use Sentry\SentryBundle\Tests\End2End\App\KernelWithExtraConfig;
use Sentry\State\HubInterface;

use function Sentry\getOtlpTracesEndpointUrl;

/**
* @runTestsInSeparateProcesses
*/
final class OtlpTracesEndpointEnd2EndTest extends TestCase
{
public function testOTLPIntegration(): void
{
$kernel = new KernelWithExtraConfig([
__DIR__ . '/Fixtures/config_otlp_default.yaml',
]);
$kernel->boot();

/** @var HubInterface $hub */
$hub = $kernel->getContainer()->get('test.hub');
$this->assertNotNull($hub->getClient());
$this->assertNotNull($hub->getIntegration(\Sentry\Integration\OTLPIntegration::class));

$this->assertSame(
'http://example.com/sentry/api/1/integration/otlp/v1/traces/',
getOtlpTracesEndpointUrl()
);

$kernel->shutdown();
}
}
Loading