Skip to content

Commit

Permalink
add number of cache reads received in custom payload to the trace
Browse files Browse the repository at this point in the history
  • Loading branch information
Karolina committed Mar 18, 2022
1 parent 821a267 commit 73f4e47
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,7 @@ private void setFinalResult(Connection connection, Message.Response response) {
}
}
parentTracingInfo.setReplicas(replicasBuilder.toString());
parentTracingInfo.setCacheCounter(buf.getInt());
}

parentTracingInfo.tracingFinished();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public void setTable(String table) {}
@Override
public void setReplicas(String replicas) {}

@Override
public void setCacheCounter(int cacheCounter) {}

@Override
public void recordException(Exception exception) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ enum StatusCode {
*/
void setReplicas(String replicas);

/**
* Adds provided cache reads counter to the trace.
*
* @param cacheCounter the counter to be set.
*/
void setCacheCounter(int cacheCounter);

/**
* Records in the trace that the provided exception occured.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class TestTracingInfo implements TracingInfo {
private String partitionKey;
private String table;
private String replicas;
private Integer cacheCounter;

public TestTracingInfo(PrecisionLevel precision) {
this.precision = precision;
Expand Down Expand Up @@ -159,6 +160,11 @@ public void setReplicas(String replicas) {
this.replicas = replicas;
}

@Override
public void setCacheCounter(int cacheCounter) {
this.cacheCounter = cacheCounter;
}

@Override
public void recordException(Exception exception) {
if (this.exceptions == null) {
Expand Down Expand Up @@ -267,6 +273,10 @@ public String getReplicas() {
return replicas;
}

public Integer getCacheCounter() {
return cacheCounter;
}

public StatusCode getStatusCode() {
return statusCode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ public void setReplicas(String replicas) {
span.setAttribute("db.scylla.replicas", replicas);
}

@Override
public void setCacheCounter(int cacheCounter) {
assertStarted();
span.setAttribute("db.scylla.cache_counter", cacheCounter);
}

private io.opentelemetry.api.trace.StatusCode mapStatusCode(StatusCode code) {
switch (code) {
case OK:
Expand Down

0 comments on commit 73f4e47

Please sign in to comment.