@@ -182,7 +182,6 @@ void testAllAttributes() {
182
182
// no network demand
183
183
Assertions .assertEquals (0.0 , metricDemandResult .get ().metricValue );
184
184
}
185
-
186
185
}
187
186
}
188
187
@@ -435,22 +434,31 @@ private static List<MetricDemand> extractMetricValuesFromLog(String logMessage)
435
434
436
435
List <MetricDemand > demands = new ArrayList <>();
437
436
String valueAttributeInLog = "value=" ;
437
+ String sampleApplicationName = "io.retit.opentelemetry.SampleApplication" ;
438
+
439
+ String emissionMetricNotTransactionRelated = "io.retit.emissions" ;
438
440
439
- String [] seperateMetrics = logMessage .split ("ImmutableLongPointData" );
440
441
for (String key : METRIC_NAMES ) {
441
- for (String metricData : seperateMetrics ) {
442
- if (metricData .contains (key ) && metricData .indexOf (valueAttributeInLog ) != -1 ) {
442
+ if (logMessage .contains (key )) {
443
+ String dataForCurrentMetric = logMessage .substring (logMessage .indexOf (key ) + 1 );
444
+
445
+ if (!key .startsWith (emissionMetricNotTransactionRelated ) && dataForCurrentMetric .contains (sampleApplicationName )) {
446
+ dataForCurrentMetric = dataForCurrentMetric .substring (dataForCurrentMetric .indexOf (sampleApplicationName ));
447
+ }
448
+
449
+ if (dataForCurrentMetric .indexOf (valueAttributeInLog ) != -1 ) {
443
450
444
451
MetricDemand metricDemand = new MetricDemand ();
445
- int valueIndex = metricData .indexOf (valueAttributeInLog );
452
+ int valueIndex = dataForCurrentMetric .indexOf (valueAttributeInLog );
446
453
447
- String valueString = metricData .substring (valueIndex + valueAttributeInLog .length (), metricData .indexOf ("," , valueIndex ));
454
+ String valueString = dataForCurrentMetric .substring (valueIndex + valueAttributeInLog .length (), dataForCurrentMetric .indexOf ("," , valueIndex ));
448
455
double value = Double .parseDouble (valueString );
449
456
450
457
metricDemand .metricName = key ;
451
458
metricDemand .metricValue = value ;
452
459
demands .add (metricDemand );
453
460
}
461
+
454
462
}
455
463
456
464
}
0 commit comments