Skip to content

Commit 2a5a9c7

Browse files
brunnertbrunnert
and
brunnert
authored
Cleanup Metric Attributes (#78)
* Cleanup Metric Attributes * Cleanup Metric Attributes * Cleanup Metric Attributes --------- Co-authored-by: brunnert <brunnert@hm.edu>
1 parent 01bad07 commit 2a5a9c7

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

extension/src/main/java/io/retit/opentelemetry/javaagent/extension/commons/Constants.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
*/
2222
@SuppressWarnings("checkstyle:javadocVariable")
2323
public class Constants {
24+
public static final String NETWORK_NAMESPACE = "network";
25+
public static final String THREAD_NAMESPACE = "thread";
26+
public static final String USER_NAMESPACE = "user";
27+
public static final String CLIENT_NAMESPACE = "client";
28+
public static final String INSTANCE_NAMESPACE = "instance";
29+
2430
public static final String RETIT_NAMESPACE = "io.retit";
2531
public static final String RETIT_RESPONSE_TIME_LOGGING_CONFIGURATION_PROPERTY = RETIT_NAMESPACE + ".log.response.time";
2632
public static final String RETIT_CPU_DEMAND_LOGGING_CONFIGURATION_PROPERTY = RETIT_NAMESPACE + ".log.cpu.demand";

extension/src/main/java/io/retit/opentelemetry/javaagent/extension/metrics/MetricPublishingService.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public void publishResourceDemandVectorOfTransaction(final ReadWriteSpan readWri
157157
Long endThread = readWriteSpan.getAttributes().get(AttributeKey.longKey(Constants.SPAN_ATTRIBUTE_SPAN_END_THREAD));
158158

159159
if (startThread != null && startThread.equals(endThread)) {
160-
Attributes filteredAttributes = getAttributesWithoutRETITSpanAttributes(readWriteSpan.getAttributes());
160+
Attributes filteredAttributes = getAttributesWithoutRETITThreadUserAndNetworkClientAttributes(readWriteSpan.getAttributes());
161161
// add resource demands to resource demand vector
162162
publishCpuDemandMetricForTransaction(logCPUTime, readWriteSpan.getAttributes(), filteredAttributes);
163163
publishMemoryDemandMetricForTransaction(logHeapConsumption, readWriteSpan.getAttributes(), filteredAttributes);
@@ -229,12 +229,17 @@ private void publishNetworkDemandMetricForTransaction(final boolean logNetworkDe
229229
}
230230
}
231231

232-
private Attributes getAttributesWithoutRETITSpanAttributes(final Attributes spanAttributes) {
232+
private Attributes getAttributesWithoutRETITThreadUserAndNetworkClientAttributes(final Attributes spanAttributes) {
233233
AttributesBuilder attributesBuilder = Attributes.builder();
234234

235235
attributesBuilder.putAll(spanAttributes);
236236

237-
attributesBuilder.removeIf(key -> key.getKey().startsWith(Constants.RETIT_NAMESPACE));
237+
attributesBuilder.removeIf(key -> key.getKey().startsWith(Constants.RETIT_NAMESPACE)
238+
|| key.getKey().startsWith(Constants.NETWORK_NAMESPACE)
239+
|| key.getKey().startsWith(Constants.THREAD_NAMESPACE)
240+
|| key.getKey().startsWith(Constants.USER_NAMESPACE)
241+
|| key.getKey().startsWith(Constants.CLIENT_NAMESPACE)
242+
|| key.getKey().startsWith(Constants.INSTANCE_NAMESPACE));
238243

239244
return attributesBuilder.build();
240245
}

0 commit comments

Comments
 (0)