@@ -131,11 +131,21 @@ protected RemoteWebDriver() {
131131
132132 public RemoteWebDriver (Capabilities capabilities ) {
133133 this (getDefaultServerURL (),
134- Require .nonNull ("Capabilities" , capabilities ));
134+ Require .nonNull ("Capabilities" , capabilities ), true );
135+ }
136+
137+ public RemoteWebDriver (Capabilities capabilities , boolean enableTracing ) {
138+ this (getDefaultServerURL (),
139+ Require .nonNull ("Capabilities" , capabilities ), enableTracing );
135140 }
136141
137142 public RemoteWebDriver (URL remoteAddress , Capabilities capabilities ) {
138- this (createTracedExecutorWithTracedHttpClient (Require .nonNull ("Server URL" , remoteAddress )),
143+ this (createExecutor (Require .nonNull ("Server URL" , remoteAddress ), true ),
144+ Require .nonNull ("Capabilities" , capabilities ));
145+ }
146+
147+ public RemoteWebDriver (URL remoteAddress , Capabilities capabilities , boolean enableTracing ) {
148+ this (createExecutor (Require .nonNull ("Server URL" , remoteAddress ), enableTracing ),
139149 Require .nonNull ("Capabilities" , capabilities ));
140150 }
141151
@@ -168,13 +178,18 @@ private static URL getDefaultServerURL() {
168178 }
169179 }
170180
171- private static CommandExecutor createTracedExecutorWithTracedHttpClient (URL remoteAddress ) {
172- Tracer tracer = OpenTelemetryTracer .getInstance ();
173- CommandExecutor executor = new HttpCommandExecutor (
174- Collections .emptyMap (),
175- ClientConfig .defaultConfig ().baseUrl (remoteAddress ),
176- new TracedHttpClient .Factory (tracer , HttpClient .Factory .createDefault ()));
177- return new TracedCommandExecutor (executor , tracer );
181+ private static CommandExecutor createExecutor (URL remoteAddress , boolean enableTracing ) {
182+ ClientConfig config = ClientConfig .defaultConfig ().baseUrl (remoteAddress );
183+ if (enableTracing ) {
184+ Tracer tracer = OpenTelemetryTracer .getInstance ();
185+ CommandExecutor executor = new HttpCommandExecutor (
186+ Collections .emptyMap (),
187+ config ,
188+ new TracedHttpClient .Factory (tracer , HttpClient .Factory .createDefault ()));
189+ return new TracedCommandExecutor (executor , tracer );
190+ } else {
191+ return new HttpCommandExecutor (config );
192+ }
178193 }
179194
180195 @ Beta
0 commit comments