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/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..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,11 +10,13 @@ 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; 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; @@ -46,8 +48,10 @@ public void enrichEvent(StructuredTrace trace, Event event) { EnrichedSpanUtils.getQueryString(event) .ifPresent( queryString -> { + String spanId = + Optional.ofNullable(event.getEventId()).map(HexUtils::getHex).orElse(null); Map> paramNameToValues = - getQueryParamsFromQueryString(queryString); + getQueryParamsFromQueryString(queryString, spanId); for (Map.Entry> queryParamEntry : paramNameToValues.entrySet()) { if (queryParamEntry.getValue().isEmpty()) { continue; @@ -65,7 +69,8 @@ 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 +80,15 @@ 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 +97,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; } 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; } diff --git a/hypertrace-trace-enricher/trace-reader/build.gradle.kts b/hypertrace-trace-enricher/trace-reader/build.gradle.kts index 256f0d399..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") @@ -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() 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")