From 382c21e264f9d6d744dda4f80c2f4d156162736f Mon Sep 17 00:00:00 2001 From: songy23 Date: Wed, 26 Sep 2018 09:50:31 -0700 Subject: [PATCH] Use a local VERSION string in OC-Agent Exporter. --- RELEASING.md | 1 + .../exporter/trace/ocagent/OcAgentNodeUtils.java | 9 ++++++--- .../exporter/trace/ocagent/OcAgentNodeUtilsTest.java | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index 6d896d4423..d60113b11f 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -67,6 +67,7 @@ token](https://help.github.com/articles/creating-a-personal-access-token-for-the examples/build.gradle examples/pom.xml api/src/main/java/io/opencensus/common/OpenCensusLibraryInformation.java + exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java ) $ git checkout -b v$MAJOR.$MINOR.x master $ git push upstream v$MAJOR.$MINOR.x diff --git a/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java b/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java index 4c02e65b14..657298033a 100644 --- a/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java +++ b/exporters/trace/ocagent/src/main/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtils.java @@ -41,6 +41,10 @@ /** Utilities for detecting and creating {@link Node}. */ final class OcAgentNodeUtils { + // The current version of the OpenCensus OC-Agent Exporter. + @VisibleForTesting + static final String OC_AGENT_EXPORTER_VERSION = "0.17.0-SNAPSHOT"; // CURRENT_OPENCENSUS_VERSION + @VisibleForTesting static final String RESOURCE_TYPE_ATTRIBUTE_KEY = "OPENCENSUS_SOURCE_TYPE"; @VisibleForTesting static final String RESOURCE_LABEL_ATTRIBUTE_KEY = "OPENCENSUS_SOURCE_LABELS"; @@ -93,13 +97,12 @@ static ProcessIdentifier getProcessIdentifier(String jvmName, Timestamp censusTi } // Creates library info with the given OpenCensus Java version. - // Note that in Java, the versions between exporters and core library are the same. @VisibleForTesting static LibraryInfo getLibraryInfo(String currentOcJavaVersion) { return LibraryInfo.newBuilder() .setLanguage(Language.JAVA) .setCoreLibraryVersion(currentOcJavaVersion) - .setExporterVersion(currentOcJavaVersion) + .setExporterVersion(OC_AGENT_EXPORTER_VERSION) .build(); } @@ -120,7 +123,7 @@ static ServiceInfo getServiceInfo(String serviceName) { * A comma-separated list of labels describing the source in more detail, * e.g. “key1=val1,key2=val2”. The allowed character set is appropriately constrained. */ - // TODO: update this once we have an agreement on + // TODO: update the resource attributes once we have an agreement on the resource specs: // https://github.com/census-instrumentation/opencensus-specs/pull/162. @VisibleForTesting static Map getAttributeMap(@Nullable MonitoredResource resource) { diff --git a/exporters/trace/ocagent/src/test/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtilsTest.java b/exporters/trace/ocagent/src/test/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtilsTest.java index 29822488d7..813066bcb7 100644 --- a/exporters/trace/ocagent/src/test/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtilsTest.java +++ b/exporters/trace/ocagent/src/test/java/io/opencensus/exporter/trace/ocagent/OcAgentNodeUtilsTest.java @@ -17,6 +17,7 @@ package io.opencensus.exporter.trace.ocagent; import static com.google.common.truth.Truth.assertThat; +import static io.opencensus.exporter.trace.ocagent.OcAgentNodeUtils.OC_AGENT_EXPORTER_VERSION; import static io.opencensus.exporter.trace.ocagent.OcAgentNodeUtils.RESOURCE_LABEL_ATTRIBUTE_KEY; import static io.opencensus.exporter.trace.ocagent.OcAgentNodeUtils.RESOURCE_TYPE_ATTRIBUTE_KEY; @@ -47,6 +48,7 @@ public class OcAgentNodeUtilsTest { @Test public void testConstants() { + assertThat(OC_AGENT_EXPORTER_VERSION).isEqualTo("0.17.0-SNAPSHOT"); assertThat(RESOURCE_TYPE_ATTRIBUTE_KEY).isEqualTo("OPENCENSUS_SOURCE_TYPE"); assertThat(RESOURCE_LABEL_ATTRIBUTE_KEY).isEqualTo("OPENCENSUS_SOURCE_LABELS"); } @@ -64,11 +66,11 @@ public void getProcessIdentifier() { @Test public void getLibraryInfo() { - String currentOcJavaVersion = "0.17.0"; + String currentOcJavaVersion = "0.16.0"; LibraryInfo libraryInfo = OcAgentNodeUtils.getLibraryInfo(currentOcJavaVersion); assertThat(libraryInfo.getLanguage()).isEqualTo(Language.JAVA); assertThat(libraryInfo.getCoreLibraryVersion()).isEqualTo(currentOcJavaVersion); - assertThat(libraryInfo.getExporterVersion()).isEqualTo(currentOcJavaVersion); + assertThat(libraryInfo.getExporterVersion()).isEqualTo(OC_AGENT_EXPORTER_VERSION); } @Test