Skip to content
Merged
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.17")
implementation("org.hypertrace.core.datamodel:data-model:0.1.18")
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.17")
implementation("org.hypertrace.core.datamodel:data-model:0.1.18")
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
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.17")
implementation("org.hypertrace.core.datamodel:data-model:0.1.18")

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
Expand Up @@ -16,19 +16,23 @@ public class StructuredTraceGraphBuilder {

public static StructuredTraceGraph buildGraph(StructuredTrace trace) {
StructuredTrace cachedTrace = cachedTraceThreadLocal.get();
StructuredTraceGraph cachedGraph = cachedGraphThreadLocal.get();
boolean shouldRebuildTraceEventsGraph =
GraphBuilderUtil.isTraceEventsChanged(cachedTrace, trace);
boolean shouldRebuildTraceEntitiesGraph =
GraphBuilderUtil.isTraceEntitiesChanged(cachedTrace, trace);

if (GraphBuilderUtil.isDifferentTrace(cachedTrace, trace)
if (null == cachedGraph
|| GraphBuilderUtil.isDifferentTrace(cachedTrace, trace)
|| (shouldRebuildTraceEventsGraph && shouldRebuildTraceEntitiesGraph)) {
Instant start = Instant.now();
StructuredTraceGraph graph = StructuredTraceGraph.createGraph(trace);
LOG.debug(
"Time taken in building StructuredTraceGraph, duration_millis:{} for tenantId:{}",
Duration.between(start, Instant.now()).toMillis(),
trace.getCustomerId());
StructuredTraceGraph graph = new StructuredTraceGraph(trace);
if (LOG.isDebugEnabled()) {
LOG.debug(
"Time taken in building StructuredTraceGraph, duration_millis:{} for tenantId:{}",
Duration.between(start, Instant.now()).toMillis(),
trace.getCustomerId());
}
cachedTraceThreadLocal.set(StructuredTrace.newBuilder(trace).build());
cachedGraphThreadLocal.set(graph);
debugGraph("Case: Rebuilding the graph.", graph, trace);
Expand All @@ -37,22 +41,25 @@ public static StructuredTraceGraph buildGraph(StructuredTrace trace) {

if (shouldRebuildTraceEventsGraph || shouldRebuildTraceEntitiesGraph) {
Instant start = Instant.now();
StructuredTraceGraph graph =
shouldRebuildTraceEventsGraph
? StructuredTraceGraph.reCreateTraceEventsGraph(trace)
: StructuredTraceGraph.reCreateTraceEntitiesGraph(trace);
LOG.debug(
"Time taken in building TraceEventsGraph, duration_millis:{} for tenantId:{}",
Duration.between(start, Instant.now()).toMillis(),
trace.getCustomerId());
if (shouldRebuildTraceEventsGraph) {
cachedGraph.reCreateTraceEventsGraph(trace);
} else {
cachedGraph.reCreateTraceEntitiesGraph(trace);
}
if (LOG.isDebugEnabled()) {
Copy link
Contributor

@surajpuvvada surajpuvvada Jul 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this log be inside the if condition ? or may be fix the log statement

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't get your point, what changes are you suggesting in the log statement?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it says building events graph but it could be either events or entities graph

LOG.debug(
"Time taken in building TraceEventsGraph, duration_millis:{} for tenantId:{}",
Duration.between(start, Instant.now()).toMillis(),
trace.getCustomerId());
}
cachedTraceThreadLocal.set(StructuredTrace.newBuilder(trace).build());
cachedGraphThreadLocal.set(graph);
debugGraph("Case: Partially building the graph.", graph, trace);
return graph;
cachedGraphThreadLocal.set(cachedGraph);
debugGraph("Case: Partially building the graph.", cachedGraph, trace);
return cachedGraph;
}

debugGraph("Case: Not building the graph.", cachedGraphThreadLocal.get(), trace);
return cachedGraphThreadLocal.get();
return cachedGraph;
}

private static void debugGraph(
Expand All @@ -68,23 +75,23 @@ private static void debugGraph(
(null != graph.getTraceEntitiesGraph()));

// build the graph again and check
StructuredTraceGraph tempGraph = StructuredTraceGraph.createGraph(trace);
StructuredTraceGraph tempGraph = new StructuredTraceGraph(trace);
LOG.info(
logPrefix
+ "Recreating StructuredTraceGraph. Is events graph non-null: {}."
+ " Is entities graph non-null: {}",
(null != tempGraph.getTraceEventsGraph()),
(null != tempGraph.getTraceEntitiesGraph()));

tempGraph = StructuredTraceGraph.reCreateTraceEventsGraph(trace);
tempGraph.reCreateTraceEventsGraph(trace);
LOG.info(
logPrefix
+ "Recreating events graph. Is events graph non-null: {}."
+ " Is entities graph non-null: {}",
(null != tempGraph.getTraceEventsGraph()),
(null != tempGraph.getTraceEntitiesGraph()));

tempGraph = StructuredTraceGraph.reCreateTraceEntitiesGraph(trace);
tempGraph.reCreateTraceEntitiesGraph(trace);
LOG.info(
logPrefix
+ "Recreating entities graph. Is events graph non-null: {}."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.hypertrace.traceenricher.trace.util;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;

import java.nio.ByteBuffer;
Expand All @@ -14,6 +14,7 @@
import org.hypertrace.core.datamodel.shared.StructuredTraceGraph;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.MockedConstruction;
import org.mockito.MockedStatic;

public class StructuredTraceGraphBuilderTest {
Expand Down Expand Up @@ -44,33 +45,15 @@ void testBuildGraph() {
.when(() -> StructuredTrace.newBuilder(underTestTrace))
.thenReturn(builder);

// make two calls, and check that first call create cache entries, and second call uses same
StructuredTraceGraph mockedStructuredTraceGraph = mock(StructuredTraceGraph.class);
try (MockedStatic<StructuredTraceGraph> structuredTraceGraphMockedStatic =
mockStatic(StructuredTraceGraph.class)) {
structuredTraceGraphMockedStatic
.when(() -> StructuredTraceGraph.createGraph(underTestTrace))
.thenReturn(mockedStructuredTraceGraph);
structuredTraceGraphMockedStatic
.when(() -> StructuredTraceGraph.reCreateTraceEntitiesGraph(underTestTrace))
.thenReturn(mockedStructuredTraceGraph);
structuredTraceGraphMockedStatic
.when(() -> StructuredTraceGraph.reCreateTraceEventsGraph(underTestTrace))
.thenReturn(mockedStructuredTraceGraph);
try (MockedConstruction<StructuredTraceGraph> mocked =
mockConstruction(StructuredTraceGraph.class)) {

// calls first time
StructuredTraceGraph actual = StructuredTraceGraphBuilder.buildGraph(underTestTrace);
Assertions.assertEquals(mockedStructuredTraceGraph, actual);
structuredTraceGraphMockedStatic.verify(
// todo change times to 1 when logging is changed to debug level in
// StructuredTraceGraphBuilder#buildGraph
() -> StructuredTraceGraph.createGraph(underTestTrace), times(2));

// calls second time, this time it returns from cache
StructuredTraceGraphBuilder.buildGraph(underTestTrace);
structuredTraceGraphMockedStatic.verify(
// todo change times to 1 when logging is changed to debug level in
// StructuredTraceGraphBuilder#buildGraph
() -> StructuredTraceGraph.createGraph(underTestTrace), times(3));
StructuredTraceGraph cached = StructuredTraceGraphBuilder.buildGraph(underTestTrace);
Assertions.assertEquals(actual, cached);
}
}
}
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.17")
implementation("org.hypertrace.core.datamodel:data-model:0.1.18")
implementation("org.hypertrace.entity.service:entity-service-client:0.6.10")
implementation("org.hypertrace.core.serviceframework:platform-metrics:0.1.26")
implementation("org.hypertrace.core.grpcutils:grpc-client-utils:0.5.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tasks.test {

dependencies {
implementation(project(":hypertrace-trace-enricher:hypertrace-trace-enricher-impl"))
implementation("org.hypertrace.core.datamodel:data-model:0.1.17")
implementation("org.hypertrace.core.datamodel:data-model:0.1.18")
implementation("org.hypertrace.core.serviceframework:platform-service-framework:0.1.26")
implementation("org.hypertrace.core.serviceframework:platform-metrics:0.1.26")
implementation("org.hypertrace.entity.service:entity-service-client:0.6.10")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

dependencies {
implementation("org.hypertrace.core.datamodel:data-model:0.1.17")
implementation("org.hypertrace.core.datamodel:data-model:0.1.18")

implementation("org.json:json:20210307")
implementation("org.apache.commons:commons-lang3:3.12.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private TraceUI(StructuredTrace trace, Set<JSONObject> roots) {
}

public static TraceUI build(StructuredTrace trace) {
StructuredTraceGraph graph = StructuredTraceGraph.createGraph(trace);
StructuredTraceGraph graph = new StructuredTraceGraph(trace);
Set<Event> roots = findRootEvents(trace);
Set<JSONObject> rootJsons = new HashSet<>();
for (Event root : roots) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies {

// TODO: migrate in core
implementation("org.hypertrace.core.viewgenerator:view-generator-framework:0.3.1")
implementation("org.hypertrace.core.datamodel:data-model:0.1.17")
implementation("org.hypertrace.core.datamodel:data-model:0.1.18")
implementation("org.hypertrace.core.serviceframework:platform-metrics:0.1.26")

implementation("org.hypertrace.entity.service:entity-service-api:0.6.10")
Expand Down
2 changes: 1 addition & 1 deletion raw-spans-grouper/raw-spans-grouper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies {
because("https://snyk.io/vuln/SNYK-JAVA-ORGGLASSFISHJERSEYCORE-1255637")
}
implementation(project(":span-normalizer:span-normalizer-api"))
implementation("org.hypertrace.core.datamodel:data-model:0.1.17")
implementation("org.hypertrace.core.datamodel:data-model:0.1.18")
implementation("org.hypertrace.core.serviceframework:platform-service-framework:0.1.26")
implementation("org.hypertrace.core.serviceframework:platform-metrics:0.1.26")

Expand Down
2 changes: 1 addition & 1 deletion semantic-convention-utils/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {
implementation(project(":span-normalizer:raw-span-constants"))
implementation(project(":span-normalizer:span-normalizer-constants"))

implementation("org.hypertrace.core.datamodel:data-model:0.1.17")
implementation("org.hypertrace.core.datamodel:data-model:0.1.18")
implementation("org.hypertrace.entity.service:entity-service-client:0.6.10")
implementation("org.apache.commons:commons-lang3:3.12.0")

Expand Down
2 changes: 1 addition & 1 deletion span-normalizer/span-normalizer/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies {
implementation(project(":span-normalizer:span-normalizer-constants"))
implementation(project(":semantic-convention-utils"))

implementation("org.hypertrace.core.datamodel:data-model:0.1.17")
implementation("org.hypertrace.core.datamodel:data-model:0.1.18")
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.kafkastreams.framework:kafka-streams-framework:0.1.21")
Expand Down