Skip to content

Commit 287f57e

Browse files
author
Rishabh
authored
feat: Capability to fetch logs along with span (#59)
1 parent 1e1c09e commit 287f57e

File tree

30 files changed

+1113
-48
lines changed

30 files changed

+1113
-48
lines changed

hypertrace-core-graphql-attribute-scope/src/main/java/org/hypertrace/core/graphql/atttributes/scopes/HypertraceCoreAttributeScopeModule.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static org.hypertrace.core.graphql.attributes.IdMapping.forForeignId;
44
import static org.hypertrace.core.graphql.attributes.IdMapping.forId;
5+
import static org.hypertrace.core.graphql.atttributes.scopes.HypertraceCoreAttributeScopeString.LOG_EVENT;
56
import static org.hypertrace.core.graphql.atttributes.scopes.HypertraceCoreAttributeScopeString.SPAN;
67
import static org.hypertrace.core.graphql.atttributes.scopes.HypertraceCoreAttributeScopeString.TRACE;
78

@@ -21,7 +22,7 @@ protected void configure() {
2122
Multibinder<IdMapping> idBinder = Multibinder.newSetBinder(binder(), IdMapping.class);
2223
idBinder.addBinding().toInstance(forId(SPAN, "id"));
2324
idBinder.addBinding().toInstance(forForeignId(SPAN, TRACE, "traceId"));
24-
25+
idBinder.addBinding().toInstance(forForeignId(LOG_EVENT, SPAN, "spanId"));
2526
idBinder.addBinding().toInstance(forId(TRACE, "id"));
2627
}
2728
}

hypertrace-core-graphql-common-schema/src/main/java/org/hypertrace/core/graphql/common/schema/attributes/AttributeQueryable.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.hypertrace.core.graphql.common.schema.attributes.arguments.AttributeKeyArgument;
77

88
public interface AttributeQueryable {
9+
910
String ATTRIBUTE_FIELD_NAME = "attribute";
1011

1112
@GraphQLField

hypertrace-core-graphql-gateway-service-utils/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies {
1010
api(project(":hypertrace-core-graphql-attribute-store"))
1111
api("io.reactivex.rxjava3:rxjava")
1212
api(project(":hypertrace-core-graphql-common-schema"))
13+
implementation(project(":hypertrace-core-graphql-grpc-utils"))
1314

1415
testImplementation("org.junit.jupiter:junit-jupiter")
1516
testImplementation("org.mockito:mockito-core")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.hypertrace.core.graphql.utils.gateway;
2+
3+
import io.grpc.CallCredentials;
4+
import javax.inject.Inject;
5+
import javax.inject.Provider;
6+
import org.hypertrace.core.graphql.spi.config.GraphQlServiceConfig;
7+
import org.hypertrace.core.graphql.utils.grpc.GrpcChannelRegistry;
8+
import org.hypertrace.gateway.service.GatewayServiceGrpc;
9+
import org.hypertrace.gateway.service.GatewayServiceGrpc.GatewayServiceFutureStub;
10+
11+
class GatewayServiceFutureStubProvider implements Provider<GatewayServiceFutureStub> {
12+
13+
private final GraphQlServiceConfig serviceConfig;
14+
private final CallCredentials credentials;
15+
private final GrpcChannelRegistry channelRegistry;
16+
17+
@Inject
18+
GatewayServiceFutureStubProvider(
19+
GraphQlServiceConfig serviceConfig,
20+
CallCredentials credentials,
21+
GrpcChannelRegistry channelRegistry) {
22+
this.serviceConfig = serviceConfig;
23+
this.credentials = credentials;
24+
this.channelRegistry = channelRegistry;
25+
}
26+
27+
@Override
28+
public GatewayServiceFutureStub get() {
29+
return GatewayServiceGrpc.newFutureStub(
30+
channelRegistry.forAddress(
31+
serviceConfig.getGatewayServiceHost(), serviceConfig.getGatewayServicePort()))
32+
.withCallCredentials(credentials);
33+
}
34+
}

hypertrace-core-graphql-gateway-service-utils/src/main/java/org/hypertrace/core/graphql/utils/gateway/GatewayUtilsModule.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.google.inject.AbstractModule;
44
import com.google.inject.Key;
5+
import com.google.inject.Singleton;
56
import com.google.inject.TypeLiteral;
67
import java.util.Collection;
78
import java.util.List;
@@ -15,6 +16,7 @@
1516
import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderDirection;
1617
import org.hypertrace.core.graphql.common.utils.BiConverter;
1718
import org.hypertrace.core.graphql.common.utils.Converter;
19+
import org.hypertrace.gateway.service.GatewayServiceGrpc.GatewayServiceFutureStub;
1820
import org.hypertrace.gateway.service.v1.common.ColumnIdentifier;
1921
import org.hypertrace.gateway.service.v1.common.Expression;
2022
import org.hypertrace.gateway.service.v1.common.Filter;
@@ -62,5 +64,9 @@ protected void configure() {
6264

6365
bind(Key.get(new TypeLiteral<Converter<OrderDirection, SortOrder>>() {}))
6466
.to(SortOrderConverter.class);
67+
68+
bind(GatewayServiceFutureStub.class)
69+
.toProvider(GatewayServiceFutureStubProvider.class)
70+
.in(Singleton.class);
6571
}
6672
}

hypertrace-core-graphql-log-event-schema/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ dependencies {
2828
testImplementation("org.junit.jupiter:junit-jupiter")
2929
testImplementation("com.fasterxml.jackson.core:jackson-databind")
3030
testImplementation(project(":hypertrace-core-graphql-gateway-service-utils"))
31+
testImplementation("org.mockito:mockito-core")
32+
testImplementation("org.mockito:mockito-junit-jupiter")
33+
3134
testAnnotationProcessor("org.projectlombok:lombok")
3235
testCompileOnly("org.projectlombok:lombok")
3336
}

hypertrace-core-graphql-log-event-schema/src/test/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventsRequestBuilderTest.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package org.hypertrace.core.graphql.log.event.dao;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.mockito.Mockito.mock;
45

6+
import com.google.inject.AbstractModule;
57
import com.google.inject.Guice;
68
import com.google.inject.Injector;
79
import com.google.inject.Key;
810
import com.google.inject.TypeLiteral;
11+
import io.grpc.CallCredentials;
912
import java.time.Duration;
1013
import java.time.Instant;
1114
import java.util.Collection;
@@ -18,7 +21,9 @@
1821
import org.hypertrace.core.graphql.common.schema.results.arguments.filter.FilterArgument;
1922
import org.hypertrace.core.graphql.common.schema.results.arguments.order.OrderArgument;
2023
import org.hypertrace.core.graphql.common.utils.Converter;
24+
import org.hypertrace.core.graphql.spi.config.GraphQlServiceConfig;
2125
import org.hypertrace.core.graphql.utils.gateway.GatewayUtilsModule;
26+
import org.hypertrace.core.graphql.utils.grpc.GrpcChannelRegistry;
2227
import org.hypertrace.gateway.service.v1.common.Expression;
2328
import org.hypertrace.gateway.service.v1.common.Filter;
2429
import org.hypertrace.gateway.service.v1.common.OrderByExpression;
@@ -32,7 +37,17 @@ class GatewayServiceLogEventsRequestBuilderTest extends BaseDaoTest {
3237

3338
@BeforeEach
3439
void setup() {
35-
Injector injector = Guice.createInjector(new GatewayUtilsModule());
40+
Injector injector =
41+
Guice.createInjector(
42+
new GatewayUtilsModule(),
43+
new AbstractModule() {
44+
@Override
45+
protected void configure() {
46+
bind(CallCredentials.class).toInstance(mock(CallCredentials.class));
47+
bind(GraphQlServiceConfig.class).toInstance(mock(GraphQlServiceConfig.class));
48+
bind(GrpcChannelRegistry.class).toInstance(mock(GrpcChannelRegistry.class));
49+
}
50+
});
3651

3752
Converter<Collection<AttributeAssociation<FilterArgument>>, Filter> filterConverter =
3853
injector.getInstance(

hypertrace-core-graphql-log-event-schema/src/test/java/org/hypertrace/core/graphql/log/event/dao/GatewayServiceLogEventsResponseConverterTest.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package org.hypertrace.core.graphql.log.event.dao;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.mockito.Mockito.mock;
45

6+
import com.google.inject.AbstractModule;
57
import com.google.inject.Guice;
68
import com.google.inject.Injector;
79
import com.google.inject.Key;
810
import com.google.inject.TypeLiteral;
11+
import io.grpc.CallCredentials;
912
import java.time.Duration;
1013
import java.time.Instant;
1114
import java.util.Collection;
@@ -16,7 +19,9 @@
1619
import org.hypertrace.core.graphql.common.request.AttributeRequest;
1720
import org.hypertrace.core.graphql.common.utils.BiConverter;
1821
import org.hypertrace.core.graphql.log.event.schema.LogEventResultSet;
22+
import org.hypertrace.core.graphql.spi.config.GraphQlServiceConfig;
1923
import org.hypertrace.core.graphql.utils.gateway.GatewayUtilsModule;
24+
import org.hypertrace.core.graphql.utils.grpc.GrpcChannelRegistry;
2025
import org.hypertrace.gateway.service.v1.common.Value;
2126
import org.hypertrace.gateway.service.v1.common.ValueType;
2227
import org.hypertrace.gateway.service.v1.log.events.LogEvent;
@@ -30,7 +35,17 @@ class GatewayServiceLogEventsResponseConverterTest extends BaseDaoTest {
3035

3136
@BeforeEach
3237
void setup() {
33-
Injector injector = Guice.createInjector(new GatewayUtilsModule());
38+
Injector injector =
39+
Guice.createInjector(
40+
new GatewayUtilsModule(),
41+
new AbstractModule() {
42+
@Override
43+
protected void configure() {
44+
bind(CallCredentials.class).toInstance(mock(CallCredentials.class));
45+
bind(GraphQlServiceConfig.class).toInstance(mock(GraphQlServiceConfig.class));
46+
bind(GrpcChannelRegistry.class).toInstance(mock(GrpcChannelRegistry.class));
47+
}
48+
});
3449
BiConverter<Collection<AttributeRequest>, Map<String, Value>, Map<String, Object>>
3550
attributeMapConverter =
3651
injector.getInstance(

hypertrace-core-graphql-span-schema/build.gradle.kts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,21 @@ dependencies {
2222
implementation(project(":hypertrace-core-graphql-grpc-utils"))
2323
implementation(project(":hypertrace-core-graphql-common-schema"))
2424
implementation(project(":hypertrace-core-graphql-attribute-store"))
25+
implementation(project(":hypertrace-core-graphql-log-event-schema"))
26+
implementation(project(":hypertrace-core-graphql-deserialization"))
27+
implementation(project(":hypertrace-core-graphql-schema-utils"))
28+
implementation(project(":hypertrace-core-graphql-attribute-scope-constants"))
29+
30+
testImplementation("org.junit.jupiter:junit-jupiter")
31+
testImplementation("com.fasterxml.jackson.core:jackson-databind")
32+
testImplementation(project(":hypertrace-core-graphql-gateway-service-utils"))
33+
testImplementation("org.mockito:mockito-core")
34+
testImplementation("org.mockito:mockito-junit-jupiter")
35+
36+
testAnnotationProcessor("org.projectlombok:lombok")
37+
testCompileOnly("org.projectlombok:lombok")
38+
}
39+
40+
tasks.test {
41+
useJUnitPlatform()
2542
}

hypertrace-core-graphql-span-schema/src/main/java/org/hypertrace/core/graphql/span/SpanSchemaModule.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.google.inject.multibindings.Multibinder;
55
import org.hypertrace.core.graphql.common.request.ResultSetRequestBuilder;
66
import org.hypertrace.core.graphql.span.dao.SpanDaoModule;
7+
import org.hypertrace.core.graphql.span.request.SpanRequestModule;
78
import org.hypertrace.core.graphql.spi.schema.GraphQlSchemaFragment;
89

910
public class SpanSchemaModule extends AbstractModule {
@@ -15,5 +16,6 @@ protected void configure() {
1516

1617
requireBinding(ResultSetRequestBuilder.class);
1718
install(new SpanDaoModule());
19+
install(new SpanRequestModule());
1820
}
1921
}

0 commit comments

Comments
 (0)