Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hypertrace-ingester/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
implementation("org.hypertrace.core.kafkastreams.framework:kafka-streams-framework:0.1.21")
implementation("org.hypertrace.core.serviceframework:platform-service-framework:0.1.26")
implementation("org.hypertrace.core.serviceframework:platform-metrics:0.1.26")
implementation("org.hypertrace.core.datamodel:data-model:0.1.19")
implementation("org.hypertrace.core.datamodel:data-model:0.1.20")
implementation("org.hypertrace.core.viewgenerator:view-generator-framework:0.3.1")
implementation("com.typesafe:config:1.4.1")
implementation("org.apache.commons:commons-lang3:3.12.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ sourceSets {
dependencies {
api("com.google.protobuf:protobuf-java-util:3.15.7")

implementation("org.hypertrace.core.datamodel:data-model:0.1.19")
implementation("org.hypertrace.core.datamodel:data-model:0.1.20")
implementation(project(":span-normalizer:raw-span-constants"))
implementation(project(":span-normalizer:span-normalizer-constants"))
implementation(project(":semantic-convention-utils"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.hypertrace.traceenricher.enrichedspan.constants.utils;

import static java.util.Collections.emptyList;
import static org.hypertrace.core.datamodel.shared.AvroBuilderCache.fastNewBuilder;
import static org.hypertrace.core.span.constants.v1.Grpc.GRPC_REQUEST_BODY;
import static org.hypertrace.core.span.constants.v1.Grpc.GRPC_RESPONSE_BODY;
import static org.hypertrace.core.span.constants.v1.Http.HTTP_METHOD;
Expand Down Expand Up @@ -147,7 +148,7 @@ public void testGetStringAttributeIgnoreKeyCase() {

when(e1.getAttributes())
.thenReturn(
Attributes.newBuilder()
fastNewBuilder(Attributes.Builder.class)
.setAttributeMap(Map.of("K2", AttributeValue.newBuilder().setValue("v2").build()))
.build());
// Should be case insensitive
Expand All @@ -157,7 +158,7 @@ public void testGetStringAttributeIgnoreKeyCase() {

when(e1.getEnrichedAttributes())
.thenReturn(
Attributes.newBuilder()
fastNewBuilder(Attributes.Builder.class)
.setAttributeMap(Map.of("k3", AttributeValue.newBuilder().setValue("v3").build()))
.build());
// Should be case insensitive
Expand Down Expand Up @@ -185,7 +186,8 @@ public void should_getHttpMethod() {
public void should_getNullMethod_noHttpFields() {
Event e = mock(Event.class);
when(e.getAttributes())
.thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
.thenReturn(
fastNewBuilder(Attributes.Builder.class).setAttributeMap(new HashMap<>()).build());

Optional<String> method = EnrichedSpanUtils.getHttpMethod(e);
assertTrue(method.isEmpty());
Expand All @@ -204,7 +206,8 @@ public void should_getFullUrl() {
public void should_getNullUrl_noHttpFields() {
Event e = mock(Event.class);
when(e.getAttributes())
.thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
.thenReturn(
fastNewBuilder(Attributes.Builder.class).setAttributeMap(new HashMap<>()).build());

Optional<String> url = EnrichedSpanUtils.getFullHttpUrl(e);
assertTrue(url.isEmpty());
Expand All @@ -214,7 +217,8 @@ public void should_getNullUrl_noHttpFields() {
public void getRequestSize_httpProtocol() {
Event e = createMockEventWithEnrichedAttribute("PROTOCOL", "HTTP");
when(e.getAttributes())
.thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
.thenReturn(
fastNewBuilder(Attributes.Builder.class).setAttributeMap(new HashMap<>()).build());
addAttribute(e, RawSpanConstants.getValue(HTTP_REQUEST_SIZE), "64");

Optional<Integer> requestSize = EnrichedSpanUtils.getRequestSize(e);
Expand All @@ -226,7 +230,8 @@ public void getRequestSize_httpProtocol() {
public void getRequestSize_grpcProtocol() {
Event e = createMockEventWithEnrichedAttribute("PROTOCOL", "GRPC");
when(e.getAttributes())
.thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
.thenReturn(
fastNewBuilder(Attributes.Builder.class).setAttributeMap(new HashMap<>()).build());
addAttribute(e, RawSpanConstants.getValue(GRPC_REQUEST_BODY), "some grpc response body");

Optional<Integer> requestSize = EnrichedSpanUtils.getRequestSize(e);
Expand All @@ -246,7 +251,8 @@ public void getRequestSize_emptyProtocol() {
public void getRequestSize_httpProtocol_noSize() {
Event e = createMockEventWithEnrichedAttribute("PROTOCOL", "HTTP");
when(e.getAttributes())
.thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
.thenReturn(
fastNewBuilder(Attributes.Builder.class).setAttributeMap(new HashMap<>()).build());

Optional<Integer> requestSize = EnrichedSpanUtils.getRequestSize(e);
assertTrue(requestSize.isEmpty());
Expand All @@ -256,7 +262,8 @@ public void getRequestSize_httpProtocol_noSize() {
public void getResponseSize_httpProtocol() {
Event e = createMockEventWithEnrichedAttribute("PROTOCOL", "HTTP");
when(e.getAttributes())
.thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
.thenReturn(
fastNewBuilder(Attributes.Builder.class).setAttributeMap(new HashMap<>()).build());
addAttribute(e, RawSpanConstants.getValue(HTTP_RESPONSE_SIZE), "64");

Optional<Integer> responseSize = EnrichedSpanUtils.getResponseSize(e);
Expand All @@ -268,7 +275,8 @@ public void getResponseSize_httpProtocol() {
public void getResponseSize_grpcProtocol() {
Event e = createMockEventWithEnrichedAttribute("PROTOCOL", "GRPC");
when(e.getAttributes())
.thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
.thenReturn(
fastNewBuilder(Attributes.Builder.class).setAttributeMap(new HashMap<>()).build());
addAttribute(e, RawSpanConstants.getValue(GRPC_RESPONSE_BODY), "some grpc request body");

Optional<Integer> responseSize = EnrichedSpanUtils.getResponseSize(e);
Expand All @@ -280,7 +288,8 @@ public void getResponseSize_grpcProtocol() {
public void getResponseSize_httpProtocol_noSize() {
Event e = createMockEventWithEnrichedAttribute("PROTOCOL", "HTTP");
when(e.getAttributes())
.thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
.thenReturn(
fastNewBuilder(Attributes.Builder.class).setAttributeMap(new HashMap<>()).build());

Optional<Integer> requestSize = EnrichedSpanUtils.getResponseSize(e);
assertTrue(requestSize.isEmpty());
Expand Down Expand Up @@ -338,7 +347,7 @@ public void testGetSpaceIds_withData() {
Event e = mock(Event.class);
when(e.getEnrichedAttributes())
.thenReturn(
Attributes.newBuilder()
fastNewBuilder(Attributes.Builder.class)
.setAttributeMap(Map.of("SPACE_IDS", AttributeValueCreator.create(spaceIds)))
.build());

Expand All @@ -363,7 +372,7 @@ private Event createMockEventWithAttribute(String key, String value) {
Event e = mock(Event.class);
when(e.getAttributes())
.thenReturn(
Attributes.newBuilder()
fastNewBuilder(Attributes.Builder.class)
.setAttributeMap(Map.of(key, AttributeValue.newBuilder().setValue(value).build()))
.build());
when(e.getEnrichedAttributes()).thenReturn(null);
Expand All @@ -375,7 +384,7 @@ private Event createMockEventWithEnrichedAttribute(String key, String value) {
when(e.getAttributes()).thenReturn(null);
when(e.getEnrichedAttributes())
.thenReturn(
Attributes.newBuilder()
fastNewBuilder(Attributes.Builder.class)
.setAttributeMap(Map.of(key, AttributeValue.newBuilder().setValue(value).build()))
.build());
return e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tasks.test {

dependencies {
implementation(project(":hypertrace-trace-enricher:enriched-span-constants"))
implementation("org.hypertrace.core.datamodel:data-model:0.1.19")
implementation("org.hypertrace.core.datamodel:data-model:0.1.20")

implementation("org.slf4j:slf4j-api:1.7.30")
implementation("org.apache.commons:commons-lang3:3.12.0")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.hypertrace.traceenricher.trace.util;

import static org.hypertrace.core.datamodel.shared.AvroBuilderCache.fastNewBuilder;

import java.io.File;
import java.io.IOException;
import java.net.URL;
Expand Down Expand Up @@ -245,7 +247,7 @@ void debugApiTraceGraph() throws IOException {
void addEnrichedAttribute(Event event, String key, AttributeValue value) {
Attributes enrichedAttributes = event.getEnrichedAttributes();
if (enrichedAttributes == null) {
enrichedAttributes = Attributes.newBuilder().build();
enrichedAttributes = fastNewBuilder(Attributes.Builder.class).build();
event.setEnrichedAttributes(enrichedAttributes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies {
implementation(project(":semantic-convention-utils"))
implementation(project(":hypertrace-trace-enricher:trace-reader"))

implementation("org.hypertrace.core.datamodel:data-model:0.1.19")
implementation("org.hypertrace.core.datamodel:data-model:0.1.20")
implementation("org.hypertrace.entity.service:entity-service-client:0.8.5")
implementation("org.hypertrace.core.serviceframework:platform-metrics:0.1.28")
implementation("org.hypertrace.core.grpcutils:grpc-client-utils:0.6.1")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.hypertrace.traceenricher.enrichment;

import static org.hypertrace.core.datamodel.shared.AvroBuilderCache.fastNewBuilder;

import com.google.common.collect.Lists;
import com.typesafe.config.Config;
import java.util.HashSet;
Expand Down Expand Up @@ -62,7 +64,7 @@ protected Event getEarliestEvent(StructuredTrace trace) {
protected void addEnrichedAttribute(Event event, String key, AttributeValue value) {
Attributes enrichedAttributes = event.getEnrichedAttributes();
if (enrichedAttributes == null) {
enrichedAttributes = Attributes.newBuilder().build();
enrichedAttributes = fastNewBuilder(Attributes.Builder.class).build();
event.setEnrichedAttributes(enrichedAttributes);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.hypertrace.traceenricher.util;

import static org.hypertrace.core.datamodel.shared.AvroBuilderCache.fastNewBuilder;

import java.util.HashMap;
import java.util.Map;
import org.hypertrace.core.datamodel.AttributeValue;
Expand All @@ -22,7 +24,10 @@ public static Entity convertToAvroEntity(EnrichedEntity entity) {
.setEntityId(entity.getEntityId())
.setCustomerId(entity.getTenantId())
.setEntityName(entity.getEntityName())
.setAttributes(Attributes.newBuilder().setAttributeMap(getAvroAttributeMap(entity)).build())
.setAttributes(
fastNewBuilder(Attributes.Builder.class)
.setAttributeMap(getAvroAttributeMap(entity))
.build())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.hypertrace.traceenricher.util;

import static org.hypertrace.core.datamodel.shared.AvroBuilderCache.fastNewBuilder;

import com.google.common.base.Strings;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -40,7 +42,9 @@ public static Entity convertToAvroEntity(

if (includeAttributes) {
builder.setAttributes(
Attributes.newBuilder().setAttributeMap(getAvroAttributeMap(entity)).build());
fastNewBuilder(Attributes.Builder.class)
.setAttributeMap(getAvroAttributeMap(entity))
.build());
}
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.hypertrace.traceenricher.enrichment.enrichers;

import static org.hypertrace.core.datamodel.shared.AvroBuilderCache.fastNewBuilder;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -63,9 +64,11 @@ protected Config getEntityServiceConfig() {
Event createMockEvent() {
Event e = mock(Event.class);
when(e.getAttributes())
.thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
.thenReturn(
fastNewBuilder(Attributes.Builder.class).setAttributeMap(new HashMap<>()).build());
when(e.getEnrichedAttributes())
.thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
.thenReturn(
fastNewBuilder(Attributes.Builder.class).setAttributeMap(new HashMap<>()).build());
lenient()
.when(e.getMetrics())
.thenReturn(Metrics.newBuilder().setMetricMap(new HashMap<>()).build());
Expand Down Expand Up @@ -120,7 +123,8 @@ public StructuredTrace createStructuredTrace(String tenantId, Event... events) {
StructuredTrace createMockStructuredTrace() {
StructuredTrace trace = mock(StructuredTrace.class);
when(trace.getAttributes())
.thenReturn(Attributes.newBuilder().setAttributeMap(new HashMap<>()).build());
.thenReturn(
fastNewBuilder(Attributes.Builder.class).setAttributeMap(new HashMap<>()).build());
when(trace.getMetrics()).thenReturn(Metrics.newBuilder().setMetricMap(new HashMap<>()).build());

return trace;
Expand All @@ -141,7 +145,7 @@ public Attributes createNewAvroAttributes() {
protected Attributes createNewAvroAttributes(Map<String, String> attributes) {
Map<String, AttributeValue> map = new HashMap<>();
attributes.forEach((k, v) -> map.put(k, createAvroAttribute(v)));
return Attributes.newBuilder().setAttributeMap(map).build();
return fastNewBuilder(Attributes.Builder.class).setAttributeMap(map).build();
}

protected Map<String, org.hypertrace.entity.data.service.v1.AttributeValue> createEdsAttributes(
Expand Down Expand Up @@ -175,7 +179,7 @@ Event.Builder createOpenSourceSpan(
.setEventId(ByteBuffer.wrap(eventId.getBytes()))
.setEnrichedAttributes(createNewAvroAttributes(enrichedAttr))
.setServiceName(serviceName)
.setAttributes(Attributes.newBuilder().build());
.setAttributes(fastNewBuilder(Attributes.Builder.class).build());
}

protected StructuredTrace getBigTrace() {
Expand Down Expand Up @@ -217,11 +221,9 @@ protected StructuredTrace getBigTrace() {
Event.newBuilder()
.setCustomerId(TENANT_ID)
.setAttributes(
org.hypertrace.core.datamodel.Attributes.newBuilder()
.setAttributeMap(entrySpanProxyMap)
.build())
fastNewBuilder(Attributes.Builder.class).setAttributeMap(entrySpanProxyMap).build())
.setEnrichedAttributes(
org.hypertrace.core.datamodel.Attributes.newBuilder()
fastNewBuilder(Attributes.Builder.class)
.setAttributeMap(enrichedEntrySpanProxyMap)
.build())
.setEventId(createByteBuffer("event0"))
Expand Down Expand Up @@ -257,9 +259,7 @@ protected StructuredTrace getBigTrace() {
.setEventId(createByteBuffer("event1"))
.setEventRefList(Collections.singletonList(eventRef0))
.setEnrichedAttributes(
org.hypertrace.core.datamodel.Attributes.newBuilder()
.setAttributeMap(event1EnrichedMap)
.build())
fastNewBuilder(Attributes.Builder.class).setAttributeMap(event1EnrichedMap).build())
.build();
RawSpan rawSpan1 =
RawSpan.newBuilder()
Expand Down Expand Up @@ -291,9 +291,7 @@ protected StructuredTrace getBigTrace() {
.setCustomerId(TENANT_ID)
.setEventId(createByteBuffer("event2"))
.setEnrichedAttributes(
org.hypertrace.core.datamodel.Attributes.newBuilder()
.setAttributeMap(event2EnrichedMap)
.build())
fastNewBuilder(Attributes.Builder.class).setAttributeMap(event2EnrichedMap).build())
.setEventRefList(Collections.singletonList(eventRef1))
.build();
RawSpan rawSpan2 =
Expand Down Expand Up @@ -351,11 +349,9 @@ protected StructuredTrace getBigTrace() {
.setCustomerId(TENANT_ID)
.setEventId(createByteBuffer("event4"))
.setAttributes(
org.hypertrace.core.datamodel.Attributes.newBuilder()
.setAttributeMap(exitSpanProxyMap)
.build())
fastNewBuilder(Attributes.Builder.class).setAttributeMap(exitSpanProxyMap).build())
.setEnrichedAttributes(
org.hypertrace.core.datamodel.Attributes.newBuilder()
fastNewBuilder(Attributes.Builder.class)
.setAttributeMap(exitSpanProxyEnrichedMap)
.build())
.setEventRefList(Collections.singletonList(eventRef2))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.hypertrace.traceenricher.enrichment.enrichers;

import static org.hypertrace.core.datamodel.shared.AvroBuilderCache.fastNewBuilder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.doReturn;
Expand Down Expand Up @@ -450,8 +451,9 @@ private Event createEvent(
.setCustomerId(tenantId)
.setEventId(ByteBuffer.wrap(eventName.getBytes()))
.setEnrichedAttributes(
Attributes.newBuilder().setAttributeMap(enrichedAttributesMap).build())
.setAttributes(Attributes.newBuilder().setAttributeMap(attributeMap).build())
fastNewBuilder(Attributes.Builder.class).setAttributeMap(enrichedAttributesMap).build())
.setAttributes(
fastNewBuilder(Attributes.Builder.class).setAttributeMap(attributeMap).build())
.setEventName(eventName)
.setServiceName(serviceName)
.setEventRefList(eventRefList)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.hypertrace.traceenricher.enrichment.enrichers;

import static org.hypertrace.core.datamodel.shared.AvroBuilderCache.fastNewBuilder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -252,8 +253,9 @@ private Event createMockTestEvent() {
.setCustomerId("customer1")
.setEventId(ByteBuffer.wrap("bdf03dfabf5c70f9".getBytes()))
.setEntityIdList(Arrays.asList("4bfca8f7-4974-36a4-9385-dd76bf5c8824"))
.setEnrichedAttributes(Attributes.newBuilder().setAttributeMap(map).build())
.setAttributes(Attributes.newBuilder().setAttributeMap(map).build())
.setEnrichedAttributes(
fastNewBuilder(Attributes.Builder.class).setAttributeMap(map).build())
.setAttributes(fastNewBuilder(Attributes.Builder.class).setAttributeMap(map).build())
.setEventName("test-event")
.setStartTimeMillis(1566869077746L)
.setEndTimeMillis(1566869077750L)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.hypertrace.traceenricher.enrichment.enrichers;

import static org.hypertrace.core.datamodel.shared.AvroBuilderCache.fastNewBuilder;
import static org.hypertrace.core.span.normalizer.constants.OTelSpanTag.OTEL_SPAN_TAG_RPC_SYSTEM;
import static org.hypertrace.traceenricher.enrichment.enrichers.SpanTypeAttributeEnricher.CLIENT_KEY;
import static org.hypertrace.traceenricher.enrichment.enrichers.SpanTypeAttributeEnricher.CLIENT_VALUE;
Expand Down Expand Up @@ -253,9 +254,10 @@ private Event createEvent(
return Event.newBuilder()
.setCustomerId(TENANT_ID)
.setEventId(ByteBuffer.wrap("event1".getBytes()))
.setAttributes(Attributes.newBuilder().setAttributeMap(attributeMap).build())
.setAttributes(
fastNewBuilder(Attributes.Builder.class).setAttributeMap(attributeMap).build())
.setEnrichedAttributes(
Attributes.newBuilder().setAttributeMap(enrichedAttributeMap).build())
fastNewBuilder(Attributes.Builder.class).setAttributeMap(enrichedAttributeMap).build())
.build();
}

Expand Down
Loading