Skip to content

Commit e599d0e

Browse files
authored
Change the default port that the OTLP exporters point to. (#2113)
* Change the default port that the OTLP exporters point to. * extract constants for the export metrics labels
1 parent 4897f4c commit e599d0e

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

exporters/otlp/src/main/java/io/opentelemetry/exporter/otlp/OtlpGrpcMetricExporter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
*/
6666
@ThreadSafe
6767
public final class OtlpGrpcMetricExporter implements MetricExporter {
68-
public static final String DEFAULT_ENDPOINT = "localhost:55680";
68+
public static final String DEFAULT_ENDPOINT = "localhost:4317";
6969
public static final long DEFAULT_DEADLINE_MS = TimeUnit.SECONDS.toMillis(1);
7070
private static final boolean DEFAULT_USE_TLS = false;
7171

@@ -206,7 +206,7 @@ public Builder setDeadlineMs(long deadlineMs) {
206206
}
207207

208208
/**
209-
* Sets the OTLP endpoint to connect to. Optional, defaults to "localhost:55680".
209+
* Sets the OTLP endpoint to connect to. Optional, defaults to "localhost:4317".
210210
*
211211
* @param endpoint endpoint to connect to
212212
* @return this builder's instance

exporters/otlp/src/main/java/io/opentelemetry/exporter/otlp/OtlpGrpcSpanExporter.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,18 @@
7070
@ThreadSafe
7171
public final class OtlpGrpcSpanExporter implements SpanExporter {
7272

73-
public static final String DEFAULT_ENDPOINT = "localhost:55680";
73+
public static final String DEFAULT_ENDPOINT = "localhost:4317";
7474
public static final long DEFAULT_DEADLINE_MS = TimeUnit.SECONDS.toMillis(1);
7575

7676
private static final Logger logger = Logger.getLogger(OtlpGrpcSpanExporter.class.getName());
7777
private static final boolean DEFAULT_USE_TLS = false;
78+
private static final String EXPORTER_NAME = OtlpGrpcSpanExporter.class.getSimpleName();
79+
80+
private static final Labels EXPORTER_NAME_LABELS = Labels.of("exporter", EXPORTER_NAME);
81+
private static final Labels EXPORT_SUCCESS_LABELS =
82+
Labels.of("exporter", EXPORTER_NAME, "success", "true");
83+
private static final Labels EXPORT_FAILURE_LABELS =
84+
Labels.of("exporter", EXPORTER_NAME, "success", "false");
7885

7986
private final TraceServiceFutureStub traceService;
8087
private final ManagedChannel managedChannel;
@@ -111,8 +118,7 @@ private OtlpGrpcSpanExporter(ManagedChannel channel, long deadlineMs) {
111118
*/
112119
@Override
113120
public CompletableResultCode export(Collection<SpanData> spans) {
114-
spansSeen.add(
115-
spans.size(), Labels.of("exporter", OtlpGrpcMetricExporter.class.getSimpleName()));
121+
spansSeen.add(spans.size(), EXPORTER_NAME_LABELS);
116122
ExportTraceServiceRequest exportTraceServiceRequest =
117123
ExportTraceServiceRequest.newBuilder()
118124
.addAllResourceSpans(SpanAdapter.toProtoResourceSpans(spans))
@@ -132,19 +138,13 @@ public CompletableResultCode export(Collection<SpanData> spans) {
132138
new FutureCallback<ExportTraceServiceResponse>() {
133139
@Override
134140
public void onSuccess(@Nullable ExportTraceServiceResponse response) {
135-
spansExported.add(
136-
spans.size(),
137-
Labels.of(
138-
"exporter", OtlpGrpcMetricExporter.class.getSimpleName(), "success", "true"));
141+
spansExported.add(spans.size(), EXPORT_SUCCESS_LABELS);
139142
result.succeed();
140143
}
141144

142145
@Override
143146
public void onFailure(Throwable t) {
144-
spansExported.add(
145-
spans.size(),
146-
Labels.of(
147-
"exporter", OtlpGrpcMetricExporter.class.getSimpleName(), "success", "false"));
147+
spansExported.add(spans.size(), EXPORT_FAILURE_LABELS);
148148
logger.log(Level.WARNING, "Failed to export spans. Error message: " + t.getMessage());
149149
logger.log(Level.FINEST, "Failed to export spans. Details follow: " + t);
150150
result.fail();
@@ -240,7 +240,7 @@ public Builder setDeadlineMs(long deadlineMs) {
240240
}
241241

242242
/**
243-
* Sets the OTLP endpoint to connect to. Optional, defaults to "localhost:55680".
243+
* Sets the OTLP endpoint to connect to. Optional, defaults to "localhost:4317".
244244
*
245245
* @param endpoint endpoint to connect to
246246
* @return this builder's instance

perf-harness/src/test/java/io/opentelemetry/perf/OtlpPipelineStressTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
@SuppressWarnings({"FutureReturnValueIgnored", "CatchAndPrintStackTrace"})
5252
public class OtlpPipelineStressTest {
5353

54-
public static final int OTLP_RECEIVER_PORT = 55680;
54+
public static final int OTLP_RECEIVER_PORT =
55+
55680; // todo: switch to 4317 when that port makes it into the collector docker image.
5556
public static final int COLLECTOR_PROXY_PORT = 44444;
5657
public static final int TOXIPROXY_CONTROL_PORT = 8474;
5758
public static Network network = Network.newNetwork();

0 commit comments

Comments
 (0)