Skip to content

Commit fb3c315

Browse files
GRPC authority header seems to not have host component sometimes. (#87)
* GRPC authority header seems to not have host component sometimes. Due to this, the host header was being set as :<port>, which isn't right. Fixing the bug to ignore such host header so that the span will be resolved based on the servicename that comes in the span. * Upgrading the avro version and data-model to newer version to fix Snyk issues.
1 parent 4a47807 commit fb3c315

File tree

15 files changed

+32
-22
lines changed

15 files changed

+32
-22
lines changed

hypertrace-ingester/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies {
2828
implementation("org.hypertrace.core.kafkastreams.framework:kafka-streams-framework:0.1.9")
2929
implementation("org.hypertrace.core.serviceframework:platform-service-framework:0.1.9")
3030
implementation("org.hypertrace.core.serviceframework:platform-metrics:0.1.8")
31-
implementation("org.hypertrace.core.datamodel:data-model:0.1.9")
31+
implementation("org.hypertrace.core.datamodel:data-model:0.1.12")
3232
implementation("org.hypertrace.core.viewgenerator:view-generator-framework:0.1.14")
3333
implementation("com.typesafe:config:1.4.0")
3434

hypertrace-trace-enricher/enriched-span-constants/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ sourceSets {
6060
dependencies {
6161
api("com.google.protobuf:protobuf-java-util:3.13.0")
6262

63-
implementation("org.hypertrace.core.datamodel:data-model:0.1.9")
63+
implementation("org.hypertrace.core.datamodel:data-model:0.1.12")
6464
implementation(project(":span-normalizer:raw-span-constants"))
6565
implementation(project(":span-normalizer:span-normalizer-constants"))
6666
implementation("org.hypertrace.entity.service:entity-service-api:0.1.23")

hypertrace-trace-enricher/hypertrace-trace-enricher-api/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tasks.test {
99

1010
dependencies {
1111
implementation(project(":hypertrace-trace-enricher:enriched-span-constants"))
12-
implementation("org.hypertrace.core.datamodel:data-model:0.1.9")
12+
implementation("org.hypertrace.core.datamodel:data-model:0.1.12")
1313

1414
implementation("org.slf4j:slf4j-api:1.7.30")
1515
implementation("org.apache.commons:commons-lang3:3.11")

hypertrace-trace-enricher/hypertrace-trace-enricher-impl/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies {
1616
implementation(project(":semantic-convention-utils"))
1717
implementation(project(":hypertrace-trace-enricher:trace-reader"))
1818

19-
implementation("org.hypertrace.core.datamodel:data-model:0.1.9")
19+
implementation("org.hypertrace.core.datamodel:data-model:0.1.12")
2020
implementation("org.hypertrace.entity.service:entity-service-client:0.1.23")
2121
implementation("org.hypertrace.core.serviceframework:platform-metrics:0.1.18")
2222

hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/ApiBoundaryTypeAttributeEnricher.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,29 +153,29 @@ private Optional<String> getGrpcAuthority(Event event) {
153153

154154
private Optional<String> getSanitizedHostValue(String value) {
155155
if (StringUtils.isNotBlank(value)) {
156-
String host = sanitizeHostValue(value);
157-
if (!LOCALHOST.equalsIgnoreCase(host)) {
158-
return Optional.of(host);
156+
Optional<String> host = sanitizeHostValue(value);
157+
if (host.isPresent() && !LOCALHOST.equalsIgnoreCase(host.get())) {
158+
return host;
159159
}
160160
}
161161
return Optional.empty();
162162
}
163163

164-
private String sanitizeHostValue(String host) {
164+
private Optional<String> sanitizeHostValue(String host) {
165165
if (host.contains(COLON) && !host.startsWith(COLON)) {
166-
return COLON_SPLITTER.splitToList(host).get(0);
166+
return Optional.ofNullable(COLON_SPLITTER.splitToList(host).get(0));
167167
}
168168

169169
// the value is a URL, just return the authority part of it.
170170
try {
171171
URI uri = new URI(host);
172172
if (uri.getScheme() != null) {
173-
return uri.getHost();
173+
return Optional.ofNullable(uri.getHost());
174174
}
175-
return host;
175+
return Optional.of(host);
176176
} catch (URISyntaxException ignore) {
177177
// ignore
178-
return host;
178+
return Optional.empty();
179179
}
180180
}
181181
}

hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/test/java/org/hypertrace/traceenricher/enrichment/enrichers/ApiBoundaryTypeAttributeEnricherTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ public void testEnrichEventWithAuthorityHeader() {
144144
Assertions.assertEquals(EnrichedSpanUtils.getHostHeader(innerEntrySpan), "testHost");
145145
}
146146

147+
@Test
148+
public void testEnrichEventWithIncompleteAuthorityHeader() {
149+
// Try with :port since that seems to be a valid value for some authority headers.
150+
addEnrichedAttributeToEvent(innerEntrySpan,
151+
RawSpanConstants.getValue(org.hypertrace.core.span.constants.v1.Http.HTTP_REQUEST_AUTHORITY_HEADER),
152+
AttributeValueCreator.create(":9000"));
153+
target.enrichEvent(trace, innerEntrySpan);
154+
Assertions.assertNull(EnrichedSpanUtils.getHostHeader(innerEntrySpan));
155+
}
156+
147157
@Test
148158
public void testEnrichEventWithHostHeader() {
149159
addEnrichedAttributeToEvent(innerEntrySpan,

hypertrace-trace-enricher/hypertrace-trace-enricher/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ dependencies {
4646
}
4747

4848
implementation(project(":hypertrace-trace-enricher:hypertrace-trace-enricher-impl"))
49-
implementation("org.hypertrace.core.datamodel:data-model:0.1.9")
49+
implementation("org.hypertrace.core.datamodel:data-model:0.1.12")
5050
implementation("org.hypertrace.core.flinkutils:flink-utils:0.1.6")
5151
implementation("org.hypertrace.core.serviceframework:platform-service-framework:0.1.18")
5252
implementation("org.hypertrace.entity.service:entity-service-client:0.1.23")

hypertrace-trace-enricher/hypertrace-trace-visualizer/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
dependencies {
6-
implementation("org.hypertrace.core.datamodel:data-model:0.1.9")
6+
implementation("org.hypertrace.core.datamodel:data-model:0.1.12")
77

88
implementation("org.json:json:20201115")
99
implementation("org.apache.commons:commons-lang3:3.11")

hypertrace-trace-enricher/trace-reader/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
dependencies {
9-
implementation("org.hypertrace.core.datamodel:data-model:0.1.9")
9+
implementation("org.hypertrace.core.datamodel:data-model:0.1.12")
1010
implementation("org.hypertrace.core.attribute.service:attribute-service-api:0.8.7")
1111
implementation("org.hypertrace.core.attribute.service:caching-attribute-service-client:0.8.7")
1212
implementation("org.hypertrace.core.attribute.service:attribute-projection-registry:0.8.7")

hypertrace-view-generator/hypertrace-view-generator-api/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ sourceSets {
1212
}
1313

1414
dependencies {
15-
api( "org.apache.avro:avro:1.9.2")
15+
api( "org.apache.avro:avro:1.10.1")
1616
}
1717

0 commit comments

Comments
 (0)