Skip to content

Commit f25e660

Browse files
authored
fix doc Application-toolkit-tracer extract data from map (#617)
1 parent 5f61c5e commit f25e660

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

docs/en/setup/service-agent/java-agent/Application-toolkit-tracer.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,20 @@ while (next.hasNext()) {
6969
...
7070

7171
```
72+
note: Inject can be done only in Exit Span
7273

7374
```java
7475
// Receive the map representing a header/metadata and do the extract operation in another process.
7576
...
7677

7778
ContextCarrierRef contextCarrierRef = new ContextCarrierRef();
7879
CarrierItemRef next = contextCarrierRef.items();
79-
for (Map.Entry<String, String> entry : map.entrySet()) {
80-
if (next.hasNext()) {
81-
next = next.next();
82-
if (entry.getKey().equals(next.getHeadKey()))
83-
next.setHeadValue(entry.getValue());
84-
}
80+
while ((next.hasNext())) {
81+
next = next.next();
82+
String value = map.get(next.getHeadKey());
83+
if (value != null){
84+
next.setHeadValue(value);
85+
}
8586
}
8687
Tracer.extract(contextCarrierRef);
8788
```
@@ -106,12 +107,12 @@ while (next.hasNext()) {
106107

107108
ContextCarrierRef contextCarrierRef = new ContextCarrierRef();
108109
CarrierItemRef next = contextCarrierRef.items();
109-
for (Map.Entry<String, String> entry : map.entrySet()) {
110-
if (next.hasNext()) {
111-
next = next.next();
112-
if (entry.getKey().equals(next.getHeadKey()))
113-
next.setHeadValue(entry.getValue());
114-
}
110+
while ((next.hasNext())) {
111+
next = next.next();
112+
String value = map.get(next.getHeadKey());
113+
if (value != null){
114+
next.setHeadValue(value);
115+
}
115116
}
116117
SpanRef spanRef = Tracer.createEntrySpan("${operationName}", contextCarrierRef);
117118
```

0 commit comments

Comments
 (0)