From 478182f0360cb4a1c9fa44364b4c2448dafaff55 Mon Sep 17 00:00:00 2001 From: anujgoyal Date: Thu, 30 Dec 2021 17:19:28 +0530 Subject: [PATCH 1/7] Added spanId to the parsing error log --- .../enrichers/HttpAttributeEnricher.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java b/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java index 0982a5473..1fa6b6291 100644 --- a/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java +++ b/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java @@ -15,6 +15,7 @@ import org.hypertrace.core.datamodel.AttributeValue; import org.hypertrace.core.datamodel.Event; import org.hypertrace.core.datamodel.StructuredTrace; +import org.hypertrace.core.datamodel.shared.HexUtils; import org.hypertrace.core.datamodel.shared.trace.AttributeValueCreator; import org.hypertrace.traceenricher.enrichedspan.constants.EnrichedSpanConstants; import org.hypertrace.traceenricher.enrichedspan.constants.utils.EnrichedSpanUtils; @@ -47,7 +48,7 @@ public void enrichEvent(StructuredTrace trace, Event event) { .ifPresent( queryString -> { Map> paramNameToValues = - getQueryParamsFromQueryString(queryString); + getQueryParamsFromQueryString(queryString, HexUtils.getHex(event.getEventId())); for (Map.Entry> queryParamEntry : paramNameToValues.entrySet()) { if (queryParamEntry.getValue().isEmpty()) { continue; @@ -65,7 +66,7 @@ public void enrichEvent(StructuredTrace trace, Event event) { }); } - private Map> getQueryParamsFromQueryString(String queryString) { + private Map> getQueryParamsFromQueryString(String queryString, String spanId) { return Splitter.on(QUERY_PARAM_DELIMITER).splitToList(queryString).stream() // split only on first occurrence of delimiter. eg: cat=1dog=2 should be split to cat -> // 1dog=2 @@ -75,13 +76,13 @@ private Map> getQueryParamsFromQueryString(String queryStri kv -> Pair.of( String.format( - PARAM_ATTR_FORMAT, HTTP_REQUEST_QUERY_PARAM_ATTR, decodeParamKey(kv[0])), - decode(kv[1]))) + PARAM_ATTR_FORMAT, HTTP_REQUEST_QUERY_PARAM_ATTR, decodeParamKey(kv[0], spanId)), + decode(kv[1], spanId))) .collect(groupingBy(Pair::getKey, mapping(Pair::getValue, toList()))); } - private static String decodeParamKey(String input) { - String urlDecodedKey = decode(input); + private static String decodeParamKey(String input, String spanId) { + String urlDecodedKey = decode(input, spanId); /* '[]' can occur at the end of param name which denotes param can have multiple values, we strip '[]' to get original param name */ if (urlDecodedKey.endsWith("[]") && urlDecodedKey.length() > 2) { @@ -90,11 +91,11 @@ private static String decodeParamKey(String input) { return input; } - private static String decode(String input) { + private static String decode(String input, String spanId) { try { return URLDecoder.decode(input, StandardCharsets.UTF_8); } catch (IllegalArgumentException e) { - LOGGER.error("Cannot decode the input {}", input, e); + LOGGER.error("Cannot decode the input {}, span id {}", input, spanId, e); // Falling back to original input if it can't be decoded return input; } From e8080798b82b5567c213f98c8b8ab179c402dfe3 Mon Sep 17 00:00:00 2001 From: anujgoyal Date: Thu, 30 Dec 2021 17:29:08 +0530 Subject: [PATCH 2/7] spotless --- .../enrichment/enrichers/HttpAttributeEnricher.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java b/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java index 1fa6b6291..65c495c51 100644 --- a/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java +++ b/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java @@ -66,7 +66,8 @@ public void enrichEvent(StructuredTrace trace, Event event) { }); } - private Map> getQueryParamsFromQueryString(String queryString, String spanId) { + private Map> getQueryParamsFromQueryString( + String queryString, String spanId) { return Splitter.on(QUERY_PARAM_DELIMITER).splitToList(queryString).stream() // split only on first occurrence of delimiter. eg: cat=1dog=2 should be split to cat -> // 1dog=2 @@ -76,7 +77,9 @@ private Map> getQueryParamsFromQueryString(String queryStri kv -> Pair.of( String.format( - PARAM_ATTR_FORMAT, HTTP_REQUEST_QUERY_PARAM_ATTR, decodeParamKey(kv[0], spanId)), + PARAM_ATTR_FORMAT, + HTTP_REQUEST_QUERY_PARAM_ATTR, + decodeParamKey(kv[0], spanId)), decode(kv[1], spanId))) .collect(groupingBy(Pair::getKey, mapping(Pair::getValue, toList()))); } From 4302b327676eaca548b8b351a6418036d7804044 Mon Sep 17 00:00:00 2001 From: anujgoyal Date: Thu, 30 Dec 2021 18:12:42 +0530 Subject: [PATCH 3/7] checked get --- .../enrichment/enrichers/HttpAttributeEnricher.java | 4 +++- .../enrichment/enrichers/AbstractAttributeEnricherTest.java | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java b/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java index 65c495c51..ac924cd41 100644 --- a/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java +++ b/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java @@ -47,8 +47,10 @@ public void enrichEvent(StructuredTrace trace, Event event) { EnrichedSpanUtils.getQueryString(event) .ifPresent( queryString -> { + String spanId = + event.getEventId() == null ? null : HexUtils.getHex(event.getEventId()); Map> paramNameToValues = - getQueryParamsFromQueryString(queryString, HexUtils.getHex(event.getEventId())); + getQueryParamsFromQueryString(queryString, spanId); for (Map.Entry> queryParamEntry : paramNameToValues.entrySet()) { if (queryParamEntry.getValue().isEmpty()) { continue; diff --git a/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/test/java/org/hypertrace/traceenricher/enrichment/enrichers/AbstractAttributeEnricherTest.java b/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/test/java/org/hypertrace/traceenricher/enrichment/enrichers/AbstractAttributeEnricherTest.java index 21d4cb854..05cc052da 100644 --- a/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/test/java/org/hypertrace/traceenricher/enrichment/enrichers/AbstractAttributeEnricherTest.java +++ b/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/test/java/org/hypertrace/traceenricher/enrichment/enrichers/AbstractAttributeEnricherTest.java @@ -9,6 +9,7 @@ import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -70,6 +71,7 @@ Event createMockEvent() { .when(e.getMetrics()) .thenReturn(Metrics.newBuilder().setMetricMap(new HashMap<>()).build()); when(e.getServiceName()).thenReturn("service"); + when(e.getEventId()).thenReturn(ByteBuffer.wrap("event_id".getBytes(StandardCharsets.UTF_8))); return e; } From aef0e0db40765dc62d47fdcc67b5ac62b96c584a Mon Sep 17 00:00:00 2001 From: anujgoyal Date: Thu, 30 Dec 2021 18:16:59 +0530 Subject: [PATCH 4/7] nit --- .../enrichment/enrichers/HttpAttributeEnricher.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java b/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java index ac924cd41..643376f14 100644 --- a/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java +++ b/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/src/main/java/org/hypertrace/traceenricher/enrichment/enrichers/HttpAttributeEnricher.java @@ -10,6 +10,7 @@ import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; +import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.Pair; import org.hypertrace.core.datamodel.AttributeValue; @@ -48,7 +49,7 @@ public void enrichEvent(StructuredTrace trace, Event event) { .ifPresent( queryString -> { String spanId = - event.getEventId() == null ? null : HexUtils.getHex(event.getEventId()); + Optional.ofNullable(event.getEventId()).map(HexUtils::getHex).orElse(null); Map> paramNameToValues = getQueryParamsFromQueryString(queryString, spanId); for (Map.Entry> queryParamEntry : paramNameToValues.entrySet()) { From ebd4cec9a09c1ad21e24b59deb7cef4ca9cb9ca9 Mon Sep 17 00:00:00 2001 From: anujgoyal Date: Thu, 30 Dec 2021 18:25:50 +0530 Subject: [PATCH 5/7] snyk --- .../hypertrace-view-generator/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts b/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts index 0bd7ae2c5..48c5c3694 100644 --- a/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts +++ b/hypertrace-view-generator/hypertrace-view-generator/build.gradle.kts @@ -40,7 +40,7 @@ dependencies { implementation("org.apache.avro:avro:1.10.2") implementation("org.apache.commons:commons-lang3:3.12.0") - implementation("com.fasterxml.jackson.core:jackson-databind:2.12.2") + implementation("com.fasterxml.jackson.core:jackson-databind:2.13.1") testImplementation("org.junit.jupiter:junit-jupiter:5.7.1") testImplementation("org.mockito:mockito-core:3.8.0") From 73f10e025b28874d944a9d4a28c3e99f7b1ffa77 Mon Sep 17 00:00:00 2001 From: anujgoyal Date: Thu, 30 Dec 2021 18:57:18 +0530 Subject: [PATCH 6/7] update log4j dep --- hypertrace-trace-enricher/trace-reader/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hypertrace-trace-enricher/trace-reader/build.gradle.kts b/hypertrace-trace-enricher/trace-reader/build.gradle.kts index 256f0d399..120765f98 100644 --- a/hypertrace-trace-enricher/trace-reader/build.gradle.kts +++ b/hypertrace-trace-enricher/trace-reader/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter:5.7.1") testImplementation("org.mockito:mockito-inline:3.8.0") testImplementation("org.mockito:mockito-junit-jupiter:3.8.0") - testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j-impl:2.17.0") + testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j-impl:2.17.1") tasks.test { useJUnitPlatform() From c04c899cf1b1f5a078b229407b28cfabb9f58f8f Mon Sep 17 00:00:00 2001 From: anujgoyal Date: Thu, 30 Dec 2021 19:42:03 +0530 Subject: [PATCH 7/7] dep upgrade --- .../hypertrace-trace-enricher-impl/build.gradle.kts | 2 +- hypertrace-trace-enricher/trace-reader/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/build.gradle.kts b/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/build.gradle.kts index 285a81653..ba154441c 100644 --- a/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/build.gradle.kts +++ b/hypertrace-trace-enricher/hypertrace-trace-enricher-impl/build.gradle.kts @@ -21,7 +21,7 @@ dependencies { implementation("org.hypertrace.core.serviceframework:platform-metrics:0.1.28") implementation("org.hypertrace.core.grpcutils:grpc-client-utils:0.6.2") implementation("org.hypertrace.config.service:spaces-config-service-api:0.1.0") - implementation("org.hypertrace.core.grpcutils:grpc-context-utils:0.6.2") + implementation("org.hypertrace.core.grpcutils:grpc-context-utils:0.7.0") implementation("com.typesafe:config:1.4.1") implementation("org.apache.httpcomponents:httpclient:4.5.13") diff --git a/hypertrace-trace-enricher/trace-reader/build.gradle.kts b/hypertrace-trace-enricher/trace-reader/build.gradle.kts index 120765f98..46d4c76b6 100644 --- a/hypertrace-trace-enricher/trace-reader/build.gradle.kts +++ b/hypertrace-trace-enricher/trace-reader/build.gradle.kts @@ -13,7 +13,7 @@ dependencies { api("org.hypertrace.core.datamodel:data-model:0.1.20") implementation("org.hypertrace.core.attribute.service:attribute-projection-registry:0.12.3") implementation("org.hypertrace.core.grpcutils:grpc-client-rx-utils:0.6.2") - implementation("org.hypertrace.core.grpcutils:grpc-context-utils:0.6.2") + implementation("org.hypertrace.core.grpcutils:grpc-context-utils:0.7.0") implementation("io.reactivex.rxjava3:rxjava:3.0.11") annotationProcessor("org.projectlombok:lombok:1.18.20")