use of org.hypertrace.core.datamodel.RawSpan in project hypertrace-ingester by hypertrace.
the class MigrationTestRpc method testRpcFieldsGrpcSystem.
@Test
public void testRpcFieldsGrpcSystem() throws Exception {
Map<String, String> tagMap = Map.of(OTEL_SPAN_TAG_RPC_SYSTEM.getValue(), "grpc", RPC_REQUEST_METADATA_AUTHORITY.getValue(), "testservice:45", RPC_REQUEST_METADATA_USER_AGENT.getValue(), "grpc-go/1.17.0");
Span span = createSpanFromTags(tagMap);
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().getGrpc());
assertAll(() -> assertEquals("testservice:45", RpcSemanticConventionUtils.getGrpcAuthority(rawSpan.getEvent()).get()));
}
use of org.hypertrace.core.datamodel.RawSpan in project hypertrace-ingester by hypertrace.
the class MigrationTestHttp method testPopulateOtherFieldsOTelSpan.
@Test
public void testPopulateOtherFieldsOTelSpan() throws Exception {
Span span = Span.newBuilder().build();
RawSpan rawSpan = normalizer.convert("tenant-key", span, buildEvent("tenant-key", span, Optional.empty()));
assertFalse(HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).isPresent());
assertFalse(HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).isPresent());
assertFalse(HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).isPresent());
assertFalse(HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).isPresent());
assertFalse(HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).isPresent());
span = Span.newBuilder().addTags(KeyValue.newBuilder().setKey(OTelHttpSemanticConventions.HTTP_URL.getValue()).setVStr("https://example.ai/apis/5673/events?a1=v1&a2=v2")).build();
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("example.ai", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get());
assertEquals("a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get());
assertEquals("/apis/5673/events", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get());
assertEquals("https", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get());
// Removes the trailing "/" for path
span = Span.newBuilder().addTags(KeyValue.newBuilder().setKey(OTelHttpSemanticConventions.HTTP_URL.getValue()).setVStr("https://example.ai/apis/5673/events/?a1=v1&a2=v2")).build();
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("example.ai", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get());
assertEquals("a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get());
assertEquals("/apis/5673/events", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get());
assertEquals("https", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get());
// No query
span = Span.newBuilder().addTags(KeyValue.newBuilder().setKey(OTelHttpSemanticConventions.HTTP_URL.getValue()).setVStr("https://example.ai/apis/5673/events")).build();
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("example.ai", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get());
assertEquals("/apis/5673/events", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get());
assertEquals("https", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get());
assertFalse(HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).isPresent());
// No path
span = Span.newBuilder().addTags(KeyValue.newBuilder().setKey(OTelHttpSemanticConventions.HTTP_URL.getValue()).setVStr("https://example.ai")).build();
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("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
span = Span.newBuilder().addTags(KeyValue.newBuilder().setKey(OTelHttpSemanticConventions.HTTP_URL.getValue()).setVStr("/apis/5673/events?a1=v1&a2=v2")).build();
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());
assertFalse(HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).isPresent());
assertFalse(HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).isPresent());
assertFalse(HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).isPresent());
assertEquals("/apis/5673/events", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get());
assertEquals("a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get());
// "/" home path, host with port
span = Span.newBuilder().addTags(KeyValue.newBuilder().setKey(OTelHttpSemanticConventions.HTTP_URL.getValue()).setVStr("http://example.ai:9000/?a1=v1&a2=v2")).build();
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("example.ai:9000", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get());
assertEquals("/", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get());
assertEquals("http", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get());
assertEquals("a1=v1&a2=v2", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get());
// Set path and query string before calling populateOtherFields. Simulate case where fields came
// from attributes
span = Span.newBuilder().addTags(KeyValue.newBuilder().setKey(OTelHttpSemanticConventions.HTTP_URL.getValue()).setVStr("http://example.ai:9000/apis/4533?a1=v1&a2=v2")).addTags(KeyValue.newBuilder().setKey(RawSpanConstants.getValue(HTTP_REQUEST_QUERY_STRING)).setVStr("some-query-str=v1")).addTags(KeyValue.newBuilder().setKey(OTelHttpSemanticConventions.HTTP_TARGET.getValue()).setVStr("/some-test-path")).build();
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("example.ai:9000", HttpSemanticConventionUtils.getHttpHost(rawSpan.getEvent()).get());
assertEquals("/some-test-path", HttpSemanticConventionUtils.getHttpPath(rawSpan.getEvent()).get());
assertEquals("http", HttpSemanticConventionUtils.getHttpScheme(rawSpan.getEvent()).get());
assertEquals("some-query-str=v1", HttpSemanticConventionUtils.getHttpQueryString(rawSpan.getEvent()).get());
// originally set url is a relative url, should be overridden
span = Span.newBuilder().addTags(KeyValue.newBuilder().setKey(OTelHttpSemanticConventions.HTTP_SCHEME.getValue()).setVStr("http")).addTags(KeyValue.newBuilder().setKey(OTelSpanSemanticConventions.SPAN_KIND.getValue()).setVStr("server")).addTags(KeyValue.newBuilder().setKey(OTelHttpSemanticConventions.HTTP_NET_HOST_NAME.getValue()).setVStr("example.internal.com")).addTags(KeyValue.newBuilder().setKey(OTelHttpSemanticConventions.HTTP_NET_HOST_PORT.getValue()).setVStr("50850")).addTags(KeyValue.newBuilder().setKey(OTelHttpSemanticConventions.HTTP_TARGET.getValue()).setVStr("/api/v1/gatekeeper/check?url=%2Fpixel%2Factivities%3Fadvertisable%3DTRHRT&method=GET&service=pixel")).build();
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(HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).get(), "http://example.internal.com:50850/api/v1/gatekeeper/check?url=%2Fpixel%2Factivities%3Fadvertisable%3DTRHRT&method=GET&service=pixel");
}
use of org.hypertrace.core.datamodel.RawSpan in project hypertrace-ingester by hypertrace.
the class MigrationTestHttp method testRequestSizeTagKeysPriority.
@ParameterizedTest
@MethodSource("provideMapForTestingRequestSizeTagKeysPriority")
public void testRequestSizeTagKeysPriority(Map<String, String> tagsMap, int requestSize) 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(requestSize, HttpSemanticConventionUtils.getHttpRequestSize(rawSpan.getEvent()).get());
}
use of org.hypertrace.core.datamodel.RawSpan in project hypertrace-ingester by hypertrace.
the class MigrationTestHttp method testResponseSizeTagKeysPriority.
@ParameterizedTest
@MethodSource("provideMapForTestingResponseSizeTagKeysPriority")
public void testResponseSizeTagKeysPriority(Map<String, String> tagsMap, int responseSize) 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(responseSize, HttpSemanticConventionUtils.getHttpResponseSize(rawSpan.getEvent()).get());
}
use of org.hypertrace.core.datamodel.RawSpan in project hypertrace-ingester by hypertrace.
the class MigrationTestHttp method testRelativeUrlNotSetsUrlField.
@Test
public void testRelativeUrlNotSetsUrlField() throws Exception {
Span span = createSpanFromTags(Map.of(RawSpanConstants.getValue(HTTP_URL), "/dispatch/test?a=b&k1=v1"));
RawSpan rawSpan = normalizer.convert("tenant-key", span, buildEvent("tenant-key", span, Optional.empty()));
assertFalse(HttpSemanticConventionUtils.getHttpUrl(rawSpan.getEvent()).isPresent());
}
Aggregations