-
-
Notifications
You must be signed in to change notification settings - Fork 202
Add starfish v1 attributes to span data/breadcrumbs #764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ec39d09
Add starfish v1 attributes to span data/breadcrumbs
cleptric 26a544f
Update tests
cleptric 4bd7362
Remove duplicate request_body_size
cleptric b619b8c
Update txn data
cleptric 8462edf
Add db connection address and port to span data
stayallive File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| <?php | ||
|
|
||
| namespace Sentry\Features; | ||
|
|
||
| use Illuminate\Database\Events\QueryExecuted; | ||
| use Illuminate\Support\Facades\DB; | ||
| use Sentry\Laravel\Tests\TestCase; | ||
| use Sentry\Tracing\Span; | ||
| use Sentry\Tracing\TransactionContext; | ||
|
|
||
| class DatabaseIntegrationTest extends TestCase | ||
| { | ||
| protected function usesMySQL($app): void | ||
| { | ||
| $app['config']->set('database.default', 'mysql'); | ||
| $app['config']->set('database.connections.mysql', [ | ||
| 'driver' => 'mysql', | ||
| 'host' => 'host-mysql', | ||
| 'port' => 3306, | ||
| 'username' => 'user-mysql', | ||
| 'password' => 'password', | ||
| 'database' => 'db-mysql', | ||
| ]); | ||
| } | ||
|
|
||
| protected function usesMySQLFromUrl($app): void | ||
| { | ||
| $app['config']->set('database.default', 'mysqlurl'); | ||
| $app['config']->set('database.connections.mysqlurl', [ | ||
| 'driver' => 'mysql', | ||
| 'url' => 'mysql://user-mysqlurl:password@host-mysqlurl:3307/db-mysqlurl', | ||
| ]); | ||
| } | ||
|
|
||
| protected function usesInMemorySqlite($app): void | ||
| { | ||
| $app['config']->set('database.default', 'inmemory'); | ||
| $app['config']->set('database.connections.inmemory', [ | ||
| 'driver' => 'sqlite', | ||
| 'database' => ':memory:', | ||
| ]); | ||
| } | ||
|
|
||
| /** | ||
| * @define-env usesMySQL | ||
| */ | ||
| public function testSpanIsCreatedForMySQLConnectionQuery(): void | ||
| { | ||
| $span = $this->executeQueryAndRetrieveSpan( | ||
| $query = 'SELECT "mysql"' | ||
| ); | ||
|
|
||
| $this->assertEquals($query, $span->getDescription()); | ||
| $this->assertEquals('db.sql.query', $span->getOp()); | ||
| $this->assertEquals('host-mysql', $span->getData()['server.address']); | ||
| $this->assertEquals(3306, $span->getData()['server.port']); | ||
| } | ||
|
|
||
| /** | ||
| * @define-env usesMySQLFromUrl | ||
| */ | ||
| public function testSpanIsCreatedForMySQLUrlConnectionQuery(): void | ||
| { | ||
| $span = $this->executeQueryAndRetrieveSpan( | ||
| $query = 'SELECT "mysqlurl"' | ||
| ); | ||
|
|
||
| $this->assertEquals($query, $span->getDescription()); | ||
| $this->assertEquals('db.sql.query', $span->getOp()); | ||
| $this->assertEquals('host-mysqlurl', $span->getData()['server.address']); | ||
| $this->assertEquals(3307, $span->getData()['server.port']); | ||
| } | ||
|
|
||
| /** | ||
| * @define-env usesInMemorySqlite | ||
| */ | ||
| public function testSpanIsCreatedForSqliteConnectionQuery(): void | ||
| { | ||
| $span = $this->executeQueryAndRetrieveSpan( | ||
| $query = 'SELECT "inmemory"' | ||
| ); | ||
|
|
||
| $this->assertEquals($query, $span->getDescription()); | ||
| $this->assertEquals('db.sql.query', $span->getOp()); | ||
| $this->assertNull($span->getData()['server.address']); | ||
| $this->assertNull($span->getData()['server.port']); | ||
| } | ||
|
|
||
| private function executeQueryAndRetrieveSpan(string $query): Span | ||
| { | ||
| $hub = $this->getHubFromContainer(); | ||
|
|
||
| $transaction = $hub->startTransaction(new TransactionContext); | ||
| $transaction->initSpanRecorder(); | ||
|
|
||
| $this->getCurrentScope()->setSpan($transaction); | ||
|
|
||
| $this->dispatchLaravelEvent(new QueryExecuted($query, [], 123, DB::connection())); | ||
|
|
||
| $spans = $transaction->getSpanRecorder()->getSpans(); | ||
|
|
||
| $this->assertCount(2, $spans); | ||
|
|
||
| return $spans[1]; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.