@@ -54,11 +54,11 @@ public static Map<String, EmittedSpans> getSpansByScopeFromFiles(
5454
5555 spansByScope .putIfAbsent (whenKey , new StringBuilder ("spans_by_scope:\n " ));
5656
57- // Skip the metric spans_by_scope ("metrics:") so we can aggregate into one list
58- int metricsIndex = content .indexOf ("spans_by_scope:\n " );
59- if (metricsIndex != -1 ) {
57+ // Skip the spans_by_scope line so we can aggregate into one list
58+ int spanIndex = content .indexOf ("spans_by_scope:\n " );
59+ if (spanIndex != -1 ) {
6060 String contentAfterMetrics =
61- content .substring (metricsIndex + "spans_by_scope:\n " .length ());
61+ content .substring (spanIndex + "spans_by_scope:\n " .length ());
6262 spansByScope .get (whenKey ).append (contentAfterMetrics );
6363 }
6464 }
@@ -79,8 +79,7 @@ public static Map<String, EmittedSpans> getSpansByScopeFromFiles(
7979 * @param input raw string representation of EmittedMetrics yaml
8080 * @return {@code Map<String, EmittedMetrics>} where the key is the `when` condition
8181 */
82- // visible for testing
83- public static Map <String , EmittedSpans > parseSpans (Map <String , StringBuilder > input )
82+ private static Map <String , EmittedSpans > parseSpans (Map <String , StringBuilder > input )
8483 throws JsonProcessingException {
8584 Map <String , EmittedSpans > result = new HashMap <>();
8685
@@ -139,24 +138,24 @@ private static EmittedSpans getEmittedSpans(
139138 for (Map .Entry <String , Map <String , Set <TelemetryAttribute >>> scopeEntry :
140139 attributesByScopeAndSpanKind .entrySet ()) {
141140 String scope = scopeEntry .getKey ();
142- EmittedSpans .SpansByScope deduplicatedScope = getSpansByScope (scopeEntry , scope );
141+ Map <String , Set <TelemetryAttribute >> spanKindMap = scopeEntry .getValue ();
142+ EmittedSpans .SpansByScope deduplicatedScope = getSpansByScope (scope , spanKindMap );
143143 deduplicatedSpansByScope .add (deduplicatedScope );
144144 }
145145
146146 return new EmittedSpans (when , deduplicatedSpansByScope );
147147 }
148148
149149 /**
150- * Converts a map entry of scope and its attributes into an {@link EmittedSpans.SpansByScope}
151- * object .
150+ * Converts a map of attributes by spanKind into an {@link EmittedSpans.SpansByScope} object.
151+ * Deduplicates spans by their kind and collects their attributes .
152152 *
153- * @param scopeEntry the map entry containing scope and its attributes
154153 * @param scope the name of the scope
154+ * @param spanKindMap a map where the key is the span kind and the value is set of attributes
155155 * @return an {@link EmittedSpans.SpansByScope} object with deduplicated spans
156156 */
157157 private static EmittedSpans .SpansByScope getSpansByScope (
158- Map .Entry <String , Map <String , Set <TelemetryAttribute >>> scopeEntry , String scope ) {
159- Map <String , Set <TelemetryAttribute >> spanKindMap = scopeEntry .getValue ();
158+ String scope , Map <String , Set <TelemetryAttribute >> spanKindMap ) {
160159
161160 List <EmittedSpans .Span > deduplicatedSpans = new ArrayList <>();
162161
0 commit comments