Skip to content

Commit

Permalink
Move dependency on benchmark lib to rely on bazel git_repository vs m…
Browse files Browse the repository at this point in the history
…aven snapshot (typedb#5060)

Implement dependency on benchmark-lib (which provides Zipkin tracing functionality) via bazel and git repository rather than maven-snapshot pushed to our test repository.
  • Loading branch information
flyingsilverfin authored and Marco Scoppetta committed Mar 25, 2019
1 parent 50bc82d commit 24ff217
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 18 deletions.
11 changes: 11 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ graknlabs_graql()
load("//dependencies/graknlabs:dependencies.bzl", "graknlabs_client_java")
graknlabs_client_java()

load("//dependencies/graknlabs:dependencies.bzl", "graknlabs_benchmark")
graknlabs_benchmark()

load("//dependencies/graknlabs:dependencies.bzl", "graknlabs_build_tools")
graknlabs_build_tools()

Expand Down Expand Up @@ -92,6 +95,14 @@ graknlabs_graql_maven_dependencies = "maven_dependencies")
graknlabs_graql_maven_dependencies()


###########################
# Load Benchmark dependencies #
###########################
load("@graknlabs_benchmark//dependencies/maven:dependencies.bzl",
graknlabs_benchmark_maven_dependencies = "maven_dependencies")
graknlabs_benchmark_maven_dependencies()


#######################################
# Load compiler dependencies for GRPC #
#######################################
Expand Down
7 changes: 7 additions & 0 deletions dependencies/graknlabs/dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ def graknlabs_client_java():
commit = "d9091e05e61a592752da5bc487af5ed2ba518695",
)

def graknlabs_benchmark():
git_repository(
name = "graknlabs_benchmark",
remote = "https://github.com/graknlabs/benchmark.git",
commit = "ceb5a2ebb71ee526d788fb4b17a104a6669d4b70" # do not sync - changes much less frequently than repository
)

def graknlabs_build_tools():
git_repository(
name = "graknlabs_build_tools",
Expand Down
3 changes: 2 additions & 1 deletion server/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ java_library(

# External dependencies from @graknlabs
"@graknlabs_graql//java:graql",
"@graknlabs_benchmark//lib:server-instrumentation",

# External dependencies from Maven
"//dependencies/maven/artifacts/grakn/benchmark:lib",

"//dependencies/maven/artifacts/com/datastax/cassandra:cassandra-driver-core", # PREVIOUSLY UNDECLARED
"//dependencies/maven/artifacts/com/google/auto/value:auto-value",
"//dependencies/maven/artifacts/com/google/code/findbugs:annotations",
Expand Down
4 changes: 2 additions & 2 deletions server/src/server/ServerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package grakn.core.server;

import grakn.benchmark.lib.serverinstrumentation.ServerTracingInstrumentation;
import grakn.benchmark.lib.instrumentation.ServerTracing;
import grakn.core.common.config.Config;
import grakn.core.common.config.ConfigKey;
import grakn.core.server.deduplicator.AttributeDeduplicatorDaemon;
Expand Down Expand Up @@ -90,7 +90,7 @@ private static io.grpc.Server createServerRPC(Config config, SessionFactory sess
OpenRequest requestOpener = new ServerOpenRequest(sessionFactory);

if (benchmark) {
ServerTracingInstrumentation.initInstrumentation("server-instrumentation");
ServerTracing.initInstrumentation("server-instrumentation");
}

io.grpc.Server serverRPC = ServerBuilder.forPort(grpcPort)
Expand Down
20 changes: 10 additions & 10 deletions server/src/server/rpc/SessionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import brave.Span;
import brave.propagation.TraceContext;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import grakn.benchmark.lib.serverinstrumentation.ServerTracingInstrumentation;
import grakn.benchmark.lib.instrumentation.ServerTracing;
import grakn.core.api.Transaction.Type;
import grakn.core.concept.Concept;
import grakn.core.concept.ConceptId;
Expand Down Expand Up @@ -147,9 +147,9 @@ private static <T> T nonNull(@Nullable T item) {
public void onNext(Transaction.Req request) {
// !important: this is the gRPC thread
try {
if (ServerTracingInstrumentation.tracingEnabledFromMessage(request)) {
TraceContext receivedTraceContext = ServerTracingInstrumentation.extractTraceContext(request);
Span queueSpan = ServerTracingInstrumentation.createChildSpanWithParentContext("Server receive queue", receivedTraceContext);
if (ServerTracing.tracingEnabledFromMessage(request)) {
TraceContext receivedTraceContext = ServerTracing.extractTraceContext(request);
Span queueSpan = ServerTracing.createChildSpanWithParentContext("Server receive queue", receivedTraceContext);
queueSpan.start();
queueSpan.tag("childNumber", "0");

Expand Down Expand Up @@ -180,7 +180,7 @@ private void handleRequest(Transaction.Req request, Span queueSpan, TraceContext
queueSpan.finish(); // time spent in queue

// create a new scoped span
ScopedSpan span = ServerTracingInstrumentation.startScopedChildSpanWithParentContext("Server handle request", context);
ScopedSpan span = ServerTracing.startScopedChildSpanWithParentContext("Server handle request", context);
span.tag("childNumber", "1");
handleRequest(request);
}
Expand Down Expand Up @@ -300,14 +300,14 @@ private void query(SessionProto.Transaction.Query.Req request) {
/* permanent tracing hooks, as performance here varies depending on query and what's in the graph */

ScopedSpan span = null;
if (ServerTracingInstrumentation.tracingActive()) {
span = ServerTracingInstrumentation.createScopedChildSpan("Parsing Graql Query");
if (ServerTracing.tracingActive()) {
span = ServerTracing.startScopedChildSpan("Parsing Graql Query");
}
GraqlQuery query = Graql.parse(request.getQuery());

if (span != null) {
span.finish();
span = ServerTracingInstrumentation.createScopedChildSpan("Creating query stream");
span = ServerTracing.startScopedChildSpan("Creating query stream");
}

Stream<Transaction.Res> responseStream = tx().stream(query, request.getInfer().equals(Transaction.Query.INFER.TRUE)).map(ResponseBuilder.Transaction.Iter::query);
Expand Down Expand Up @@ -396,8 +396,8 @@ private void next(Transaction.Iter.Req iterate) {
}

private void onNextResponse(Transaction.Res response) {
if (ServerTracingInstrumentation.tracingActive()) {
ServerTracingInstrumentation.currentSpan().finish();
if (ServerTracing.tracingActive()) {
ServerTracing.currentSpan().finish();
}
responseSender.onNext(response);
}
Expand Down
10 changes: 5 additions & 5 deletions server/src/server/session/TransactionOLTP.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package grakn.core.server.session;

import brave.ScopedSpan;
import grakn.benchmark.lib.serverinstrumentation.ServerTracingInstrumentation;
import grakn.benchmark.lib.instrumentation.ServerTracing;
import grakn.core.api.Transaction;
import grakn.core.common.config.ConfigKey;
import grakn.core.common.exception.ErrorMessage;
Expand Down Expand Up @@ -874,8 +874,8 @@ private Optional<CommitLog> commitWithLogs() throws InvalidKBException {

/* This method has permanent tracing because commits can take varying lengths of time depending on operations */
ScopedSpan span = null;
if (ServerTracingInstrumentation.tracingActive()) {
span = ServerTracingInstrumentation.createScopedChildSpan("commitWithLogs validate");
if (ServerTracing.tracingActive()) {
span = ServerTracing.startScopedChildSpan("commitWithLogs validate");
}

checkMutationAllowed();
Expand All @@ -887,7 +887,7 @@ private Optional<CommitLog> commitWithLogs() throws InvalidKBException {

if (span != null) {
span.finish();
span = ServerTracingInstrumentation.createScopedChildSpan("commitWithLogs commit");
span = ServerTracing.startScopedChildSpan("commitWithLogs commit");
}

// lock on the keyspace cache shared between concurrent tx's to the same keyspace
Expand All @@ -902,7 +902,7 @@ private Optional<CommitLog> commitWithLogs() throws InvalidKBException {

if (span != null) {
span.finish();
span = ServerTracingInstrumentation.createScopedChildSpan("commitWithLogs create log");
span = ServerTracing.startScopedChildSpan("commitWithLogs create log");
}

Optional logs = Optional.of(CommitLog.create(keyspace(), newInstances, newAttributes));
Expand Down

0 comments on commit 24ff217

Please sign in to comment.