Uploaded image for project: 'Couchbase Documentation'
  1. Couchbase Documentation
  2. DOC-4426

Add how to specify a scope from the application

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • None
    • None

    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

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          Note, now fixed in .NET -
          https://docs.couchbase.com/dotnet-sdk/2.7/tracing-from-the-sdk.html#specifying-a-scope
          Will now port fixes to Java and the others as chance arises.

          richard.smedley Richard Smedley added a comment - Note, now fixed in .NET - https://docs.couchbase.com/dotnet-sdk/2.7/tracing-from-the-sdk.html#specifying-a-scope Will now port fixes to Java and the others as chance arises.

          People

            hakim.cassimally Hakim Cassimally
            ingenthr Matt Ingenthron
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty