Skip to content

Commit

Permalink
✨ Default to OTLP exporter (#340)
Browse files Browse the repository at this point in the history
* ✨ default to OTLP exporting

* ✅ update test to verify default type is OTLP exporter

* ✨ update example config to use OTLP endpoint

* ✅ update hypertrace conifg test

* 📝 fix readme

* 📝 update readme

* 🐛 fix bug where first request to waitForTraces doesnt always have the request trace
  • Loading branch information
ryandens authored Jul 23, 2021
1 parent 4816a22 commit bf5e317
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ The final artifact is in `javaagent/build/libs/hypertrace-agent-<version>-all.ja
Download the [latest version](https://github.com/hypertrace/javaagent/releases/latest/download/hypertrace-agent-all.jar).

```bash
HT_EXPORTING_ENDPOINT=http://localhost:9411/api/v2/spans java -javaagent:javaagent/build/libs/hypertrace-agent-<version>-all.jar -jar app.jar
HT_REPORTING_ENDPOINT=http://localhost:4317 java -javaagent:javaagent/build/libs/hypertrace-agent-<version>-all.jar -jar app.jar
```

By default the agent uses Zipkin exporter.
By default the agent uses Otlp exporter.

The configuration precedence order
1. OpenTelemetry Agent's trace config file `OTEL_TRACE_CONFIG`/`otel.trace.config`
Expand Down
2 changes: 1 addition & 1 deletion example-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
service_name: service_name
reporting:
endpoint: http://localhost:9411/api/v2/spans
endpoint: http://localhost:4317
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.hypertrace.agent.config.Config.Opa.Builder;
import org.hypertrace.agent.config.Config.PropagationFormat;
import org.hypertrace.agent.config.Config.Reporting;
import org.hypertrace.agent.config.Config.TraceReporterType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -52,7 +53,7 @@ private HypertraceConfig() {}
private static volatile AgentConfig agentConfig;

static final String DEFAULT_SERVICE_NAME = "unknown";
static final String DEFAULT_REPORTING_ENDPOINT = "http://localhost:9411/api/v2/spans";
static final String DEFAULT_REPORTING_ENDPOINT = "http://localhost:4317";
static final String DEFAULT_OPA_ENDPOINT = "http://opa.traceableai:8181/";
static final int DEFAULT_OPA_POLL_PERIOD_SECONDS = 30;
// 128 KiB
Expand Down Expand Up @@ -143,7 +144,7 @@ private static Reporting.Builder applyReportingDefaults(Reporting.Builder builde
builder.setEndpoint(StringValue.newBuilder().setValue(DEFAULT_REPORTING_ENDPOINT).build());
}
if (builder.getTraceReporterType().equals(Config.TraceReporterType.UNSPECIFIED)) {
builder.setTraceReporterType(Config.TraceReporterType.ZIPKIN);
builder.setTraceReporterType(TraceReporterType.OTLP);
}
Builder opaBuilder = applyOpaDefaults(builder.getOpa().toBuilder());
builder.setOpa(opaBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void defaultValues() throws IOException {
Assertions.assertTrue(agentConfig.getEnabled().getValue());
Assertions.assertEquals("unknown", agentConfig.getServiceName().getValue());
Assertions.assertEquals(
TraceReporterType.ZIPKIN, agentConfig.getReporting().getTraceReporterType());
TraceReporterType.OTLP, agentConfig.getReporting().getTraceReporterType());
Assertions.assertEquals(
HypertraceConfig.DEFAULT_REPORTING_ENDPOINT,
agentConfig.getReporting().getEndpoint().getValue());
Expand Down Expand Up @@ -106,7 +106,7 @@ private void assertConfig(AgentConfig agentConfig) {
Assertions.assertEquals(
TraceReporterType.OTLP, agentConfig.getReporting().getTraceReporterType());
Assertions.assertEquals(
"http://localhost:9411", agentConfig.getReporting().getEndpoint().getValue());
"http://localhost:4317", agentConfig.getReporting().getEndpoint().getValue());
Assertions.assertEquals(true, agentConfig.getReporting().getSecure().getValue());
Assertions.assertEquals(
"http://opa.localhost:8181/", agentConfig.getReporting().getOpa().getEndpoint().getValue());
Expand Down
2 changes: 1 addition & 1 deletion otel-extensions/src/test/resources/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ enabled: false
propagationFormats:
- B3
reporting:
endpoint: http://localhost:9411
endpoint: http://localhost:4317
secure: true
trace_reporter_type: OTLP
opa:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.testcontainers.utility.MountableFile;

public abstract class AbstractSmokeTest {

private static final Logger log = LoggerFactory.getLogger(OpenTelemetryStorage.class);
private static final String OTEL_COLLECTOR_IMAGE = "otel/opentelemetry-collector:0.21.0";
private static final String MOCK_BACKEND_IMAGE =
Expand Down Expand Up @@ -159,6 +160,13 @@ protected static Stream<InstrumentationLibrarySpans> getInstrumentationLibSpanSt
.flatMap(resourceSpans -> resourceSpans.getInstrumentationLibrarySpansList().stream());
}

protected Collection<ExportTraceServiceRequest> waitForTraces(final int count) {
return Awaitility.await()
.until(
this::waitForTraces,
exportTraceServiceRequests -> exportTraceServiceRequests.size() == count);
}

protected Collection<ExportTraceServiceRequest> waitForTraces() throws IOException {
String content = waitForContent();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
Expand Down Expand Up @@ -185,7 +186,8 @@ public void postJson_payload_truncation() throws IOException {
try (Response response = client.newCall(request).execute()) {
Assertions.assertEquals(response.body().string(), requestBody);
}
ArrayList<ExportTraceServiceRequest> traces = new ArrayList<>(waitForTraces());

Collection<ExportTraceServiceRequest> traces = waitForTraces(2);

List<String> responseBodyAttributes =
getSpanStream(traces)
Expand Down

0 comments on commit bf5e317

Please sign in to comment.