Skip to content

Commit f50dca8

Browse files
feat: support internal attributes inside graphql (#81)
* feat: support internal attributes inside graphql * ci: fix snyk and codecov
1 parent 29f5405 commit f50dca8

File tree

7 files changed

+18
-11
lines changed

7 files changed

+18
-11
lines changed

.github/workflows/pr-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ jobs:
6868
- name: Setup snyk
6969
uses: snyk/actions/[email protected]
7070
- name: Snyk test
71-
run: snyk test --all-sub-projects --org=hypertrace --severity-threshold=low --policy-path=.snyk
71+
run: snyk test --all-sub-projects --org=hypertrace --severity-threshold=low --policy-path=.snyk --remote-repo-url='${{ github.server_url }}/${{ github.repository }}.git'
7272
env:
7373
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

.github/workflows/pr-test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,9 @@ jobs:
3434
args: jacocoTestReport
3535

3636
- name: Upload coverage to Codecov
37-
uses: codecov/codecov-action@v1
37+
uses: codecov/codecov-action@v2
3838
with:
3939
name: unit test reports
40-
fail_ci_if_error: true
4140
flags: unit
4241

4342
- name: Publish Unit Test Results

hypertrace-core-graphql-attribute-store/src/main/java/org/hypertrace/core/graphql/attributes/AttributeStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import org.hypertrace.core.graphql.context.GraphQlRequestContext;
66

77
public interface AttributeStore {
8-
Single<List<AttributeModel>> getAll(GraphQlRequestContext context);
8+
Single<List<AttributeModel>> getAllExternal(GraphQlRequestContext context);
99

1010
Single<AttributeModel> get(GraphQlRequestContext context, String scope, String key);
1111

hypertrace-core-graphql-attribute-store/src/main/java/org/hypertrace/core/graphql/attributes/CachingAttributeStore.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import javax.inject.Inject;
88
import javax.inject.Singleton;
99
import org.hypertrace.core.attribute.service.cachingclient.CachingAttributeClient;
10-
import org.hypertrace.core.attribute.service.v1.AttributeMetadataFilter;
1110
import org.hypertrace.core.graphql.context.GraphQlRequestContext;
1211
import org.hypertrace.core.graphql.spi.config.GraphQlServiceConfig;
1312
import org.hypertrace.core.graphql.utils.grpc.GrpcChannelRegistry;
@@ -37,7 +36,6 @@ class CachingAttributeStore implements AttributeStore {
3736
channelRegistry.forAddress(
3837
serviceConfig.getAttributeServiceHost(),
3938
serviceConfig.getAttributeServicePort()))
40-
.withAttributeFilter(AttributeMetadataFilter.newBuilder().setInternal(false).build())
4139
.withCacheExpiration(Duration.ofMinutes(5))
4240
.withMaximumCacheContexts(1000)
4341
.build());
@@ -55,10 +53,11 @@ class CachingAttributeStore implements AttributeStore {
5553
}
5654

5755
@Override
58-
public Single<List<AttributeModel>> getAll(GraphQlRequestContext requestContext) {
56+
public Single<List<AttributeModel>> getAllExternal(GraphQlRequestContext requestContext) {
5957
return GrpcRxExecutionContext.forContext(this.grpcContextBuilder.build(requestContext))
6058
.wrapSingle(this.cachingAttributeClient::getAll)
6159
.flattenAsObservable(list -> list)
60+
.filter(attribute -> !attribute.getInternal())
6261
.mapOptional(this.translator::translate)
6362
.toList();
6463
}

hypertrace-core-graphql-attribute-store/src/test/java/org/hypertrace/core/graphql/attributes/CachingAttributeStoreTest.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,24 @@ void supportsBasicRead() {
5959
.setInternal(false)
6060
.build();
6161

62+
AttributeMetadata internalAttrResponse =
63+
AttributeMetadata.newBuilder()
64+
.setScopeString("SPAN")
65+
.setKey("other")
66+
.setInternal(true)
67+
.build();
68+
6269
when(this.mockAttributeClient.get("SPAN", "id")).thenReturn(Single.just(spanIdResponse));
6370
when(this.mockAttributeModeTranslator.translate(spanIdResponse))
6471
.thenReturn(Optional.of(spanIdAttribute));
6572

6673
assertEquals(spanIdAttribute, this.attributeStore.get(mockContext, "SPAN", "id").blockingGet());
6774

68-
when(this.mockAttributeClient.getAll()).thenReturn(Single.just(List.of(spanIdResponse)));
75+
when(this.mockAttributeClient.getAll())
76+
.thenReturn(Single.just(List.of(spanIdResponse, internalAttrResponse)));
6977

70-
assertEquals(List.of(spanIdAttribute), this.attributeStore.getAll(mockContext).blockingGet());
78+
assertEquals(
79+
List.of(spanIdAttribute), this.attributeStore.getAllExternal(mockContext).blockingGet());
7180
}
7281

7382
@Test

hypertrace-core-graphql-metadata-schema/src/main/java/org/hypertrace/core/graphql/metadata/fetcher/MetadataFetcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static final class MetadataFetcherImpl
3030
@Override
3131
public CompletableFuture<List<AttributeMetadata>> get(DataFetchingEnvironment environment) {
3232
return this.attributeStore
33-
.getAll(environment.getContext())
33+
.getAllExternal(environment.getContext())
3434
.flatMap(this.responseBuilder::build)
3535
.toCompletionStage()
3636
.toCompletableFuture();

hypertrace-core-graphql-metadata-schema/src/test/java/org/hypertrace/core/graphql/metadata/fetcher/MetadataFetcherTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void beforeEach() {
3636
List<AttributeModel> mockModelResult = List.of(mockModel);
3737
List<AttributeMetadata> mockMetadataResult = List.of(mockMetadata);
3838
when(this.mockDataFetchingEnvironment.getContext()).thenReturn(this.mockContext);
39-
when(this.mockAttributeStore.getAll(eq(this.mockContext)))
39+
when(this.mockAttributeStore.getAllExternal(eq(this.mockContext)))
4040
.thenReturn(Single.just(mockModelResult));
4141
when(this.mockResponseBuilder.build(eq(mockModelResult)))
4242
.thenReturn(Single.just(mockMetadataResult));

0 commit comments

Comments
 (0)