Details
-
Bug
-
Resolution: Unresolved
-
Critical
-
None
-
None
-
*Location*: https://docs.couchbase.com/java-sdk/2.7/tracing-from-the-sdk.html
*User-Agent*: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
*Screen Resolution*: 1440 x 900
Description
As of 2.7.0, the application can specify a scope as an outer trace. This isn't covered in the docs but should be. This is only useful when using a separate tracer, such as Jaeger. The built in Tracer won't do anything with it.
While filed against Java, additional tickets need to be done for the other platforms as discussed with Michael Goldsmith.
As an example from my spring demo app note the scope and scope close:
@RequestMapping("/itineraries") |
public ResponseEntity itineraries() { |
final Scope scope = env.tracer() |
.buildSpan("query-and-fetch") |
.startActive(true); |
List<String> res = bucket.async().query(N1qlQuery.simple("select meta().id as id from `travel-sample` where type = \"route\" limit 1000")) |
.flatMap(new Func1<AsyncN1qlQueryResult, Observable<AsyncN1qlQueryRow>>() { |
public Observable<AsyncN1qlQueryRow> call(AsyncN1qlQueryResult result) { |
return result.rows(); |
}
|
}).flatMap(new Func1<AsyncN1qlQueryRow, Observable<JsonDocument>>() { |
public Observable<JsonDocument> call(AsyncN1qlQueryRow row) { |
env.tracer().scopeManager().activate(scope.span(), false); |
return bucket.async().get(row.value().getString("id"), JsonDocument.class); |
}
|
}).map(new Func1<JsonDocument, String>() { |
public String call(JsonDocument doc) { |
return doc.content().toString(); |
}
|
})
|
.toList().toBlocking().single();
|
scope.close();
|
return new ResponseEntity<Object>(res, HttpStatus.OK); |
}
|
Full context at https://github.com/ingenthr/CouchbaseSpringTracingDemo