Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Commit

Permalink
Use a local VERSION string in OC-Agent Exporter.
Browse files Browse the repository at this point in the history
  • Loading branch information
songy23 committed Sep 26, 2018
1 parent 15fa5fd commit 382c21e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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();
}

Expand All @@ -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<String, String> getAttributeMap(@Nullable MonitoredResource resource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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");
}
Expand All @@ -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
Expand Down

0 comments on commit 382c21e

Please sign in to comment.