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

Implementation of OC-Agent Trace Service clients. #1476

Closed
20 changes: 12 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def useCheckerFramework = rootProject.hasProperty('checkerFramework')
def useErrorProne = !useCheckerFramework

subprojects {
// OC-Agent exporter depends on grpc-core which depends on errorprone annotations, and it
// doesn't wort with checker framework.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/wort/work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

def mustUseErrorprone = project.name == "opencensus-exporter-trace-ocagent"

apply plugin: "checkstyle"
apply plugin: 'maven'
apply plugin: 'idea'
Expand All @@ -41,7 +45,7 @@ subprojects {
apply plugin: "io.morethan.jmhreport"
// Plugins that require java8
if (JavaVersion.current().isJava8Compatible()) {
if (useErrorProne) {
if (useErrorProne || mustUseErrorprone) {
apply plugin: "net.ltgt.errorprone"
}
apply plugin: 'com.github.sherter.google-java-format'
Expand All @@ -58,7 +62,7 @@ subprojects {
mavenLocal()
}

if (useCheckerFramework) {
if (useCheckerFramework && !mustUseErrorprone) {
configurations {
checkerFrameworkJavac {
description = 'a customization of the Open JDK javac compiler with additional support for type annotations'
Expand All @@ -75,7 +79,7 @@ subprojects {
// We suppress the "processing" warning as suggested in
// https://groups.google.com/forum/#!topic/bazel-discuss/_R3A9TJSoPM
it.options.compilerArgs += ["-Xlint:all", "-Xlint:-try", "-Xlint:-processing"]
if (useErrorProne) {
if (useErrorProne || mustUseErrorprone) {
if (JavaVersion.current().isJava8Compatible()) {
it.options.compilerArgs += ["-XepAllDisabledChecksAsWarnings", "-XepDisableWarningsInGeneratedCode"]

Expand All @@ -90,7 +94,7 @@ subprojects {
it.options.compilerArgs += ["-Xep:Var:OFF"]
}
}
if (useCheckerFramework) {
if (useCheckerFramework && !mustUseErrorprone) {
it.options.compilerArgs += [
'-processor',
'com.google.auto.value.processor.AutoValueProcessor,org.checkerframework.checker.nullness.NullnessChecker',
Expand All @@ -101,7 +105,7 @@ subprojects {
// Protobuf-generated code produces some warnings.
// https://github.com/google/protobuf/issues/2718
it.options.compilerArgs += ["-Xlint:-cast"]
if (!JavaVersion.current().isJava9()) {
if (!JavaVersion.current().isJava9() && !mustUseErrorprone) {
// TODO(sebright): Enable -Werror for Java 9 once we upgrade AutoValue (issue #1017).
it.options.compilerArgs += ["-Werror"]
}
Expand Down Expand Up @@ -229,7 +233,7 @@ subprojects {
}

dependencies {
if (useCheckerFramework) {
if (useCheckerFramework && !mustUseErrorprone) {
ext.checkerFrameworkVersion = '2.5.5'

// 2.4.0 is the last version of the Checker Framework compiler that supports annotations
Expand All @@ -254,7 +258,7 @@ subprojects {
libraries.mockito,
libraries.truth

if (useErrorProne && JavaVersion.current().isJava8Compatible()) {
if ((useErrorProne || mustUseErrorprone) && JavaVersion.current().isJava8Compatible()) {
// The ErrorProne plugin defaults to the latest, which would break our
// build if error prone releases a new version with a new check
errorprone "com.google.errorprone:error_prone_core:${errorProneVersion}"
Expand Down Expand Up @@ -458,7 +462,7 @@ subprojects {
maxHeapSize = '1500m'
}

if (useCheckerFramework) {
if (useCheckerFramework && !mustUseErrorprone) {
allprojects {
tasks.withType(JavaCompile).all { JavaCompile compile ->
compile.doFirst {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ public static void createAndRegister(OcAgentTraceExporterConfiguration configura
new OcAgentTraceExporterHandler(
configuration.getEndPoint(),
configuration.getServiceName(),
configuration.getUseInsecure());
configuration.getUseInsecure(),
configuration.getRetryInterval());
registerInternal(newHandler);
}
}
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 com.google.auto.value.AutoValue;
import io.opencensus.common.Duration;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

Expand Down Expand Up @@ -58,6 +59,15 @@ public abstract class OcAgentTraceExporterConfiguration {
@Nullable
public abstract String getServiceName();

/**
* Returns the retry time interval when trying to connect to Agent.
*
* @return the retry time interval
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"." at the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

* @since 0.17
*/
@Nullable
public abstract Duration getRetryInterval();

/**
* Returns a new {@link Builder}.
*
Expand Down Expand Up @@ -106,6 +116,15 @@ public abstract static class Builder {
*/
public abstract Builder setServiceName(String serviceName);

/**
* Sets the retry time interval when trying to connect to Agent.
*
* @param retryInterval the retry time interval.
* @return this.
* @since 0.17
*/
public abstract Builder setRetryInterval(Duration retryInterval);

/**
* Builds a {@link OcAgentTraceExporterConfiguration}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.opencensus.exporter.trace.ocagent;

import io.opencensus.common.Duration;
import io.opencensus.trace.export.SpanData;
import io.opencensus.trace.export.SpanExporter.Handler;
import java.util.Collection;
Expand All @@ -26,29 +27,35 @@ final class OcAgentTraceExporterHandler extends Handler {

private static final String DEFAULT_END_POINT = "localhost:55678";
private static final String DEFAULT_SERVICE_NAME = "OpenCensus";

// private final String endPoint;
// private final Node node;
// private final boolean useInsecure;
private static final Duration DEFAULT_RETRY_INTERVAL = Duration.create(300, 0); // 5 minutes

OcAgentTraceExporterHandler() {
this(null, null, null);
this(null, null, null, null);
}

OcAgentTraceExporterHandler(
@Nullable String endPoint, @Nullable String serviceName, @Nullable Boolean useInsecure) {
// this.endPoint = endPoint == null ? DEFAULT_END_POINT : endPoint;
// if (serviceName == null) {
// serviceName = DEFAULT_SERVICE_NAME;
// }
// this.node = OcAgentNodeUtils.getNodeInfo(serviceName);
// this.useInsecure = useInsecure == null ? false : useInsecure;
@Nullable String endPoint,
@Nullable String serviceName,
@Nullable Boolean useInsecure,
@Nullable Duration retryInterval) {
if (endPoint == null) {
endPoint = DEFAULT_END_POINT;
}
if (serviceName == null) {
serviceName = DEFAULT_SERVICE_NAME;
}
if (useInsecure == null) {
useInsecure = false;
}
if (retryInterval == null) {
retryInterval = DEFAULT_RETRY_INTERVAL;
}
OcAgentTraceServiceClients.startAttemptsToConnectToAgent(
endPoint, useInsecure, serviceName, retryInterval.toMillis());
}

@Override
public void export(Collection<SpanData> spanDataList) {
// TODO(songya): implement this.
// for (SpanData spanData : spanDataList) {
// }
OcAgentTraceServiceClients.onExport(spanDataList);
}
}
Loading