Skip to content

Instantly share code, notes, and snippets.

@daschl
Created January 10, 2018 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daschl/97686176e9e4cf514d17e9868cc20123 to your computer and use it in GitHub Desktop.
Save daschl/97686176e9e4cf514d17e9868cc20123 to your computer and use it in GitHub Desktop.
import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.CouchbaseCluster;
import com.couchbase.client.java.document.JsonDocument;
import com.couchbase.client.java.document.json.JsonObject;
import com.couchbase.client.java.env.CouchbaseEnvironment;
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
import com.uber.jaeger.Configuration;
import io.opentracing.Tracer;
public class SimpleReadWrite {
public static void main(String... args) throws Exception {
// init the jaeger tracer
Tracer tracer = new Configuration(
"simple_read_write",
new Configuration.SamplerConfiguration("const", 1),
new Configuration.ReporterConfiguration(
true, "localhost", 5775, 1000, 10000)
).getTracer();
// normal couchbase setup, passing in the jaeger tracer env
CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder().tracer(tracer).build();
Cluster cluster = CouchbaseCluster.create(env);
cluster.authenticate("Administrator", "password");
Bucket bucket = cluster.openBucket("default");
// do a upsert and get
bucket.upsert(JsonDocument.create("mydoc_id", JsonObject.empty()));
bucket.get("mydoc_id");
// dont die immediately so jaeger gets a chance to send the spans to the server
Thread.sleep(10000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment