6
6
7
7
use Sentry \State \HubInterface ;
8
8
use Symfony \Component \Config \Definition \Builder \ArrayNodeDefinition ;
9
+ use Symfony \Component \Config \Definition \Builder \NodeDefinition ;
9
10
use Symfony \Component \Config \Definition \Builder \TreeBuilder ;
10
11
use Symfony \Component \Config \Definition \ConfigurationInterface ;
11
12
16
17
class Configuration implements ConfigurationInterface
17
18
{
18
19
public const TRACEMODE_TRACECONTEXT = 'tracecontext ' ;
19
- public const TRACEMODE_TRACEID = 'traceid ' ;
20
+ public const TRACEMODE_TRACEID = 'traceid ' ;
20
21
21
22
public function getConfigTreeBuilder (): TreeBuilder
22
23
{
@@ -69,7 +70,21 @@ public function getConfigTreeBuilder(): TreeBuilder
69
70
->end ()
70
71
->booleanNode ('enable_console ' )
71
72
->info ('Whether to add the trace id to console commands, defaults to true ' )
72
- ->defaultTrue ()
73
+ ->defaultNull ()
74
+ ->setDeprecated ('digitalrevolution/symfony-trace-bundle ' , '0.6.0 ' )
75
+ ->end ()
76
+ ->arrayNode ('console ' )
77
+ ->addDefaultsIfNotSet ()
78
+ ->children ()
79
+ ->booleanNode ('enabled ' )
80
+ ->info ('Whether to add the trace id to console commands, defaults to true ' )
81
+ ->defaultTrue ()
82
+ ->end ()
83
+ ->scalarNode ('trace_id ' )
84
+ ->info ('Option to set the `Trace-Id` to use for console commands from env var. Defaults to null. ' )
85
+ ->defaultNull ()
86
+ ->end ()
87
+ ->end ()
73
88
->end ()
74
89
->booleanNode ('enable_messenger ' )
75
90
->info ('Whether to add the trace id to message bus events, defaults to false ' )
@@ -79,37 +94,53 @@ public function getConfigTreeBuilder(): TreeBuilder
79
94
->info ('Whether or not to enable the twig `trace_id()` and `transaction_id()` functions. Only works if TwigBundle is present. ' )
80
95
->defaultTrue ()
81
96
->end ()
82
- ->arrayNode ('http_client ' )
83
- ->addDefaultsIfNotSet ()
84
- ->children ()
85
- ->booleanNode ('enabled ' )
86
- ->info ('Whether or not to enable the trace id aware http client ' )
87
- ->defaultTrue ()
88
- ->end ()
89
- ->booleanNode ('tag_default_client ' )
90
- ->info ('Whether or not to tag the default http client ' )
91
- ->defaultFalse ()
92
- ->end ()
93
- ->scalarNode ('header ' )
94
- ->info ('The header the bundle set in the request in the http client ' )
95
- ->defaultValue ('X-Trace-Id ' )
96
- ->end ()
97
+ ->append ($ this ->createHttpClientConfiguration ())
98
+ ->append ($ this ->createSentryConfiguration ())
99
+ ;
100
+
101
+ return $ tree ;
102
+ }
103
+
104
+ private function createHttpClientConfiguration (): NodeDefinition
105
+ {
106
+ $ node = (new TreeBuilder ('http_client ' ))->getRootNode ();
107
+ $ node
108
+ ->addDefaultsIfNotSet ()
109
+ ->children ()
110
+ ->booleanNode ('enabled ' )
111
+ ->info ('Whether or not to enable the trace id aware http client ' )
112
+ ->defaultTrue ()
113
+ ->end ()
114
+ ->booleanNode ('tag_default_client ' )
115
+ ->info ('Whether or not to tag the default http client ' )
116
+ ->defaultFalse ()
117
+ ->end ()
118
+ ->scalarNode ('header ' )
119
+ ->info ('The header the bundle set in the request in the http client ' )
120
+ ->defaultValue ('X-Trace-Id ' )
97
121
->end ()
98
122
->end ()
99
- ->arrayNode ('sentry ' )
100
- ->addDefaultsIfNotSet ()
101
- ->children ()
102
- ->booleanNode ('enabled ' )
123
+ ->end ();
124
+
125
+ return $ node ;
126
+ }
127
+
128
+ private function createSentryConfiguration (): NodeDefinition
129
+ {
130
+ $ node = (new TreeBuilder ('sentry ' ))->getRootNode ();
131
+ $ node
132
+ ->addDefaultsIfNotSet ()
133
+ ->children ()
134
+ ->booleanNode ('enabled ' )
103
135
->info ('Whether or not to enable passing trace and transaction id to Sentry ' )
104
136
->defaultFalse ()
105
137
->end ()
106
138
->scalarNode ('hub_service ' )
107
139
->info ('The service id of the Sentry Hub. Defaults to Sentry\State\HubInterface ' )
108
140
->defaultValue (HubInterface::class)
109
141
->end ()
110
- ->end ()
111
- ;
142
+ ->end ();
112
143
113
- return $ tree ;
144
+ return $ node ;
114
145
}
115
146
}
0 commit comments