Skip to content

Commit

Permalink
Change the default port that the OTLP exporters point to. (#2113)
Browse files Browse the repository at this point in the history
* Change the default port that the OTLP exporters point to.

* extract constants for the export metrics labels
  • Loading branch information
jkwatson authored Nov 23, 2020
1 parent 4897f4c commit e599d0e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
*/
@ThreadSafe
public final class OtlpGrpcMetricExporter implements MetricExporter {
public static final String DEFAULT_ENDPOINT = "localhost:55680";
public static final String DEFAULT_ENDPOINT = "localhost:4317";
public static final long DEFAULT_DEADLINE_MS = TimeUnit.SECONDS.toMillis(1);
private static final boolean DEFAULT_USE_TLS = false;

Expand Down Expand Up @@ -206,7 +206,7 @@ public Builder setDeadlineMs(long deadlineMs) {
}

/**
* Sets the OTLP endpoint to connect to. Optional, defaults to "localhost:55680".
* Sets the OTLP endpoint to connect to. Optional, defaults to "localhost:4317".
*
* @param endpoint endpoint to connect to
* @return this builder's instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,18 @@
@ThreadSafe
public final class OtlpGrpcSpanExporter implements SpanExporter {

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

private static final Logger logger = Logger.getLogger(OtlpGrpcSpanExporter.class.getName());
private static final boolean DEFAULT_USE_TLS = false;
private static final String EXPORTER_NAME = OtlpGrpcSpanExporter.class.getSimpleName();

private static final Labels EXPORTER_NAME_LABELS = Labels.of("exporter", EXPORTER_NAME);
private static final Labels EXPORT_SUCCESS_LABELS =
Labels.of("exporter", EXPORTER_NAME, "success", "true");
private static final Labels EXPORT_FAILURE_LABELS =
Labels.of("exporter", EXPORTER_NAME, "success", "false");

private final TraceServiceFutureStub traceService;
private final ManagedChannel managedChannel;
Expand Down Expand Up @@ -111,8 +118,7 @@ private OtlpGrpcSpanExporter(ManagedChannel channel, long deadlineMs) {
*/
@Override
public CompletableResultCode export(Collection<SpanData> spans) {
spansSeen.add(
spans.size(), Labels.of("exporter", OtlpGrpcMetricExporter.class.getSimpleName()));
spansSeen.add(spans.size(), EXPORTER_NAME_LABELS);
ExportTraceServiceRequest exportTraceServiceRequest =
ExportTraceServiceRequest.newBuilder()
.addAllResourceSpans(SpanAdapter.toProtoResourceSpans(spans))
Expand All @@ -132,19 +138,13 @@ public CompletableResultCode export(Collection<SpanData> spans) {
new FutureCallback<ExportTraceServiceResponse>() {
@Override
public void onSuccess(@Nullable ExportTraceServiceResponse response) {
spansExported.add(
spans.size(),
Labels.of(
"exporter", OtlpGrpcMetricExporter.class.getSimpleName(), "success", "true"));
spansExported.add(spans.size(), EXPORT_SUCCESS_LABELS);
result.succeed();
}

@Override
public void onFailure(Throwable t) {
spansExported.add(
spans.size(),
Labels.of(
"exporter", OtlpGrpcMetricExporter.class.getSimpleName(), "success", "false"));
spansExported.add(spans.size(), EXPORT_FAILURE_LABELS);
logger.log(Level.WARNING, "Failed to export spans. Error message: " + t.getMessage());
logger.log(Level.FINEST, "Failed to export spans. Details follow: " + t);
result.fail();
Expand Down Expand Up @@ -240,7 +240,7 @@ public Builder setDeadlineMs(long deadlineMs) {
}

/**
* Sets the OTLP endpoint to connect to. Optional, defaults to "localhost:55680".
* Sets the OTLP endpoint to connect to. Optional, defaults to "localhost:4317".
*
* @param endpoint endpoint to connect to
* @return this builder's instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
@SuppressWarnings({"FutureReturnValueIgnored", "CatchAndPrintStackTrace"})
public class OtlpPipelineStressTest {

public static final int OTLP_RECEIVER_PORT = 55680;
public static final int OTLP_RECEIVER_PORT =
55680; // todo: switch to 4317 when that port makes it into the collector docker image.
public static final int COLLECTOR_PROXY_PORT = 44444;
public static final int TOXIPROXY_CONTROL_PORT = 8474;
public static Network network = Network.newNetwork();
Expand Down

0 comments on commit e599d0e

Please sign in to comment.