@@ -32,6 +32,9 @@ public final class AzureMonitorExporterBuilder {
3232 private final ClientLogger logger = new ClientLogger (AzureMonitorExporterBuilder .class );
3333 private final ApplicationInsightsClientImplBuilder restServiceClientBuilder ;
3434 private String instrumentationKey ;
35+ private String endpoint ;
36+ private String connectionString ;
37+ private AzureMonitorExporterServiceVersion serviceVersion ;
3538
3639 /**
3740 * Creates an instance of {@link AzureMonitorExporterBuilder}.
@@ -52,6 +55,7 @@ AzureMonitorExporterBuilder endpoint(String endpoint) {
5255
5356 try {
5457 URL url = new URL (endpoint );
58+ this .endpoint = endpoint ;
5559 restServiceClientBuilder .host (url .getProtocol () + "://" + url .getHost ());
5660 } catch (MalformedURLException ex ) {
5761 throw logger .logExceptionAsWarning (
@@ -136,7 +140,7 @@ public AzureMonitorExporterBuilder configuration(Configuration configuration) {
136140 }
137141
138142 /**
139- * The connection string to use for exporting telemetry events to Azure Monitor.
143+ * Sets the connection string to use for exporting telemetry events to Azure Monitor.
140144 * @param connectionString The connection string for the Azure Monitor resource.
141145 * @return The updated {@link AzureMonitorExporterBuilder} object.
142146 * @throws NullPointerException If the connection string is {@code null}.
@@ -153,6 +157,18 @@ public AzureMonitorExporterBuilder connectionString(String connectionString) {
153157 if (endpoint != null ) {
154158 this .endpoint (endpoint );
155159 }
160+ this .connectionString = connectionString ;
161+ return this ;
162+ }
163+
164+ /**
165+ * Sets the Azure Monitor service version.
166+ *
167+ * @param serviceVersion The Azure Monitor service version.
168+ * @return The update {@link AzureMonitorExporterBuilder} object.
169+ */
170+ public AzureMonitorExporterBuilder serviceVersion (AzureMonitorExporterServiceVersion serviceVersion ) {
171+ this .serviceVersion = serviceVersion ;
156172 return this ;
157173 }
158174
@@ -213,12 +229,12 @@ MonitorExporterAsyncClient buildAsyncClient() {
213229 * implementation of OpenTelemetry {@link SpanExporter}.
214230 *
215231 * @return An instance of {@link AzureMonitorExporter}.
216- * @throws NullPointerException if the instrumentation key is not set.
232+ * @throws NullPointerException if the connection string is not set.
217233 */
218234 public AzureMonitorExporter buildExporter () {
219- // instrumentationKey is extracted from connectionString, so, if instrumentationKey is null
220- // then the error message should read " connectionString cannot be null".
221- Objects . requireNonNull ( instrumentationKey , "'connectionString' cannot be null" );
235+ if ( connectionString == null ) {
236+ throw logger . logExceptionAsError ( new NullPointerException ( "' connectionString' cannot be null." ));
237+ }
222238 return new AzureMonitorExporter (buildClient (), instrumentationKey );
223239 }
224240
0 commit comments