Guest User

Untitled

a guest
Jan 19th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import com.couchbase.client.java.Bucket;
  2. import com.couchbase.client.java.Cluster;
  3. import com.couchbase.client.java.CouchbaseCluster;
  4. import com.couchbase.client.java.document.JsonDocument;
  5. import com.couchbase.client.java.document.json.JsonObject;
  6. import com.couchbase.client.java.env.CouchbaseEnvironment;
  7. import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
  8. import com.uber.jaeger.Configuration;
  9. import io.opentracing.Tracer;
  10.  
  11. public class SimpleReadWrite {
  12.  
  13. public static void main(String... args) throws Exception {
  14.  
  15. // init the jaeger tracer
  16.  
  17. Tracer tracer = new Configuration(
  18. "simple_read_write",
  19. new Configuration.SamplerConfiguration("const", 1),
  20. new Configuration.ReporterConfiguration(
  21. true, "localhost", 5775, 1000, 10000)
  22. ).getTracer();
  23.  
  24.  
  25. // normal couchbase setup, passing in the jaeger tracer env
  26.  
  27. CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder().tracer(tracer).build();
  28. Cluster cluster = CouchbaseCluster.create(env);
  29. cluster.authenticate("Administrator", "password");
  30. Bucket bucket = cluster.openBucket("default");
  31.  
  32. // do a upsert and get
  33.  
  34. bucket.upsert(JsonDocument.create("mydoc_id", JsonObject.empty()));
  35. bucket.get("mydoc_id");
  36.  
  37. // dont die immediately so jaeger gets a chance to send the spans to the server
  38.  
  39. Thread.sleep(10000);
  40. }
  41. }
Add Comment
Please, Sign In to add comment