1111use Nette \Schema \Expect ;
1212use Nette \Schema \Schema ;
1313use Rootpd \NetteSentry \ApplicationMonitor ;
14+ use Rootpd \NetteSentry \DatabaseConnection ;
1415use Rootpd \NetteSentry \SentryLogger ;
1516use Sentry \Integration \EnvironmentIntegration ;
1617use Sentry \Integration \TransactionIntegration ;
@@ -55,6 +56,13 @@ public function loadConfiguration()
5556 $ logger ->addSetup ('setProfilesSampleRate ' , [$ this ->config ->profiles_sample_rate ]);
5657 }
5758
59+ if ($ this ->config ->db_tracing ) {
60+ /** @var ServiceDefinition $dbDefinition */
61+ $ dbDefinition = $ this ->getContainerBuilder ()->getDefinition ('database.default.connection ' );
62+ $ dbFactory = $ dbDefinition ->getFactory ();
63+ $ dbDefinition ->setFactory (DatabaseConnection::class, $ dbFactory ->arguments );
64+ }
65+
5866 $ integrations [] = new Statement (TransactionIntegration::class);
5967 $ integrations [] = new Statement (EnvironmentIntegration::class);
6068 }
@@ -71,13 +79,17 @@ public function loadConfiguration()
7179 public function getConfigSchema (): Schema
7280 {
7381 return Expect::structure ([
82+ // sentry configs
7483 'dsn ' => Expect::string ()->dynamic (),
7584 'environment ' => Expect::string ('local ' )->dynamic (),
7685 'user_fields ' => Expect::listOf (Expect::string ())->default ([]),
7786 'session_sections ' => Expect::listOf (Expect::string ())->default ([]),
7887 'priority_mapping ' => Expect::arrayOf (Expect::string (), Expect::string ())->default ([]),
7988 'traces_sample_rate ' => Expect::float ()->dynamic (),
8089 'profiles_sample_rate ' => Expect::float ()->dynamic (),
90+
91+ // extension configs
92+ 'db_tracing ' => Expect::bool (false )->dynamic (),
8193 ]);
8294 }
8395
0 commit comments