Skip to content

Commit bf5e317

Browse files
authored
✨ Default to OTLP exporter (#340)
* ✨ 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
1 parent 4816a22 commit bf5e317

File tree

7 files changed

+20
-9
lines changed

7 files changed

+20
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ The final artifact is in `javaagent/build/libs/hypertrace-agent-<version>-all.ja
4343
Download the [latest version](https://github.com/hypertrace/javaagent/releases/latest/download/hypertrace-agent-all.jar).
4444

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

49-
By default the agent uses Zipkin exporter.
49+
By default the agent uses Otlp exporter.
5050

5151
The configuration precedence order
5252
1. OpenTelemetry Agent's trace config file `OTEL_TRACE_CONFIG`/`otel.trace.config`

example-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
service_name: service_name
22
reporting:
3-
endpoint: http://localhost:9411/api/v2/spans
3+
endpoint: http://localhost:4317

otel-extensions/src/main/java/org/hypertrace/agent/otel/extensions/config/HypertraceConfig.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.hypertrace.agent.config.Config.Opa.Builder;
3939
import org.hypertrace.agent.config.Config.PropagationFormat;
4040
import org.hypertrace.agent.config.Config.Reporting;
41+
import org.hypertrace.agent.config.Config.TraceReporterType;
4142
import org.slf4j.Logger;
4243
import org.slf4j.LoggerFactory;
4344

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

5455
static final String DEFAULT_SERVICE_NAME = "unknown";
55-
static final String DEFAULT_REPORTING_ENDPOINT = "http://localhost:9411/api/v2/spans";
56+
static final String DEFAULT_REPORTING_ENDPOINT = "http://localhost:4317";
5657
static final String DEFAULT_OPA_ENDPOINT = "http://opa.traceableai:8181/";
5758
static final int DEFAULT_OPA_POLL_PERIOD_SECONDS = 30;
5859
// 128 KiB
@@ -143,7 +144,7 @@ private static Reporting.Builder applyReportingDefaults(Reporting.Builder builde
143144
builder.setEndpoint(StringValue.newBuilder().setValue(DEFAULT_REPORTING_ENDPOINT).build());
144145
}
145146
if (builder.getTraceReporterType().equals(Config.TraceReporterType.UNSPECIFIED)) {
146-
builder.setTraceReporterType(Config.TraceReporterType.ZIPKIN);
147+
builder.setTraceReporterType(TraceReporterType.OTLP);
147148
}
148149
Builder opaBuilder = applyOpaDefaults(builder.getOpa().toBuilder());
149150
builder.setOpa(opaBuilder);

otel-extensions/src/test/java/org/hypertrace/agent/otel/extensions/config/HypertraceConfigTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void defaultValues() throws IOException {
4040
Assertions.assertTrue(agentConfig.getEnabled().getValue());
4141
Assertions.assertEquals("unknown", agentConfig.getServiceName().getValue());
4242
Assertions.assertEquals(
43-
TraceReporterType.ZIPKIN, agentConfig.getReporting().getTraceReporterType());
43+
TraceReporterType.OTLP, agentConfig.getReporting().getTraceReporterType());
4444
Assertions.assertEquals(
4545
HypertraceConfig.DEFAULT_REPORTING_ENDPOINT,
4646
agentConfig.getReporting().getEndpoint().getValue());
@@ -106,7 +106,7 @@ private void assertConfig(AgentConfig agentConfig) {
106106
Assertions.assertEquals(
107107
TraceReporterType.OTLP, agentConfig.getReporting().getTraceReporterType());
108108
Assertions.assertEquals(
109-
"http://localhost:9411", agentConfig.getReporting().getEndpoint().getValue());
109+
"http://localhost:4317", agentConfig.getReporting().getEndpoint().getValue());
110110
Assertions.assertEquals(true, agentConfig.getReporting().getSecure().getValue());
111111
Assertions.assertEquals(
112112
"http://opa.localhost:8181/", agentConfig.getReporting().getOpa().getEndpoint().getValue());

otel-extensions/src/test/resources/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ enabled: false
44
propagationFormats:
55
- B3
66
reporting:
7-
endpoint: http://localhost:9411
7+
endpoint: http://localhost:4317
88
secure: true
99
trace_reporter_type: OTLP
1010
opa:

smoke-tests/src/test/java/org/hypertrace/agent/smoketest/AbstractSmokeTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.testcontainers.utility.MountableFile;
5050

5151
public abstract class AbstractSmokeTest {
52+
5253
private static final Logger log = LoggerFactory.getLogger(OpenTelemetryStorage.class);
5354
private static final String OTEL_COLLECTOR_IMAGE = "otel/opentelemetry-collector:0.21.0";
5455
private static final String MOCK_BACKEND_IMAGE =
@@ -159,6 +160,13 @@ protected static Stream<InstrumentationLibrarySpans> getInstrumentationLibSpanSt
159160
.flatMap(resourceSpans -> resourceSpans.getInstrumentationLibrarySpansList().stream());
160161
}
161162

163+
protected Collection<ExportTraceServiceRequest> waitForTraces(final int count) {
164+
return Awaitility.await()
165+
.until(
166+
this::waitForTraces,
167+
exportTraceServiceRequests -> exportTraceServiceRequests.size() == count);
168+
}
169+
162170
protected Collection<ExportTraceServiceRequest> waitForTraces() throws IOException {
163171
String content = waitForContent();
164172

smoke-tests/src/test/java/org/hypertrace/agent/smoketest/SpringBootSmokeTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.opentelemetry.semconv.resource.attributes.ResourceAttributes;
2121
import java.io.IOException;
2222
import java.util.ArrayList;
23+
import java.util.Collection;
2324
import java.util.List;
2425
import java.util.jar.Attributes;
2526
import java.util.jar.JarFile;
@@ -185,7 +186,8 @@ public void postJson_payload_truncation() throws IOException {
185186
try (Response response = client.newCall(request).execute()) {
186187
Assertions.assertEquals(response.body().string(), requestBody);
187188
}
188-
ArrayList<ExportTraceServiceRequest> traces = new ArrayList<>(waitForTraces());
189+
190+
Collection<ExportTraceServiceRequest> traces = waitForTraces(2);
189191

190192
List<String> responseBodyAttributes =
191193
getSpanStream(traces)

0 commit comments

Comments
 (0)