diff --git a/hypertrace-ingester/src/test/java/org/hypertrace/migration/MigrationTestHttp.java b/hypertrace-ingester/src/test/java/org/hypertrace/migration/MigrationTestHttp.java index 7b78b5ee3..dfd26e6ab 100644 --- a/hypertrace-ingester/src/test/java/org/hypertrace/migration/MigrationTestHttp.java +++ b/hypertrace-ingester/src/test/java/org/hypertrace/migration/MigrationTestHttp.java @@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import com.typesafe.config.ConfigFactory; @@ -43,6 +44,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; public class MigrationTestHttp { @@ -96,87 +98,94 @@ public void testHttpFields() throws Exception { Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + assertAll( () -> assertEquals( - rawSpan.getEvent().getHttp().getRequest().getMethod(), - HttpSemanticConventionUtils.getHttpMethod(rawSpan.getEvent()).get()), + "GET", HttpSemanticConventionUtils.getHttpMethod(rawSpan.getEvent()).get()), () -> assertEquals( - rawSpan.getEvent().getHttp().getRequest().getUrl(), + "https://example.ai/url1", HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get()), () -> assertEquals( - rawSpan.getEvent().getHttp().getRequest().getHost(), - HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()), + "example.ai", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()), () -> assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()), + "/url1", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()), () -> assertEquals( - rawSpan.getEvent().getHttp().getRequest().getUserAgent(), - HttpSemanticConventionUtils.getHttpUserAgent(rawSpan.getEvent()).get()), + "Chrome 1", HttpSemanticConventionUtils.getHttpUserAgent(rawSpan.getEvent()).get()), () -> assertEquals( - rawSpan.getEvent().getHttp().getRequest().getSize(), - HttpSemanticConventionUtils.getHttpRequestSize(rawSpan.getEvent()).get()), + 50, HttpSemanticConventionUtils.getHttpRequestSize(rawSpan.getEvent()).get()), () -> assertEquals( - rawSpan.getEvent().getHttp().getResponse().getSize(), - HttpSemanticConventionUtils.getHttpResponseSize(rawSpan.getEvent()).get()), + 30, HttpSemanticConventionUtils.getHttpResponseSize(rawSpan.getEvent()).get()), () -> assertEquals( - rawSpan.getEvent().getHttp().getRequest().getQueryString(), + "a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get())); } @ParameterizedTest @MethodSource("provideMapForTestingRequestMethodPriority") - public void testRequestMethodPriority(Map tagsMap) throws Exception { + public void testRequestMethodPriority(Map tagsMap, String expectedMethod) + throws Exception { Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + assertEquals( - rawSpan.getEvent().getHttp().getRequest().getMethod(), - HttpSemanticConventionUtils.getHttpMethod(rawSpan.getEvent()).get()); + expectedMethod, HttpSemanticConventionUtils.getHttpMethod(rawSpan.getEvent()).get()); } @ParameterizedTest @MethodSource("provideMapForTestingRequestUrlTagKeysPriority") - public void testRequestUrlTagKeysPriority(Map tagsMap) throws Exception { + public void testRequestUrlTagKeysPriority(Map tagsMap, String expectedUrl) + throws Exception { Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getUrl(), - HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get()); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + + assertEquals(expectedUrl, HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get()); } @ParameterizedTest @MethodSource("provideMapForTestingRequestPathTagKeysPriority") - public void testRequestPathTagKeysPriority(Map tagsMap) throws Exception { + public void testRequestPathTagKeysPriority(Map tagsMap, String expectedPath) + throws Exception { Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + + assertEquals(expectedPath, HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); } @ParameterizedTest @MethodSource("provideMapForTestingResponseStatusCodePriority") - public void testResponseStatusCodePriority(Map tagsMap) throws Exception { + public void testResponseStatusCodePriority(Map tagsMap, int statusCode) + throws Exception { Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + assertEquals( - rawSpan.getEvent().getHttp().getResponse().getStatusCode(), - HttpSemanticConventionUtils.getHttpResponseStatusCode(rawSpan.getEvent())); + statusCode, HttpSemanticConventionUtils.getHttpResponseStatusCode(rawSpan.getEvent())); } @Test @@ -199,45 +208,50 @@ public void testInvalidRequestPath() throws Exception { rawSpan = normalizer.convert("tenant-key", span); assertEquals("/", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); } @ParameterizedTest @MethodSource("provideMapForTestingRequestUserAgentTagKeysPriority") - public void testRequestUserAgentTagKeysPriority(Map tagsMap) throws Exception { + public void testRequestUserAgentTagKeysPriority(Map tagsMap, String userAgent) + throws Exception { Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getUserAgent(), - HttpSemanticConventionUtils.getHttpUserAgent(rawSpan.getEvent()).get()); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + + assertEquals(userAgent, HttpSemanticConventionUtils.getHttpUserAgent(rawSpan.getEvent()).get()); } @ParameterizedTest @MethodSource("provideMapForTestingRequestSizeTagKeysPriority") - public void testRequestSizeTagKeysPriority(Map tagsMap) throws Exception { + public void testRequestSizeTagKeysPriority(Map tagsMap, int requestSize) + throws Exception { Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + assertEquals( - rawSpan.getEvent().getHttp().getRequest().getSize(), - HttpSemanticConventionUtils.getHttpRequestSize(rawSpan.getEvent()).get()); + requestSize, HttpSemanticConventionUtils.getHttpRequestSize(rawSpan.getEvent()).get()); } @ParameterizedTest @MethodSource("provideMapForTestingResponseSizeTagKeysPriority") - public void testResponseSizeTagKeysPriority(Map tagsMap) throws Exception { + public void testResponseSizeTagKeysPriority(Map tagsMap, int responseSize) + throws Exception { Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + assertEquals( - rawSpan.getEvent().getHttp().getResponse().getSize(), - HttpSemanticConventionUtils.getHttpResponseSize(rawSpan.getEvent()).get()); + responseSize, HttpSemanticConventionUtils.getHttpResponseSize(rawSpan.getEvent()).get()); } @Test @@ -257,12 +271,15 @@ public void testAbsoluteUrlNotSetsUrlField() throws Exception { Map.of(RawSpanConstants.getValue(HTTP_URL), "http://abc.xyz/dispatch/test?a=b&k1=v1")); RawSpan rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + assertAll( + () -> assertTrue(HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).isPresent()), () -> assertEquals( - rawSpan.getEvent().getHttp().getRequest().getUrl(), - HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get()), - () -> assertTrue(HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).isPresent())); + "http://abc.xyz/dispatch/test?a=b&k1=v1", + HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get())); } @Test @@ -277,18 +294,15 @@ public void testInvalidUrlRejectedByUrlValidator() throws Exception { RawSpan rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + + assertEquals("https", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); + assertEquals("example.ai", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getScheme(), - HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getHost(), - HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + "/apis/5673/events", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getQueryString(), - HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); + "a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); // Removes the trailing "/" for path span = @@ -301,18 +315,15 @@ public void testInvalidUrlRejectedByUrlValidator() throws Exception { rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + + assertEquals("https", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); + assertEquals("example.ai", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getScheme(), - HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getHost(), - HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + "/apis/5673/events", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getQueryString(), - HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); + "a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); // No query span = @@ -325,15 +336,13 @@ public void testInvalidUrlRejectedByUrlValidator() throws Exception { rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + + assertEquals("https", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); + assertEquals("example.ai", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getScheme(), - HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getHost(), - HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + "/apis/5673/events", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); assertFalse(HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).isPresent()); // No path @@ -347,15 +356,12 @@ public void testInvalidUrlRejectedByUrlValidator() throws Exception { rawSpan = normalizer.convert("tenant-key", span); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getScheme(), - HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getHost(), - HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + + assertEquals("https", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); + assertEquals("example.ai", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); + assertEquals("/", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); assertFalse(HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).isPresent()); // Relative URL - should extract path and query string only @@ -369,15 +375,16 @@ public void testInvalidUrlRejectedByUrlValidator() throws Exception { rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + assertFalse(HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).isPresent()); assertFalse(HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).isPresent()); assertFalse(HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).isPresent()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getQueryString(), - HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); + "a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + "/apis/5673/events", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); // "/" home path, host with port span = @@ -390,18 +397,15 @@ public void testInvalidUrlRejectedByUrlValidator() throws Exception { rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + + assertEquals("http", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getScheme(), - HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getHost(), - HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + "example.ai:9000", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); + assertEquals("/", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getQueryString(), - HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); + "a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); // Set path and query string before calling populateOtherFields. Simulate case where fields came // from attributes @@ -423,17 +427,16 @@ public void testInvalidUrlRejectedByUrlValidator() throws Exception { rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + + assertEquals("http", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getScheme(), - HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getHost(), - HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); + "example.ai:9000", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + "/some-test-path", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getQueryString(), + "some-query-str=v1", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); } @@ -456,35 +459,32 @@ public void testHttpFieldGenerationForOtelSpan() throws Exception { Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + assertAll( () -> assertEquals( - rawSpan.getEvent().getHttp().getRequest().getMethod(), - HttpSemanticConventionUtils.getHttpMethod(rawSpan.getEvent()).get()), + "GET", HttpSemanticConventionUtils.getHttpMethod(rawSpan.getEvent()).get()), () -> assertEquals( - rawSpan.getEvent().getHttp().getRequest().getUrl(), + "https://example.ai/url1", HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get()), () -> assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()), + "/url2", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()), () -> assertEquals( - rawSpan.getEvent().getHttp().getRequest().getUserAgent(), - HttpSemanticConventionUtils.getHttpUserAgent(rawSpan.getEvent()).get()), + "Chrome 1", HttpSemanticConventionUtils.getHttpUserAgent(rawSpan.getEvent()).get()), () -> assertEquals( - rawSpan.getEvent().getHttp().getRequest().getSize(), - HttpSemanticConventionUtils.getHttpRequestSize(rawSpan.getEvent()).get()), + 100, HttpSemanticConventionUtils.getHttpRequestSize(rawSpan.getEvent()).get()), () -> assertEquals( - rawSpan.getEvent().getHttp().getResponse().getSize(), - HttpSemanticConventionUtils.getHttpResponseSize(rawSpan.getEvent()).get()), + 200, HttpSemanticConventionUtils.getHttpResponseSize(rawSpan.getEvent()).get()), () -> assertEquals( - rawSpan.getEvent().getHttp().getRequest().getScheme(), - HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get())); + "https", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get())); } @Test @@ -508,18 +508,15 @@ public void testPopulateOtherFieldsOTelSpan() throws Exception { rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + + assertEquals("example.ai", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getHost(), - HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getQueryString(), - HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); + "a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getScheme(), - HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); + "/apis/5673/events", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + assertEquals("https", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); // Removes the trailing "/" for path span = @@ -531,19 +528,15 @@ public void testPopulateOtherFieldsOTelSpan() throws Exception { .build(); rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + assertEquals("example.ai", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getHost(), - HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getQueryString(), - HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + "a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getScheme(), - HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); + "/apis/5673/events", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + assertEquals("https", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); // No query span = @@ -556,15 +549,13 @@ public void testPopulateOtherFieldsOTelSpan() throws Exception { rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); + + assertEquals("example.ai", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getHost(), - HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getScheme(), - HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); + "/apis/5673/events", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + assertEquals("https", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); assertFalse(HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).isPresent()); // No path @@ -577,16 +568,12 @@ public void testPopulateOtherFieldsOTelSpan() throws Exception { .build(); rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getHost(), - HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getScheme(), - HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); + assertEquals("example.ai", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); + assertEquals("/", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + assertEquals("https", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); assertFalse(HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).isPresent()); // Relative URL - should extract path and query string only @@ -599,16 +586,16 @@ public void testPopulateOtherFieldsOTelSpan() throws Exception { .build(); rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); assertFalse(HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).isPresent()); assertFalse(HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).isPresent()); assertFalse(HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).isPresent()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + "/apis/5673/events", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getQueryString(), - HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); + "a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); // "/" home path, host with port span = @@ -620,19 +607,15 @@ public void testPopulateOtherFieldsOTelSpan() throws Exception { .build(); rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getHost(), - HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getScheme(), - HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); + "example.ai:9000", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); + assertEquals("/", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + assertEquals("http", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getQueryString(), - HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); + "a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); // Set path and query string before calling populateOtherFields. Simulate case where fields came // from attributes @@ -653,18 +636,15 @@ public void testPopulateOtherFieldsOTelSpan() throws Exception { .build(); rawSpan = normalizer.convert("tenant-key", span); - + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getHost(), - HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + "example.ai:9000", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getScheme(), - HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); + "/some-test-path", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); + assertEquals("http", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getQueryString(), + "some-query-str=v1", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()); // originally set url is a relative url, should be overridden @@ -694,14 +674,11 @@ public void testPopulateOtherFieldsOTelSpan() throws Exception { .build(); rawSpan = normalizer.convert("tenant-key", span); - + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); assertEquals( - rawSpan.getEvent().getHttp().getRequest().getUrl(), + HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get(), "http://example.internal.com:50850/api/v1/gatekeeper/check?url=%2Fpixel%2Factivities%3Fadvertisable%3DTRHRT&method=GET&service=pixel"); - - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getUrl(), - HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get()); } @Test @@ -713,19 +690,15 @@ public void testSetPath() throws Exception { OTelHttpSemanticConventions.HTTP_TARGET.getValue(), "/api/v1/gatekeeper/check?url=%2Fpixel%2Factivities%3Fadvertisable%3DTRHRT&method=GET&service=pixel")); RawSpan rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getHttp()); - assertAll( - () -> - assertEquals( - rawSpan.getEvent().getHttp().getRequest().getPath(), - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()), - () -> - assertEquals( - "/api/v1/gatekeeper/check", - HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get())); + assertEquals( + "/api/v1/gatekeeper/check", + HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()); } - private static Stream> provideMapForTestingRequestMethodPriority() { + private static Stream provideMapForTestingRequestMethodPriority() { Map tagsMap1 = Map.of( @@ -735,10 +708,10 @@ private static Stream> provideMapForTestingRequestMethodPrio Map tagsMap2 = Map.of(RawSpanConstants.getValue(OT_SPAN_TAG_HTTP_METHOD), "POST"); - return Stream.of(tagsMap1, tagsMap2); + return Stream.of(Arguments.arguments(tagsMap1, "GET"), Arguments.arguments(tagsMap2, "POST")); } - private static Stream> provideMapForTestingRequestUrlTagKeysPriority() { + private static Stream provideMapForTestingRequestUrlTagKeysPriority() { Map tagsMap1 = Map.of( @@ -754,10 +727,13 @@ private static Stream> provideMapForTestingRequestUrlTagKeys Map tagsMap3 = Map.of(RawSpanConstants.getValue(HTTP_URL), "https://example.ai/url2"); - return Stream.of(tagsMap1, tagsMap2, tagsMap3); + return Stream.of( + Arguments.arguments(tagsMap1, "https://example.ai/url1"), + Arguments.arguments(tagsMap2, "https://example.ai/url3"), + Arguments.arguments(tagsMap3, "https://example.ai/url2")); } - private static Stream> provideMapForTestingRequestPathTagKeysPriority() { + private static Stream provideMapForTestingRequestPathTagKeysPriority() { Map tagsMap1 = Map.of( @@ -766,10 +742,11 @@ private static Stream> provideMapForTestingRequestPathTagKey Map tagsMap2 = Map.of(RawSpanConstants.getValue(HTTP_PATH), "/path2"); - return Stream.of(tagsMap1, tagsMap2); + return Stream.of( + Arguments.arguments(tagsMap1, "/path1"), Arguments.arguments(tagsMap2, "/path2")); } - private static Stream> provideMapForTestingRequestUserAgentTagKeysPriority() { + private static Stream provideMapForTestingRequestUserAgentTagKeysPriority() { Map tagsMap1 = Map.of( @@ -799,10 +776,15 @@ private static Stream> provideMapForTestingRequestUserAgentT Map tagsMap5 = Map.of(RawSpanConstants.getValue(HTTP_USER_AGENT), "Chrome 5"); - return Stream.of(tagsMap1, tagsMap2, tagsMap3, tagsMap4, tagsMap5); + return Stream.of( + Arguments.arguments(tagsMap1, "Chrome 1"), + Arguments.arguments(tagsMap2, "Chrome 2"), + Arguments.arguments(tagsMap3, "Chrome 3"), + Arguments.arguments(tagsMap4, "Chrome 4"), + Arguments.arguments(tagsMap5, "Chrome 5")); } - private static Stream> provideMapForTestingRequestSizeTagKeysPriority() { + private static Stream provideMapForTestingRequestSizeTagKeysPriority() { Map tagsMap1 = Map.of( @@ -811,10 +793,10 @@ private static Stream> provideMapForTestingRequestSizeTagKey Map tagsMap2 = Map.of(RawSpanConstants.getValue(HTTP_REQUEST_SIZE), "35"); - return Stream.of(tagsMap1, tagsMap2); + return Stream.of(Arguments.arguments(tagsMap1, 50), Arguments.arguments(tagsMap2, 35)); } - private static Stream> provideMapForTestingResponseSizeTagKeysPriority() { + private static Stream provideMapForTestingResponseSizeTagKeysPriority() { Map tagsMap1 = Map.of( @@ -823,10 +805,10 @@ private static Stream> provideMapForTestingResponseSizeTagKe Map tagsMap2 = Map.of(RawSpanConstants.getValue(HTTP_RESPONSE_SIZE), "85"); - return Stream.of(tagsMap1, tagsMap2); + return Stream.of(Arguments.arguments(tagsMap1, 100), Arguments.arguments(tagsMap2, 85)); } - private static Stream> provideMapForTestingResponseStatusCodePriority() { + private static Stream provideMapForTestingResponseStatusCodePriority() { Map tagsMap1 = Map.of( @@ -836,7 +818,7 @@ private static Stream> provideMapForTestingResponseStatusCod Map tagsMap2 = Map.of(RawSpanConstants.getValue(HTTP_RESPONSE_STATUS_CODE), "201"); - return Stream.of(tagsMap1, tagsMap2); + return Stream.of(Arguments.arguments(tagsMap1, 200), Arguments.arguments(tagsMap2, 201)); } static Span createSpanFromTags(Map tagsMap) { diff --git a/hypertrace-ingester/src/test/java/org/hypertrace/migration/MigrationTestRpc.java b/hypertrace-ingester/src/test/java/org/hypertrace/migration/MigrationTestRpc.java index fe3f29b8b..5e176d3c5 100644 --- a/hypertrace-ingester/src/test/java/org/hypertrace/migration/MigrationTestRpc.java +++ b/hypertrace-ingester/src/test/java/org/hypertrace/migration/MigrationTestRpc.java @@ -64,46 +64,50 @@ public void setup() @Test public void testGrpcFields() throws Exception { + String grpcRequestBodyValue = "some grpc request body"; + String grpcResponseBodyValue = "some grpc response body"; + String grpcErrorMessageValue = "some error message"; + String censusResponseStatusMessageValue = "CENSUS_RESPONSE_STATUS_MESSAGE"; + String envoyGrpcStatusMessage = "ENVOY_GRPC_STATUS_MESSAGE"; + Map tagsMap = new HashMap<>() { { - put(RawSpanConstants.getValue(GRPC_ERROR_MESSAGE), "Some error message"); + put(RawSpanConstants.getValue(GRPC_ERROR_MESSAGE), grpcErrorMessageValue); put(RawSpanConstants.getValue(CENSUS_RESPONSE_STATUS_CODE), "12"); put(RawSpanConstants.getValue(GRPC_STATUS_CODE), "13"); put(RawSpanConstants.getValue(CENSUS_RESPONSE_CENSUS_STATUS_CODE), "14"); put( RawSpanConstants.getValue(CENSUS_RESPONSE_STATUS_MESSAGE), - "CENSUS_RESPONSE_STATUS_MESSAGE"); - put(RawSpanConstants.getValue(ENVOY_GRPC_STATUS_MESSAGE), "ENVOY_GRPC_STATUS_MESSAGE"); - put(RawSpanConstants.getValue(GRPC_REQUEST_BODY), "some grpc request body"); - put(RawSpanConstants.getValue(GRPC_RESPONSE_BODY), "some grpc response body"); + censusResponseStatusMessageValue); + put(RawSpanConstants.getValue(ENVOY_GRPC_STATUS_MESSAGE), envoyGrpcStatusMessage); + put(RawSpanConstants.getValue(GRPC_REQUEST_BODY), grpcRequestBodyValue); + put(RawSpanConstants.getValue(GRPC_RESPONSE_BODY), grpcResponseBodyValue); } }; Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); - assertAll( - () -> - assertEquals( - rawSpan.getEvent().getGrpc().getResponse().getErrorMessage(), - RpcSemanticConventionUtils.getGrpcErrorMsg(rawSpan.getEvent())), - () -> - assertEquals( - rawSpan.getEvent().getGrpc().getResponse().getStatusCode(), - RpcSemanticConventionUtils.getGrpcStatusCode(rawSpan.getEvent())), - () -> - assertEquals( - rawSpan.getEvent().getGrpc().getResponse().getStatusMessage(), - RpcSemanticConventionUtils.getGrpcStatusMsg(rawSpan.getEvent())), - () -> - assertEquals( - rawSpan.getEvent().getGrpc().getResponse().getSize(), - RpcSemanticConventionUtils.getGrpcResponseSize(rawSpan.getEvent()).get()), - () -> - assertEquals( - rawSpan.getEvent().getGrpc().getRequest().getSize(), - RpcSemanticConventionUtils.getGrpcRequestSize(rawSpan.getEvent()).get())); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getGrpc()); + + assertEquals( + grpcErrorMessageValue, RpcSemanticConventionUtils.getGrpcErrorMsg(rawSpan.getEvent())); + + assertEquals(12, RpcSemanticConventionUtils.getGrpcStatusCode(rawSpan.getEvent())); + + assertEquals( + censusResponseStatusMessageValue, + RpcSemanticConventionUtils.getGrpcStatusMsg(rawSpan.getEvent())); + + assertEquals( + grpcResponseBodyValue.length(), + RpcSemanticConventionUtils.getGrpcResponseSize(rawSpan.getEvent()).get()); + + assertEquals( + grpcRequestBodyValue.length(), + RpcSemanticConventionUtils.getGrpcRequestSize(rawSpan.getEvent()).get()); } @Test @@ -119,15 +123,12 @@ public void testGrpcFieldsConverterEnvoyRequestAndResponseSizeHigherPriority() t Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); - assertAll( - () -> - assertEquals( - rawSpan.getEvent().getGrpc().getResponse().getSize(), - RpcSemanticConventionUtils.getGrpcResponseSize(rawSpan.getEvent()).get()), - () -> - assertEquals( - rawSpan.getEvent().getGrpc().getRequest().getSize(), - RpcSemanticConventionUtils.getGrpcRequestSize(rawSpan.getEvent()).get())); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getGrpc()); + + assertEquals(400, RpcSemanticConventionUtils.getGrpcResponseSize(rawSpan.getEvent()).get()); + + assertEquals(200, RpcSemanticConventionUtils.getGrpcRequestSize(rawSpan.getEvent()).get()); } @ParameterizedTest @@ -138,18 +139,20 @@ public void testGrpcFieldsConverterStatusCodePriority(Map tagsMa Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getGrpc()); + assertAll( () -> assertEquals( - rawSpan.getEvent().getGrpc().getResponse().getStatusCode(), - RpcSemanticConventionUtils.getGrpcStatusCode(rawSpan.getEvent())), - () -> assertEquals(statusCode, rawSpan.getEvent().getGrpc().getResponse().getStatusCode())); + statusCode, RpcSemanticConventionUtils.getGrpcStatusCode(rawSpan.getEvent()))); } @Test public void testGetGrpcUserAgent() throws Exception { + String rpcRequestMetadataUserAgentValue = "rpc user agent"; Map tagsMap = - Map.of(RPC_REQUEST_METADATA_USER_AGENT.getValue(), "rpc user agent"); + Map.of(RPC_REQUEST_METADATA_USER_AGENT.getValue(), rpcRequestMetadataUserAgentValue); Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); @@ -160,22 +163,24 @@ public void testGetGrpcUserAgent() throws Exception { tagsMap = Map.of( RPC_REQUEST_METADATA_USER_AGENT.getValue(), - "rpc user agent", + rpcRequestMetadataUserAgentValue, OTEL_SPAN_TAG_RPC_SYSTEM.getValue(), OTEL_RPC_SYSTEM_GRPC.getValue()); span = createSpanFromTags(tagsMap); rawSpan = normalizer.convert("tenant-key", span); - + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getGrpc()); assertEquals( - rawSpan.getEvent().getGrpc().getRequest().getRequestMetadata().getUserAgent(), + rpcRequestMetadataUserAgentValue, RpcSemanticConventionUtils.getGrpcUserAgent(rawSpan.getEvent()).get()); } @Test public void testGetGrpcAuthority() throws Exception { + String rpcRequestMetadataAuthorityValue = "grpc authority"; Map tagsMap = - Map.of(RPC_REQUEST_METADATA_AUTHORITY.getValue(), "grpc authority"); + Map.of(RPC_REQUEST_METADATA_AUTHORITY.getValue(), rpcRequestMetadataAuthorityValue); Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); @@ -186,15 +191,17 @@ public void testGetGrpcAuthority() throws Exception { tagsMap = Map.of( RPC_REQUEST_METADATA_AUTHORITY.getValue(), - "grpc authority", + rpcRequestMetadataAuthorityValue, OTEL_SPAN_TAG_RPC_SYSTEM.getValue(), OTEL_RPC_SYSTEM_GRPC.getValue()); span = createSpanFromTags(tagsMap); rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getGrpc()); assertEquals( - rawSpan.getEvent().getGrpc().getRequest().getRequestMetadata().getAuthority(), + rpcRequestMetadataAuthorityValue, RpcSemanticConventionUtils.getGrpcAuthority(rawSpan.getEvent()).get()); } @@ -229,14 +236,9 @@ public void testGrpcFieldsConverterStatusMessagePriority( Span span = createSpanFromTags(tagsMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); - assertAll( - () -> - assertEquals( - rawSpan.getEvent().getGrpc().getResponse().getStatusMessage(), - RpcSemanticConventionUtils.getGrpcStatusMsg(rawSpan.getEvent())), - () -> - assertEquals( - statusMessage, rawSpan.getEvent().getGrpc().getResponse().getStatusMessage())); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getGrpc()); + assertEquals(statusMessage, RpcSemanticConventionUtils.getGrpcStatusMsg(rawSpan.getEvent())); } private static Stream @@ -271,8 +273,7 @@ public void testPopulateOtherFields() throws Exception { RawSpan rawSpan = normalizer.convert("tenant-key", span); assertEquals( - rawSpan.getEvent().getGrpc().getResponse().getErrorMessage(), - RpcSemanticConventionUtils.getGrpcErrorMsg(rawSpan.getEvent())); + "resource not found", RpcSemanticConventionUtils.getGrpcErrorMsg(rawSpan.getEvent())); } @Test @@ -284,9 +285,10 @@ public void testGrpcFieldsForOTelSpan() throws Exception { Span span = createSpanFromTags(tagMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); - assertEquals( - rawSpan.getEvent().getGrpc().getResponse().getStatusCode(), - RpcSemanticConventionUtils.getGrpcStatusCode(rawSpan.getEvent())); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getGrpc()); + + assertEquals(5, RpcSemanticConventionUtils.getGrpcStatusCode(rawSpan.getEvent())); } @Test @@ -301,15 +303,14 @@ public void testRpcFieldsGrpcSystem() throws Exception { Span span = createSpanFromTags(tagMap); RawSpan rawSpan = normalizer.convert("tenant-key", span); + // now, we are not populating first class fields. So, it should be null. + assertNull(rawSpan.getEvent().getGrpc()); + assertAll( () -> assertEquals( - rawSpan.getEvent().getGrpc().getRequest().getRequestMetadata().getAuthority(), - RpcSemanticConventionUtils.getGrpcAuthority(rawSpan.getEvent()).get()), - () -> - assertEquals( - rawSpan.getEvent().getGrpc().getRequest().getRequestMetadata().getUserAgent(), - RpcSemanticConventionUtils.getGrpcUserAgent(rawSpan.getEvent()).get())); + "testservice:45", + RpcSemanticConventionUtils.getGrpcAuthority(rawSpan.getEvent()).get())); } @Test diff --git a/span-normalizer/span-normalizer/src/main/java/org/hypertrace/core/spannormalizer/jaeger/JaegerSpanNormalizer.java b/span-normalizer/span-normalizer/src/main/java/org/hypertrace/core/spannormalizer/jaeger/JaegerSpanNormalizer.java index 163c30f38..a0c13a65f 100644 --- a/span-normalizer/span-normalizer/src/main/java/org/hypertrace/core/spannormalizer/jaeger/JaegerSpanNormalizer.java +++ b/span-normalizer/span-normalizer/src/main/java/org/hypertrace/core/spannormalizer/jaeger/JaegerSpanNormalizer.java @@ -43,7 +43,6 @@ import org.hypertrace.core.serviceframework.metrics.PlatformMetricsRegistry; import org.hypertrace.core.span.constants.RawSpanConstants; import org.hypertrace.core.span.constants.v1.JaegerAttribute; -import org.hypertrace.core.spannormalizer.fieldgenerators.FieldsGenerator; import org.hypertrace.core.spannormalizer.util.JaegerHTTagsConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,7 +56,6 @@ public class JaegerSpanNormalizer { private static final String SPAN_NORMALIZATION_TIME_METRIC = "span.normalization.time"; private static JaegerSpanNormalizer INSTANCE; - private final FieldsGenerator fieldsGenerator; private final ConcurrentMap tenantToSpanNormalizationTimer = new ConcurrentHashMap<>(); private final JaegerResourceNormalizer resourceNormalizer = new JaegerResourceNormalizer(); @@ -75,7 +73,6 @@ public static JaegerSpanNormalizer get(Config config) { } public JaegerSpanNormalizer(Config config) { - this.fieldsGenerator = new FieldsGenerator(); this.tenantIdHandler = new TenantIdHandler(config); } @@ -168,10 +165,10 @@ private Event buildEvent( eventBuilder.setAttributesBuilder(Attributes.newBuilder().setAttributeMap(attributeFieldMap)); List tagsList = jaegerSpan.getTagsList(); - // Add the attributes to the eventBuilder and generate fields from the attributes - // 1. Adding all the attributes to the eventBuilder is still being done to maintain backwards - // compatibility. This - // will stop once all consumers of event start using the fields. + // Stop populating first class fields for - grpc, rpc, http, and sql. + // see more details: + // https://github.com/hypertrace/hypertrace/issues/244 + // https://github.com/hypertrace/hypertrace/issues/245 for (KeyValue keyValue : tagsList) { // Convert all attributes to lower case so that we don't have to // deal with the case sensitivity across different layers in the @@ -182,15 +179,8 @@ private Event buildEvent( continue; } attributeFieldMap.put(key, JaegerHTTagsConverter.createFromJaegerKeyValue(keyValue)); - // Generate a field from the keyValue - this.fieldsGenerator.addValueToBuilder(key, keyValue, eventBuilder, tagsMap); } - // Generate other fields if possible from the existing ones. eg. http scheme and query string - // from url - // note: attribute field map should be populated with attribute keys prior to this call - this.fieldsGenerator.populateOtherFields(eventBuilder, attributeFieldMap); - // Jaeger Fields - flags, warnings, logs, jaeger service name in the Process JaegerFields.Builder jaegerFieldsBuilder = eventBuilder.getJaegerFieldsBuilder(); // FLAGS