44import java .util .Map ;
55import javax .annotation .Nullable ;
66
7- // TODO: JavaDoc is currently only in OpenTelemetryExporter.Builder. Look there for reference.
7+ /**
8+ * Properties for configuring the OpenTelemetry exporter.
9+ *
10+ * <p>These properties can be configured via {@code prometheus.properties}, system properties, or
11+ * programmatically.
12+ *
13+ * <p>All properties are prefixed with {@code io.prometheus.exporter.opentelemetry}.
14+ *
15+ * <p>Available properties:
16+ *
17+ * <ul>
18+ * <li>{@code protocol} - OTLP protocol: {@code "grpc"} or {@code "http/protobuf"}
19+ * <li>{@code endpoint} - OTLP endpoint URL
20+ * <li>{@code headers} - HTTP headers for outgoing requests
21+ * <li>{@code intervalSeconds} - Export interval in seconds
22+ * <li>{@code timeoutSeconds} - Request timeout in seconds
23+ * <li>{@code serviceName} - Service name resource attribute
24+ * <li>{@code serviceNamespace} - Service namespace resource attribute
25+ * <li>{@code serviceInstanceId} - Service instance ID resource attribute
26+ * <li>{@code serviceVersion} - Service version resource attribute
27+ * <li>{@code resourceAttributes} - Additional resource attributes
28+ * </ul>
29+ *
30+ * @see <a
31+ * href="https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/">OpenTelemetry
32+ * SDK Environment Variables</a>
33+ */
834public class ExporterOpenTelemetryProperties {
935
1036 // See
@@ -153,6 +179,14 @@ public static class Builder {
153179
154180 private Builder () {}
155181
182+ /**
183+ * The OTLP protocol to use.
184+ *
185+ * <p>Supported values: {@code "grpc"} or {@code "http/protobuf"}.
186+ *
187+ * <p>See OpenTelemetry's <a
188+ * href="https://opentelemetry.io/docs/concepts/sdk-configuration/otlp-exporter-configuration/#otel_exporter_otlp_protocol">OTEL_EXPORTER_OTLP_PROTOCOL</a>.
189+ */
156190 public Builder protocol (String protocol ) {
157191 if (!protocol .equals ("grpc" ) && !protocol .equals ("http/protobuf" )) {
158192 throw new IllegalArgumentException (
@@ -162,17 +196,43 @@ public Builder protocol(String protocol) {
162196 return this ;
163197 }
164198
199+ /**
200+ * The OTLP endpoint to send metric data to.
201+ *
202+ * <p>The default depends on the protocol:
203+ *
204+ * <ul>
205+ * <li>{@code "grpc"}: {@code "http://localhost:4317"}
206+ * <li>{@code "http/protobuf"}: {@code "http://localhost:4318/v1/metrics"}
207+ * </ul>
208+ *
209+ * <p>See OpenTelemetry's <a
210+ * href="https://opentelemetry.io/docs/concepts/sdk-configuration/otlp-exporter-configuration/#otel_exporter_otlp_metrics_endpoint">OTEL_EXPORTER_OTLP_METRICS_ENDPOINT</a>.
211+ */
165212 public Builder endpoint (String endpoint ) {
166213 this .endpoint = endpoint ;
167214 return this ;
168215 }
169216
170- /** Add a request header. Call multiple times to add multiple headers. */
217+ /**
218+ * Add an HTTP header to be applied to outgoing requests. Call multiple times to add multiple
219+ * headers.
220+ *
221+ * <p>See OpenTelemetry's <a
222+ * href="https://opentelemetry.io/docs/concepts/sdk-configuration/otlp-exporter-configuration/#otel_exporter_otlp_headers">OTEL_EXPORTER_OTLP_HEADERS</a>.
223+ */
171224 public Builder header (String name , String value ) {
172225 this .headers .put (name , value );
173226 return this ;
174227 }
175228
229+ /**
230+ * The interval between the start of two export attempts. Default is 60 seconds.
231+ *
232+ * <p>Like OpenTelemetry's <a
233+ * href="https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md#periodic-metric-reader">OTEL_METRIC_EXPORT_INTERVAL</a>
234+ * (which defaults to 60000 milliseconds), but specified in seconds rather than milliseconds.
235+ */
176236 public Builder intervalSeconds (int intervalSeconds ) {
177237 if (intervalSeconds <= 0 ) {
178238 throw new IllegalArgumentException (intervalSeconds + ": Expecting intervalSeconds > 0" );
@@ -181,6 +241,13 @@ public Builder intervalSeconds(int intervalSeconds) {
181241 return this ;
182242 }
183243
244+ /**
245+ * The timeout for outgoing requests. Default is 10.
246+ *
247+ * <p>Like OpenTelemetry's <a
248+ * href="https://opentelemetry.io/docs/concepts/sdk-configuration/otlp-exporter-configuration/#otel_exporter_otlp_metrics_timeout">OTEL_EXPORTER_OTLP_METRICS_TIMEOUT</a>,
249+ * but in seconds rather than milliseconds.
250+ */
184251 public Builder timeoutSeconds (int timeoutSeconds ) {
185252 if (timeoutSeconds <= 0 ) {
186253 throw new IllegalArgumentException (timeoutSeconds + ": Expecting timeoutSeconds > 0" );
@@ -189,26 +256,63 @@ public Builder timeoutSeconds(int timeoutSeconds) {
189256 return this ;
190257 }
191258
259+ /**
260+ * The {@code service.name} resource attribute.
261+ *
262+ * <p>If not explicitly specified, {@code client_java} will try to initialize it with a
263+ * reasonable default, like the JAR file name.
264+ *
265+ * <p>See {@code service.name} in OpenTelemetry's <a
266+ * href="https://opentelemetry.io/docs/specs/otel/resource/semantic_conventions/#service">Resource
267+ * Semantic Conventions</a>.
268+ */
192269 public Builder serviceName (String serviceName ) {
193270 this .serviceName = serviceName ;
194271 return this ;
195272 }
196273
274+ /**
275+ * The {@code service.namespace} resource attribute.
276+ *
277+ * <p>See {@code service.namespace} in OpenTelemetry's <a
278+ * href="https://opentelemetry.io/docs/specs/otel/resource/semantic_conventions/#service-experimental">Resource
279+ * Semantic Conventions</a>.
280+ */
197281 public Builder serviceNamespace (String serviceNamespace ) {
198282 this .serviceNamespace = serviceNamespace ;
199283 return this ;
200284 }
201285
286+ /**
287+ * The {@code service.instance.id} resource attribute.
288+ *
289+ * <p>See {@code service.instance.id} in OpenTelemetry's <a
290+ * href="https://opentelemetry.io/docs/specs/otel/resource/semantic_conventions/#service-experimental">Resource
291+ * Semantic Conventions</a>.
292+ */
202293 public Builder serviceInstanceId (String serviceInstanceId ) {
203294 this .serviceInstanceId = serviceInstanceId ;
204295 return this ;
205296 }
206297
298+ /**
299+ * The {@code service.version} resource attribute.
300+ *
301+ * <p>See {@code service.version} in OpenTelemetry's <a
302+ * href="https://opentelemetry.io/docs/specs/otel/resource/semantic_conventions/#service-experimental">Resource
303+ * Semantic Conventions</a>.
304+ */
207305 public Builder serviceVersion (String serviceVersion ) {
208306 this .serviceVersion = serviceVersion ;
209307 return this ;
210308 }
211309
310+ /**
311+ * Add a resource attribute. Call multiple times to add multiple resource attributes.
312+ *
313+ * <p>See OpenTelemetry's <a
314+ * href="https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#general-sdk-configuration">OTEL_RESOURCE_ATTRIBUTES</a>.
315+ */
212316 public Builder resourceAttribute (String name , String value ) {
213317 this .resourceAttributes .put (name , value );
214318 return this ;
0 commit comments