Skip to content

Commit

Permalink
all: upgrade to OpenCensus v0.21.0
Browse files Browse the repository at this point in the history
Adaptation of @dmichel1's PR
census-ecosystem#59

which upgraded to OpenCensus v0.21.0 so as to use a bug fix from v0.18.0
for high CPU usage for low QPS services.

This commit also takes into consideration new updates to v0.21.0
that require a TagMap TTL.
  • Loading branch information
odeke-em committed May 14, 2019
1 parent e1860dd commit a1258f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ apply plugin: "net.ltgt.errorprone"
apply plugin: "signing"

group = "io.orijtech.integrations"
version = "0.0.2" // CURRENT_OCJDBC_VERSION
version = "0.0.4" // CURRENT_OCJDBC_VERSION

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand Down Expand Up @@ -38,7 +38,7 @@ buildscript {
}
}

def opencensusVersion = '0.16.1'
def opencensusVersion = '0.21.0'
def errorProneVersion = '2.3.1'
def findBugsJsr305Version = '3.0.2'

Expand Down
14 changes: 10 additions & 4 deletions src/main/java/io/opencensus/integration/jdbc/Observability.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import io.opencensus.tags.TagContext;
import io.opencensus.tags.TagContextBuilder;
import io.opencensus.tags.TagKey;
import io.opencensus.tags.TagMetadata;
import io.opencensus.tags.TagMetadata.TagTtl;
import io.opencensus.tags.TagValue;
import io.opencensus.tags.Tagger;
import io.opencensus.tags.Tags;
Expand Down Expand Up @@ -107,6 +109,8 @@ private Observability() {}
500000.0)));

static final Aggregation COUNT = Aggregation.Count.create();
static final TagMetadata TAG_METADATA_TTL_UNLIMITED =
TagMetadata.create(TagTtl.UNLIMITED_PROPAGATION);

static final View SQL_CLIENT_LATENCY_VIEW =
View.create(
Expand Down Expand Up @@ -190,13 +194,15 @@ void end() {
// Finally record the latency of the entire call,
// as well as "status": "OK" for non-error calls.
TagContextBuilder tagContextBuilder = tagger.currentBuilder();
tagContextBuilder.put(JAVA_SQL_METHOD, TagValue.create(this.method));
tagContextBuilder.put(
JAVA_SQL_METHOD, TagValue.create(this.method), TAG_METADATA_TTL_UNLIMITED);

if (recordedError == null) {
tagContextBuilder.put(JAVA_SQL_STATUS, VALUE_OK);
tagContextBuilder.put(JAVA_SQL_STATUS, VALUE_OK, TAG_METADATA_TTL_UNLIMITED);
} else {
tagContextBuilder.put(JAVA_SQL_ERROR, TagValue.create(recordedError));
tagContextBuilder.put(JAVA_SQL_STATUS, VALUE_ERROR);
tagContextBuilder.put(
JAVA_SQL_ERROR, TagValue.create(recordedError), TAG_METADATA_TTL_UNLIMITED);
tagContextBuilder.put(JAVA_SQL_STATUS, VALUE_ERROR, TAG_METADATA_TTL_UNLIMITED);
}

long totalTimeNs = System.nanoTime() - this.startTimeNs;
Expand Down

0 comments on commit a1258f4

Please sign in to comment.