1 /* 2 * Copyright 2018, OpenCensus Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package io.opencensus.exporter.trace.ocagent; 18 19 import com.google.auto.value.AutoValue; 20 import io.opencensus.common.Duration; 21 import javax.annotation.Nullable; 22 import javax.annotation.concurrent.Immutable; 23 24 /** 25 * Configurations for {@link OcAgentTraceExporter}. 26 * 27 * @since 0.17 28 */ 29 @AutoValue 30 @Immutable 31 public abstract class OcAgentTraceExporterConfiguration { 32 OcAgentTraceExporterConfiguration()33 OcAgentTraceExporterConfiguration() {} 34 35 /** 36 * Returns the end point of OC-Agent. The end point can be dns, ip:port, etc. 37 * 38 * @return the end point of OC-Agent. 39 * @since 0.17 40 */ 41 @Nullable getEndPoint()42 public abstract String getEndPoint(); 43 44 /** 45 * Returns whether to disable client transport security for the exporter's gRPC connection or not. 46 * 47 * @return whether to disable client transport security for the exporter's gRPC connection or not. 48 * @since 0.17 49 */ 50 @Nullable getUseInsecure()51 public abstract Boolean getUseInsecure(); 52 53 /** 54 * Returns the service name to be used for this {@link OcAgentTraceExporter}. 55 * 56 * @return the service name. 57 * @since 0.17 58 */ 59 @Nullable getServiceName()60 public abstract String getServiceName(); 61 62 /** 63 * Returns the retry time interval when trying to connect to Agent. 64 * 65 * @return the retry time interval. 66 * @since 0.17 67 */ 68 @Nullable getRetryInterval()69 public abstract Duration getRetryInterval(); 70 71 /** 72 * Returns whether the {@link OcAgentTraceExporter} should handle the config streams. 73 * 74 * @return whether the {@code OcAgentTraceExporter} should handle the config streams. 75 * @since 0.17 76 */ getEnableConfig()77 public abstract boolean getEnableConfig(); 78 79 /** 80 * Returns a new {@link Builder}. 81 * 82 * @return a {@code Builder}. 83 * @since 0.17 84 */ builder()85 public static Builder builder() { 86 return new AutoValue_OcAgentTraceExporterConfiguration.Builder().setEnableConfig(true); 87 } 88 89 /** 90 * Builder for {@link OcAgentTraceExporterConfiguration}. 91 * 92 * @since 0.17 93 */ 94 @AutoValue.Builder 95 public abstract static class Builder { 96 Builder()97 Builder() {} 98 99 /** 100 * Sets the end point of OC-Agent server. 101 * 102 * @param endPoint the end point of OC-Agent. 103 * @return this. 104 * @since 0.17 105 */ setEndPoint(String endPoint)106 public abstract Builder setEndPoint(String endPoint); 107 108 /** 109 * Sets whether to disable client transport security for the exporter's gRPC connection or not. 110 * 111 * @param useInsecure whether disable client transport security for the exporter's gRPC 112 * connection. 113 * @return this. 114 * @since 0.17 115 */ setUseInsecure(Boolean useInsecure)116 public abstract Builder setUseInsecure(Boolean useInsecure); 117 118 /** 119 * Sets the service name to be used for this {@link OcAgentTraceExporter}. 120 * 121 * @param serviceName the service name. 122 * @return this. 123 * @since 0.17 124 */ setServiceName(String serviceName)125 public abstract Builder setServiceName(String serviceName); 126 127 /** 128 * Sets the retry time interval when trying to connect to Agent. 129 * 130 * @param retryInterval the retry time interval. 131 * @return this. 132 * @since 0.17 133 */ setRetryInterval(Duration retryInterval)134 public abstract Builder setRetryInterval(Duration retryInterval); 135 136 /** 137 * Sets whether {@link OcAgentTraceExporter} should handle the config streams. 138 * 139 * @param enableConfig whether {@code OcAgentTraceExporter} should handle the config streams. 140 * @return this. 141 * @since 0.17 142 */ setEnableConfig(boolean enableConfig)143 public abstract Builder setEnableConfig(boolean enableConfig); 144 145 // TODO(songya): add an option that controls whether to always keep the RPC connection alive. 146 147 /** 148 * Builds a {@link OcAgentTraceExporterConfiguration}. 149 * 150 * @return a {@code OcAgentTraceExporterConfiguration}. 151 * @since 0.17 152 */ build()153 public abstract OcAgentTraceExporterConfiguration build(); 154 } 155 } 156