Skip to content

Commit 107b984

Browse files
committed
Update documentation for the deferred approach
1 parent e2e3642 commit 107b984

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

exporters/trace/src/main/java/com/google/cloud/opentelemetry/trace/TraceExporter.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.google.cloud.opentelemetry.trace;
1717

18+
import com.google.cloud.ServiceOptions;
1819
import io.opentelemetry.sdk.common.CompletableResultCode;
1920
import io.opentelemetry.sdk.trace.data.SpanData;
2021
import io.opentelemetry.sdk.trace.export.SpanExporter;
@@ -42,10 +43,36 @@ private SpanExporter createActualTraceExporter() throws IOException {
4243
this.customTraceConfigurationBuilder.build());
4344
}
4445

46+
/**
47+
* Method that generates an instance of {@link TraceExporter} using a minimally configured {@link
48+
* TraceConfiguration} object that requires no input from the user. Since no project ID is
49+
* specified, default project ID is used instead. See {@link ServiceOptions#getDefaultProjectId()}
50+
* for details.
51+
*
52+
* <p>This method defers the creation of an actual {@link TraceExporter} to a point when it is
53+
* actually needed - which is when the spans need to be exported. As a result, while this method
54+
* does not throw any exception, an exception may still be thrown during the attempt to generate
55+
* the actual {@link TraceExporter}.
56+
*
57+
* @return An instance of {@link TraceExporter} as a {@link SpanExporter} object.
58+
*/
4559
public static SpanExporter createWithDefaultConfiguration() {
4660
return generateStubTraceExporter(TraceConfiguration.builder());
4761
}
4862

63+
/**
64+
* Method that generates an instance of {@link TraceExporter} using a {@link
65+
* TraceConfiguration.Builder} that allows the user to provide preferences.
66+
*
67+
* <p>This method defers the creation of an actual {@link TraceExporter} to a point when it is
68+
* actually needed - which is when the spans need to be exported. As a result, while this method
69+
* does not throw any exception, an exception may still be thrown during the attempt to generate
70+
* the actual {@link TraceExporter}.
71+
*
72+
* @param configBuilder The {@link TraceConfiguration.Builder} object containing user preferences
73+
* for Trace.
74+
* @return An instance of {@link TraceExporter} as a {@link SpanExporter} object.
75+
*/
4976
public static SpanExporter createWithConfiguration(TraceConfiguration.Builder configBuilder) {
5077
return generateStubTraceExporter(configBuilder);
5178
}

0 commit comments

Comments
 (0)