Skip to content

Commit 9b2e587

Browse files
committed
fix naming
1 parent d80e36a commit 9b2e587

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

instrumentation-docs/src/main/java/io/opentelemetry/instrumentation/docs/parsers/EmittedSpanParser.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ 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) {
60-
String contentAfterMetrics =
61-
content.substring(metricsIndex + "spans_by_scope:\n".length());
62-
spansByScope.get(whenKey).append(contentAfterMetrics);
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) {
60+
String contentAfter =
61+
content.substring(spanIndex + "spans_by_scope:\n".length());
62+
spansByScope.get(whenKey).append(contentAfter);
6363
}
6464
}
6565
});
@@ -76,11 +76,10 @@ public static Map<String, EmittedSpans> getSpansByScopeFromFiles(
7676
* `when`, indicating the conditions under which the telemetry is emitted. deduplicates by name
7777
* and then returns a new map.
7878
*
79-
* @param input raw string representation of EmittedMetrics yaml
80-
* @return {@code Map<String, EmittedMetrics>} where the key is the `when` condition
79+
* @param input raw string representation of EmittedSpans yaml
80+
* @return {@code Map<String, EmittedSpans>} 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

Comments
 (0)