fix doc Application-toolkit-tracer extract data from map (#617)

This commit is contained in:
qiaoxingxing 2023-09-28 17:14:12 +08:00 committed by GitHub
parent 5f61c5e31d
commit f25e6600b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 12 deletions

View File

@ -69,6 +69,7 @@ while (next.hasNext()) {
...
```
note: Inject can be done only in Exit Span
```java
// Receive the map representing a header/metadata and do the extract operation in another process.
@ -76,12 +77,12 @@ while (next.hasNext()) {
ContextCarrierRef contextCarrierRef = new ContextCarrierRef();
CarrierItemRef next = contextCarrierRef.items();
for (Map.Entry<String, String> entry : map.entrySet()) {
if (next.hasNext()) {
next = next.next();
if (entry.getKey().equals(next.getHeadKey()))
next.setHeadValue(entry.getValue());
}
while ((next.hasNext())) {
next = next.next();
String value = map.get(next.getHeadKey());
if (value != null){
next.setHeadValue(value);
}
}
Tracer.extract(contextCarrierRef);
```
@ -106,12 +107,12 @@ while (next.hasNext()) {
ContextCarrierRef contextCarrierRef = new ContextCarrierRef();
CarrierItemRef next = contextCarrierRef.items();
for (Map.Entry<String, String> entry : map.entrySet()) {
if (next.hasNext()) {
next = next.next();
if (entry.getKey().equals(next.getHeadKey()))
next.setHeadValue(entry.getValue());
}
while ((next.hasNext())) {
next = next.next();
String value = map.get(next.getHeadKey());
if (value != null){
next.setHeadValue(value);
}
}
SpanRef spanRef = Tracer.createEntrySpan("${operationName}", contextCarrierRef);
```