@@ -219,11 +219,19 @@ static void configureOtelLogExport(ConfigContainer container) throws InvalidConf
219
219
}
220
220
}
221
221
222
- setSystemProperty ("otel.exporter.otlp.logs.protocol" , PROTOCOL );
222
+ String protocol = setProtocol ("otel.exporter.otlp.logs.protocol" );
223
223
setSystemProperty ("otel.logs.exporter" , "otlp" );
224
224
setSystemProperty (
225
225
"otel.exporter.otlp.logs.headers" , String .format ("authorization=Bearer %s" , apiKey ));
226
226
227
+ if (protocol .equalsIgnoreCase ("grpc" )) {
228
+ setEndpoint (
229
+ "otel.exporter.otlp.logs.endpoint" ,
230
+ String .format ("https://otel.collector.%s.%s.solarwinds.com" , dataCell , env ),
231
+ "" );
232
+ return ;
233
+ }
234
+
227
235
setEndpoint (
228
236
"otel.exporter.otlp.logs.endpoint" ,
229
237
String .format ("https://otel.collector.%s.%s.solarwinds.com/v1/logs" , dataCell , env ),
@@ -256,11 +264,19 @@ static void configureOtelMetricExport(ConfigContainer container) throws InvalidC
256
264
}
257
265
}
258
266
259
- setSystemProperty ("otel.exporter.otlp.metrics.protocol" , PROTOCOL );
267
+ String protocol = setProtocol ("otel.exporter.otlp.metrics.protocol" );
260
268
setSystemProperty ("otel.metrics.exporter" , "otlp" );
261
269
setSystemProperty (
262
270
"otel.exporter.otlp.metrics.headers" , String .format ("authorization=Bearer %s" , apiKey ));
263
271
272
+ if (protocol .equalsIgnoreCase ("grpc" )) {
273
+ setEndpoint (
274
+ "otel.exporter.otlp.metrics.endpoint" ,
275
+ String .format ("https://otel.collector.%s.%s.solarwinds.com" , dataCell , env ),
276
+ "" );
277
+ return ;
278
+ }
279
+
264
280
setEndpoint (
265
281
"otel.exporter.otlp.metrics.endpoint" ,
266
282
String .format ("https://otel.collector.%s.%s.solarwinds.com/v1/metrics" , dataCell , env ),
@@ -293,10 +309,18 @@ static void configureOtelTraceExport(ConfigContainer container) throws InvalidCo
293
309
}
294
310
}
295
311
296
- setSystemProperty ("otel.exporter.otlp.traces.protocol" , PROTOCOL );
312
+ String protocol = setProtocol ("otel.exporter.otlp.traces.protocol" );
297
313
setSystemProperty (
298
314
"otel.exporter.otlp.traces.headers" , String .format ("authorization=Bearer %s" , apiKey ));
299
315
316
+ if (protocol .equalsIgnoreCase ("grpc" )) {
317
+ setEndpoint (
318
+ "otel.exporter.otlp.traces.endpoint" ,
319
+ String .format ("https://otel.collector.%s.%s.solarwinds.com" , dataCell , env ),
320
+ "" );
321
+ return ;
322
+ }
323
+
300
324
setEndpoint (
301
325
"otel.exporter.otlp.traces.endpoint" ,
302
326
String .format ("https://otel.collector.%s.%s.solarwinds.com/v1/traces" , dataCell , env ),
@@ -630,11 +654,14 @@ public static void processConfigs(ConfigContainer configs) throws InvalidConfigE
630
654
ConfigManager .initialize (configs );
631
655
}
632
656
633
- private static void setSystemProperty (String key , String value ) {
657
+ private static String setSystemProperty (String key , String value ) {
634
658
String propertyValue = getConfigValue (key );
635
659
if (propertyValue == null ) {
636
660
System .setProperty (key , value );
661
+ return value ;
637
662
}
663
+
664
+ return propertyValue ;
638
665
}
639
666
640
667
private static void setEndpoint (String key , String value , String path ) {
@@ -646,6 +673,14 @@ private static void setEndpoint(String key, String value, String path) {
646
673
}
647
674
}
648
675
676
+ private static String setProtocol (String key ) {
677
+ String protocol = getConfigValue ("otel.exporter.otlp.protocol" );
678
+ if (protocol == null ) {
679
+ return setSystemProperty (key , ConfigurationLoader .PROTOCOL );
680
+ }
681
+ return protocol ;
682
+ }
683
+
649
684
static String normalize (String key ) {
650
685
return key .toUpperCase ().replace ("." , "_" );
651
686
}
0 commit comments