49
49
import com .solarwinds .opentelemetry .extensions .config .parser .json .TransactionNamingSchemesParser ;
50
50
import com .solarwinds .opentelemetry .extensions .config .parser .json .TransactionSettingsConfigParser ;
51
51
import com .solarwinds .opentelemetry .extensions .config .parser .json .UrlSampleRateConfigParser ;
52
+ import lombok .Getter ;
53
+
52
54
import java .io .File ;
53
55
import java .io .FileInputStream ;
54
56
import java .io .FileNotFoundException ;
70
72
import java .util .concurrent .Executors ;
71
73
import java .util .concurrent .ScheduledExecutorService ;
72
74
import java .util .stream .Collectors ;
73
- import lombok .Getter ;
74
75
75
76
public class ConfigurationLoader {
76
77
private static final Logger logger = LoggerFactory .getLogger ();
@@ -219,15 +220,23 @@ static void configureOtelLogExport(ConfigContainer container) throws InvalidConf
219
220
}
220
221
}
221
222
222
- setSystemProperty ("otel.exporter.otlp.logs.protocol" , PROTOCOL );
223
+ String protocol = setProtocol ("otel.exporter.otlp.logs.protocol" );
223
224
setSystemProperty ("otel.logs.exporter" , "otlp" );
224
225
setSystemProperty (
225
226
"otel.exporter.otlp.logs.headers" , String .format ("authorization=Bearer %s" , apiKey ));
226
227
228
+ if (protocol .equalsIgnoreCase ("grpc" )) {
229
+ setEndpoint (
230
+ "otel.exporter.otlp.logs.endpoint" ,
231
+ String .format ("https://otel.collector.%s.%s.solarwinds.com" , dataCell , env ),
232
+ "" );
233
+ return ;
234
+ }
235
+
227
236
setEndpoint (
228
- "otel.exporter.otlp.logs.endpoint" ,
229
- String .format ("https://otel.collector.%s.%s.solarwinds.com/v1/logs" , dataCell , env ),
230
- "/v1/logs" );
237
+ "otel.exporter.otlp.logs.endpoint" ,
238
+ String .format ("https://otel.collector.%s.%s.solarwinds.com/v1/logs" , dataCell , env ),
239
+ "/v1/logs" );
231
240
}
232
241
}
233
242
@@ -256,11 +265,19 @@ static void configureOtelMetricExport(ConfigContainer container) throws InvalidC
256
265
}
257
266
}
258
267
259
- setSystemProperty ("otel.exporter.otlp.metrics.protocol" , PROTOCOL );
268
+ String protocol = setProtocol ("otel.exporter.otlp.metrics.protocol" );
260
269
setSystemProperty ("otel.metrics.exporter" , "otlp" );
261
270
setSystemProperty (
262
271
"otel.exporter.otlp.metrics.headers" , String .format ("authorization=Bearer %s" , apiKey ));
263
272
273
+ if (protocol .equalsIgnoreCase ("grpc" )) {
274
+ setEndpoint (
275
+ "otel.exporter.otlp.metrics.endpoint" ,
276
+ String .format ("https://otel.collector.%s.%s.solarwinds.com" , dataCell , env ),
277
+ "" );
278
+ return ;
279
+ }
280
+
264
281
setEndpoint (
265
282
"otel.exporter.otlp.metrics.endpoint" ,
266
283
String .format ("https://otel.collector.%s.%s.solarwinds.com/v1/metrics" , dataCell , env ),
@@ -293,10 +310,18 @@ static void configureOtelTraceExport(ConfigContainer container) throws InvalidCo
293
310
}
294
311
}
295
312
296
- setSystemProperty ("otel.exporter.otlp.traces.protocol" , PROTOCOL );
313
+ String protocol = setProtocol ("otel.exporter.otlp.traces.protocol" );
297
314
setSystemProperty (
298
315
"otel.exporter.otlp.traces.headers" , String .format ("authorization=Bearer %s" , apiKey ));
299
316
317
+ if (protocol .equalsIgnoreCase ("grpc" )){
318
+ setEndpoint (
319
+ "otel.exporter.otlp.traces.endpoint" ,
320
+ String .format ("https://otel.collector.%s.%s.solarwinds.com" , dataCell , env ),
321
+ "" );
322
+ return ;
323
+ }
324
+
300
325
setEndpoint (
301
326
"otel.exporter.otlp.traces.endpoint" ,
302
327
String .format ("https://otel.collector.%s.%s.solarwinds.com/v1/traces" , dataCell , env ),
@@ -630,11 +655,14 @@ public static void processConfigs(ConfigContainer configs) throws InvalidConfigE
630
655
ConfigManager .initialize (configs );
631
656
}
632
657
633
- private static void setSystemProperty (String key , String value ) {
658
+ private static String setSystemProperty (String key , String value ) {
634
659
String propertyValue = getConfigValue (key );
635
660
if (propertyValue == null ) {
636
661
System .setProperty (key , value );
662
+ return value ;
637
663
}
664
+
665
+ return propertyValue ;
638
666
}
639
667
640
668
private static void setEndpoint (String key , String value , String path ) {
@@ -646,6 +674,14 @@ private static void setEndpoint(String key, String value, String path) {
646
674
}
647
675
}
648
676
677
+ private static String setProtocol (String key ) {
678
+ String protocol = getConfigValue ("otel.exporter.otlp.protocol" );
679
+ if (protocol == null ) {
680
+ return setSystemProperty (key , ConfigurationLoader .PROTOCOL );
681
+ }
682
+ return protocol ;
683
+ }
684
+
649
685
static String normalize (String key ) {
650
686
return key .toUpperCase ().replace ("." , "_" );
651
687
}
0 commit comments