Skip to content

Commit ca167d3

Browse files
authored
Update hypertrace config (#151)
* Update hypertrace config Signed-off-by: Pavol Loffay <[email protected]> * fixes Signed-off-by: Pavol Loffay <[email protected]>
1 parent ac858f5 commit ca167d3

File tree

16 files changed

+56
-53
lines changed

16 files changed

+56
-53
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ clean:
2323

2424
.PHONY: init-submodules
2525
init-submodules:
26-
git submodule update --init --recursive
26+
git submodule update --init

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The final artifact is in `javaagent/build/libs/hypertrace-agent-<version>-all.ja
3535
## Run & Configure
3636

3737
```bash
38-
HT_EXPORTING_ADDRESS=http://localhost:9411/api/v2/spans java -javaagent:javaagent/build/libs/hypertrace-agent-<version>-all.jar -jar app.jar
38+
HT_EXPORTING_ENDPOINT=http://localhost:9411/api/v2/spans java -javaagent:javaagent/build/libs/hypertrace-agent-<version>-all.jar -jar app.jar
3939
```
4040

4141
By default the agent uses Zipkin exporter.

example-config.yaml

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

filter-custom-opa/src/main/java/org/hypertrace/agent/filter/opa/custom/CustomOpaLibProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public Filter create() {
4141
AgentConfig agentConfig = HypertraceConfig.get();
4242
Reporting reporting = agentConfig.getReporting();
4343
return new CustomOpaLib(
44-
reporting.getOpa().getAddress().getValue(),
44+
reporting.getOpa().getEndpoint().getValue(),
4545
reporting.getToken().getValue(),
4646
reporting.getSecure().getValue(),
47-
reporting.getOpa().getPollPeriod().getValue());
47+
reporting.getOpa().getPollPeriodSeconds().getValue());
4848
}
4949
}

javaagent-core/src/main/java/org/hypertrace/agent/core/EnvironmentConfig.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ private EnvironmentConfig() {}
3939
static final String PROPAGATION_FORMATS = HT_PREFIX + "propagation.formats";
4040

4141
private static final String REPORTING_PREFIX = HT_PREFIX + "reporting.";
42-
static final String REPORTING_ADDRESS = REPORTING_PREFIX + "address";
42+
static final String REPORTING_ENDPOINT = REPORTING_PREFIX + "endpoint";
4343
static final String REPORTING_SECURE = REPORTING_PREFIX + "secure";
4444

4545
private static final String OPA_PREFIX = REPORTING_PREFIX + "opa.";
46-
static final String OPA_ADDRESS = OPA_PREFIX + "address";
47-
static final String OPA_POLL_PERIOD = OPA_PREFIX + "poll.period";
46+
static final String OPA_ENDPOINT = OPA_PREFIX + "endpoint";
47+
static final String OPA_POLL_PERIOD = OPA_PREFIX + "poll.period.seconds";
4848

4949
private static final String CAPTURE_PREFIX = HT_PREFIX + "data.capture.";
5050
public static final String CAPTURE_HTTP_HEADERS_PREFIX = CAPTURE_PREFIX + "http.headers.";
@@ -79,9 +79,9 @@ private static void applyPropagationFormat(AgentConfig.Builder builder) {
7979
}
8080

8181
private static Reporting.Builder applyReporting(Reporting.Builder builder) {
82-
String reporterAddress = getProperty(REPORTING_ADDRESS);
82+
String reporterAddress = getProperty(REPORTING_ENDPOINT);
8383
if (reporterAddress != null) {
84-
builder.setAddress(StringValue.newBuilder().setValue(reporterAddress).build());
84+
builder.setEndpoint(StringValue.newBuilder().setValue(reporterAddress).build());
8585
}
8686
String secure = getProperty(REPORTING_SECURE);
8787
if (secure != null) {
@@ -93,13 +93,14 @@ private static Reporting.Builder applyReporting(Reporting.Builder builder) {
9393
}
9494

9595
private static Opa.Builder applyOpa(Opa.Builder builder) {
96-
String address = getProperty(OPA_ADDRESS);
96+
String address = getProperty(OPA_ENDPOINT);
9797
if (address != null) {
98-
builder.setAddress(StringValue.newBuilder().setValue(address).build());
98+
builder.setEndpoint(StringValue.newBuilder().setValue(address).build());
9999
}
100100
String pollPeriod = getProperty(OPA_POLL_PERIOD);
101101
if (pollPeriod != null) {
102-
builder.setPollPeriod(Int32Value.newBuilder().setValue(Integer.parseInt(pollPeriod)).build());
102+
builder.setPollPeriodSeconds(
103+
Int32Value.newBuilder().setValue(Integer.parseInt(pollPeriod)).build());
103104
}
104105
return builder;
105106
}

javaagent-core/src/main/java/org/hypertrace/agent/core/HypertraceConfig.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ private HypertraceConfig() {}
5050
private static AgentConfig agentConfig;
5151

5252
static final String DEFAULT_SERVICE_NAME = "unknown";
53-
static final String DEFAULT_REPORTING_ADDRESS = "http://localhost:9411/api/v2/spans";
54-
static final String DEFAULT_OPA_ADDRESS = "http://opa.traceableai:8181/";
53+
static final String DEFAULT_REPORTING_ENDPOINT = "http://localhost:9411/api/v2/spans";
54+
static final String DEFAULT_OPA_ENDPOINT = "http://opa.traceableai:8181/";
5555
static final int DEFAULT_OPA_POLL_PERIOD_SECONDS = 30;
5656

5757
public static AgentConfig get() {
@@ -139,26 +139,26 @@ private static AgentConfig.Builder applyDefaults(AgentConfig.Builder configBuild
139139
configBuilder.setDataCapture(dataCaptureBuilder);
140140

141141
if (configBuilder.getPropagationFormatsList().isEmpty()) {
142-
configBuilder.addPropagationFormats(PropagationFormat.TRACE_CONTEXT);
142+
configBuilder.addPropagationFormats(PropagationFormat.TRACECONTEXT);
143143
}
144144
return configBuilder;
145145
}
146146

147147
private static Reporting.Builder applyReportingDefaults(Reporting.Builder builder) {
148-
if (!builder.hasAddress()) {
149-
builder.setAddress(StringValue.newBuilder().setValue(DEFAULT_REPORTING_ADDRESS).build());
148+
if (!builder.hasEndpoint()) {
149+
builder.setEndpoint(StringValue.newBuilder().setValue(DEFAULT_REPORTING_ENDPOINT).build());
150150
}
151151
Builder opaBuilder = applyOpaDefaults(builder.getOpa().toBuilder());
152152
builder.setOpa(opaBuilder);
153153
return builder;
154154
}
155155

156156
private static Opa.Builder applyOpaDefaults(Opa.Builder builder) {
157-
if (!builder.hasAddress()) {
158-
builder.setAddress(StringValue.newBuilder().setValue(DEFAULT_OPA_ADDRESS).build());
157+
if (!builder.hasEndpoint()) {
158+
builder.setEndpoint(StringValue.newBuilder().setValue(DEFAULT_OPA_ENDPOINT).build());
159159
}
160-
if (!builder.hasPollPeriod()) {
161-
builder.setPollPeriod(
160+
if (!builder.hasPollPeriodSeconds()) {
161+
builder.setPollPeriodSeconds(
162162
Int32Value.newBuilder().setValue(DEFAULT_OPA_POLL_PERIOD_SECONDS).build());
163163
}
164164
return builder;

javaagent-core/src/main/resources/META-INF/services/io.opentelemetry.sdk.resources.ResourceProvider

Whitespace-only changes.

javaagent-core/src/test/java/org/hypertrace/agent/core/EnvironmentConfigTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,35 @@
2727
class EnvironmentConfigTest {
2828

2929
@Test
30-
@ClearSystemProperty(key = EnvironmentConfig.REPORTING_ADDRESS)
30+
@ClearSystemProperty(key = EnvironmentConfig.REPORTING_ENDPOINT)
3131
@ClearSystemProperty(key = EnvironmentConfig.REPORTING_SECURE)
32-
@ClearSystemProperty(key = EnvironmentConfig.OPA_ADDRESS)
32+
@ClearSystemProperty(key = EnvironmentConfig.OPA_ENDPOINT)
3333
@ClearSystemProperty(key = EnvironmentConfig.OPA_POLL_PERIOD)
3434
@ClearSystemProperty(key = EnvironmentConfig.PROPAGATION_FORMATS)
3535
@ClearSystemProperty(key = EnvironmentConfig.CAPTURE_HTTP_BODY_PREFIX + "request")
3636
public void systemProperties() {
3737
// when tests are run in parallel the env vars/sys props set it junit-pioneer are visible to
3838
// parallel tests
39-
System.setProperty(EnvironmentConfig.REPORTING_ADDRESS, "http://:-)");
39+
System.setProperty(EnvironmentConfig.REPORTING_ENDPOINT, "http://:-)");
4040
System.setProperty(EnvironmentConfig.REPORTING_SECURE, "true");
4141
System.setProperty(EnvironmentConfig.CAPTURE_HTTP_BODY_PREFIX + "request", "true");
42-
System.setProperty(EnvironmentConfig.OPA_ADDRESS, "http://azkaban:9090");
42+
System.setProperty(EnvironmentConfig.OPA_ENDPOINT, "http://azkaban:9090");
4343
System.setProperty(EnvironmentConfig.OPA_POLL_PERIOD, "10");
44-
System.setProperty(EnvironmentConfig.PROPAGATION_FORMATS, "B3,TRACE_CONTEXT");
44+
System.setProperty(EnvironmentConfig.PROPAGATION_FORMATS, "B3,TRACECONTEXT");
4545

4646
AgentConfig.Builder configBuilder = AgentConfig.newBuilder();
4747
configBuilder.setServiceName(StringValue.newBuilder().setValue("foo"));
4848

4949
AgentConfig agentConfig = EnvironmentConfig.applyPropertiesAndEnvVars(configBuilder).build();
5050
Assertions.assertEquals("foo", agentConfig.getServiceName().getValue());
5151
Assertions.assertEquals(
52-
Arrays.asList(PropagationFormat.B3, PropagationFormat.TRACE_CONTEXT),
52+
Arrays.asList(PropagationFormat.B3, PropagationFormat.TRACECONTEXT),
5353
agentConfig.getPropagationFormatsList());
54-
Assertions.assertEquals("http://:-)", agentConfig.getReporting().getAddress().getValue());
54+
Assertions.assertEquals("http://:-)", agentConfig.getReporting().getEndpoint().getValue());
5555
Assertions.assertEquals(
56-
"http://azkaban:9090", agentConfig.getReporting().getOpa().getAddress().getValue());
57-
Assertions.assertEquals(10, agentConfig.getReporting().getOpa().getPollPeriod().getValue());
56+
"http://azkaban:9090", agentConfig.getReporting().getOpa().getEndpoint().getValue());
57+
Assertions.assertEquals(
58+
10, agentConfig.getReporting().getOpa().getPollPeriodSeconds().getValue());
5859
Assertions.assertEquals(true, agentConfig.getReporting().getSecure().getValue());
5960
Assertions.assertEquals(
6061
true, agentConfig.getDataCapture().getHttpBody().getRequest().getValue());

javaagent-core/src/test/java/org/hypertrace/agent/core/HypertraceConfigTest.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ public void defaultValues() throws IOException {
3737
AgentConfig agentConfig = HypertraceConfig.load(resource.getPath());
3838
Assertions.assertEquals("unknown", agentConfig.getServiceName().getValue());
3939
Assertions.assertEquals(
40-
HypertraceConfig.DEFAULT_REPORTING_ADDRESS,
41-
agentConfig.getReporting().getAddress().getValue());
40+
HypertraceConfig.DEFAULT_REPORTING_ENDPOINT,
41+
agentConfig.getReporting().getEndpoint().getValue());
4242
Assertions.assertEquals(
43-
Arrays.asList(PropagationFormat.TRACE_CONTEXT), agentConfig.getPropagationFormatsList());
43+
Arrays.asList(PropagationFormat.TRACECONTEXT), agentConfig.getPropagationFormatsList());
4444
Assertions.assertEquals(false, agentConfig.getReporting().getSecure().getValue());
4545
Assertions.assertEquals(
46-
HypertraceConfig.DEFAULT_OPA_ADDRESS,
47-
agentConfig.getReporting().getOpa().getAddress().getValue());
46+
HypertraceConfig.DEFAULT_OPA_ENDPOINT,
47+
agentConfig.getReporting().getOpa().getEndpoint().getValue());
4848
Assertions.assertEquals(
4949
HypertraceConfig.DEFAULT_OPA_POLL_PERIOD_SECONDS,
50-
agentConfig.getReporting().getOpa().getPollPeriod().getValue());
50+
agentConfig.getReporting().getOpa().getPollPeriodSeconds().getValue());
5151
Assertions.assertEquals(
5252
true, agentConfig.getDataCapture().getHttpHeaders().getRequest().getValue());
5353
Assertions.assertEquals(
@@ -93,11 +93,12 @@ private void assertConfig(AgentConfig agentConfig) {
9393
Assertions.assertEquals(
9494
Arrays.asList(PropagationFormat.B3), agentConfig.getPropagationFormatsList());
9595
Assertions.assertEquals(
96-
"http://localhost:9411", agentConfig.getReporting().getAddress().getValue());
96+
"http://localhost:9411", agentConfig.getReporting().getEndpoint().getValue());
9797
Assertions.assertEquals(true, agentConfig.getReporting().getSecure().getValue());
9898
Assertions.assertEquals(
99-
"http://opa.localhost:8181/", agentConfig.getReporting().getOpa().getAddress().getValue());
100-
Assertions.assertEquals(12, agentConfig.getReporting().getOpa().getPollPeriod().getValue());
99+
"http://opa.localhost:8181/", agentConfig.getReporting().getOpa().getEndpoint().getValue());
100+
Assertions.assertEquals(
101+
12, agentConfig.getReporting().getOpa().getPollPeriodSeconds().getValue());
101102
Assertions.assertEquals(
102103
true, agentConfig.getDataCapture().getHttpHeaders().getRequest().getValue());
103104
Assertions.assertEquals(
@@ -109,14 +110,14 @@ private void assertConfig(AgentConfig agentConfig) {
109110
}
110111

111112
@Test
112-
@ClearSystemProperty(key = EnvironmentConfig.REPORTING_ADDRESS)
113+
@ClearSystemProperty(key = EnvironmentConfig.REPORTING_ENDPOINT)
113114
public void configWithSystemProps() throws IOException {
114-
System.setProperty(EnvironmentConfig.REPORTING_ADDRESS, "http://nowhere.here");
115+
System.setProperty(EnvironmentConfig.REPORTING_ENDPOINT, "http://nowhere.here");
115116

116117
URL resource = getClass().getClassLoader().getResource("config.yaml");
117118
AgentConfig agentConfig = HypertraceConfig.load(resource.getPath());
118119
Assertions.assertEquals(
119-
"http://nowhere.here", agentConfig.getReporting().getAddress().getValue());
120+
"http://nowhere.here", agentConfig.getReporting().getEndpoint().getValue());
120121
Assertions.assertEquals("service", agentConfig.getServiceName().getValue());
121122
}
122123
}

0 commit comments

Comments
 (0)