use of org.hypertrace.core.datamodel.RawSpan in project hypertrace-ingester by hypertrace.
the class MigrationTestHttp method testRequestUrlTagKeysPriority.
@ParameterizedTest
@MethodSource("provideMapForTestingRequestUrlTagKeysPriority")
public void testRequestUrlTagKeysPriority(Map<String, String> tagsMap, String expectedUrl) throws Exception {
Span span = createSpanFromTags(tagsMap);
RawSpan rawSpan = normalizer.convert("tenant-key", span, buildEvent("tenant-key", span, Optional.empty()));
// now, we are not populating first class fields. So, it should be null.
assertNull(rawSpan.getEvent().getHttp());
assertEquals(expectedUrl, HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get());
}
use of org.hypertrace.core.datamodel.RawSpan in project hypertrace-ingester by hypertrace.
the class MigrationTestHttp method testHttpFields.
@Test
public void testHttpFields() throws Exception {
Map<String, String> tagsMap = new HashMap<>() {
{
put(RawSpanConstants.getValue(HTTP_REQUEST_METHOD), "GET");
put(RawSpanConstants.getValue(OT_SPAN_TAG_HTTP_METHOD), "PUT");
put(RawSpanConstants.getValue(OT_SPAN_TAG_HTTP_URL), "https://example.ai/url1");
put(RawSpanConstants.getValue(HTTP_URL), "https://example.ai/url2");
put(RawSpanConstants.getValue(HTTP_REQUEST_URL), "https://example.ai/url3");
put(RawSpanConstants.getValue(HTTP_HOST), "example.ai");
put(RawSpanConstants.getValue(HTTP_REQUEST_PATH), "/url1");
put(RawSpanConstants.getValue(HTTP_PATH), "/url2");
put(RawSpanConstants.getValue(HTTP_USER_DOT_AGENT), "Chrome 1");
put(RawSpanConstants.getValue(HTTP_USER_AGENT_WITH_UNDERSCORE), "Chrome 2");
put(RawSpanConstants.getValue(HTTP_USER_AGENT_WITH_DASH), "Chrome 3");
put(RawSpanConstants.getValue(HTTP_USER_AGENT_REQUEST_HEADER), "Chrome 4");
put(RawSpanConstants.getValue(HTTP_USER_AGENT), "Chrome 5");
put(RawSpanConstants.getValue(ENVOY_REQUEST_SIZE), "50");
put(RawSpanConstants.getValue(HTTP_REQUEST_SIZE), "40");
put(RawSpanConstants.getValue(ENVOY_RESPONSE_SIZE), "30");
put(RawSpanConstants.getValue(HTTP_RESPONSE_SIZE), "20");
put(RawSpanConstants.getValue(HTTP_REQUEST_QUERY_STRING), "a1=v1&a2=v2");
}
};
Span span = createSpanFromTags(tagsMap);
RawSpan rawSpan = normalizer.convert("tenant-key", span, buildEvent("tenant-key", span, Optional.empty()));
// now, we are not populating first class fields. So, it should be null.
assertNull(rawSpan.getEvent().getHttp());
assertAll(() -> assertEquals("GET", HttpSemanticConventionUtils.getHttpMethod(rawSpan.getEvent()).get()), () -> assertEquals("https://example.ai/url1", HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get()), () -> assertEquals("example.ai", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get()), () -> assertEquals("/url1", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()), () -> assertEquals("Chrome 1", HttpSemanticConventionUtils.getHttpUserAgent(rawSpan.getEvent()).get()), () -> assertEquals(50, HttpSemanticConventionUtils.getHttpRequestSize(rawSpan.getEvent()).get()), () -> assertEquals(30, HttpSemanticConventionUtils.getHttpResponseSize(rawSpan.getEvent()).get()), () -> assertEquals("a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get()));
}
use of org.hypertrace.core.datamodel.RawSpan in project hypertrace-ingester by hypertrace.
the class MigrationTestHttp method testHttpFieldGenerationForOtelSpan.
@Test
public void testHttpFieldGenerationForOtelSpan() throws Exception {
Map<String, String> tagsMap = new HashMap<>() {
{
put(OTelHttpSemanticConventions.HTTP_TARGET.getValue(), "/url2");
put(OTelHttpSemanticConventions.HTTP_URL.getValue(), "https://example.ai/url1");
put(OTelHttpSemanticConventions.HTTP_USER_AGENT.getValue(), "Chrome 1");
put(OTelHttpSemanticConventions.HTTP_REQUEST_SIZE.getValue(), "100");
put(OTelHttpSemanticConventions.HTTP_RESPONSE_SIZE.getValue(), "200");
put(OTelHttpSemanticConventions.HTTP_METHOD.getValue(), "GET");
put(OTelHttpSemanticConventions.HTTP_SCHEME.getValue(), "https");
}
};
Span span = createSpanFromTags(tagsMap);
RawSpan rawSpan = normalizer.convert("tenant-key", span, buildEvent("tenant-key", span, Optional.empty()));
// now, we are not populating first class fields. So, it should be null.
assertNull(rawSpan.getEvent().getHttp());
assertAll(() -> assertEquals("GET", HttpSemanticConventionUtils.getHttpMethod(rawSpan.getEvent()).get()), () -> assertEquals("https://example.ai/url1", HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get()), () -> assertEquals("/url2", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get()), () -> assertEquals("Chrome 1", HttpSemanticConventionUtils.getHttpUserAgent(rawSpan.getEvent()).get()), () -> assertEquals(100, HttpSemanticConventionUtils.getHttpRequestSize(rawSpan.getEvent()).get()), () -> assertEquals(200, HttpSemanticConventionUtils.getHttpResponseSize(rawSpan.getEvent()).get()), () -> assertEquals("https", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get()));
}
use of org.hypertrace.core.datamodel.RawSpan in project hypertrace-ingester by hypertrace.
the class MigrationTestHttp method testRequestPathTagKeysPriority.
@ParameterizedTest
@MethodSource("provideMapForTestingRequestPathTagKeysPriority")
public void testRequestPathTagKeysPriority(Map<String, String> tagsMap, String expectedPath) throws Exception {
Span span = createSpanFromTags(tagsMap);
RawSpan rawSpan = normalizer.convert("tenant-key", span, buildEvent("tenant-key", span, Optional.empty()));
// now, we are not populating first class fields. So, it should be null.
assertNull(rawSpan.getEvent().getHttp());
assertEquals(expectedPath, HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get());
}
use of org.hypertrace.core.datamodel.RawSpan in project hypertrace-ingester by hypertrace.
the class MigrationTestHttp method testInvalidRequestPath.
@Test
public void testInvalidRequestPath() throws Exception {
Span span = createSpanFromTags(Map.of(RawSpanConstants.getValue(HTTP_REQUEST_PATH), "path1", RawSpanConstants.getValue(HTTP_PATH), " "));
RawSpan rawSpan = normalizer.convert("tenant-key", span, buildEvent("tenant-key", span, Optional.empty()));
assertFalse(HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).isPresent());
span = createSpanFromTags(Map.of(RawSpanConstants.getValue(HTTP_REQUEST_PATH), "path1", RawSpanConstants.getValue(HTTP_PATH), "/"));
rawSpan = normalizer.convert("tenant-key", span, buildEvent("tenant-key", span, Optional.empty()));
assertEquals("/", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get());
}
Aggregations