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 .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ jobs:
- name: Setup snyk
uses: snyk/actions/setup@0.3.0
- name: Snyk test
run: snyk test --all-sub-projects --org=hypertrace --severity-threshold=low --policy-path=.snyk
run: snyk test --all-sub-projects --org=hypertrace --severity-threshold=low --policy-path=.snyk --remote-repo-url='${{ github.server_url }}/${{ github.repository }}.git'
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
3 changes: 1 addition & 2 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ jobs:
args: jacocoTestReport

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v2
with:
name: unit test reports
fail_ci_if_error: true
flags: unit

- name: Publish Unit Test Results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.hypertrace.core.graphql.context.GraphQlRequestContext;

public interface AttributeStore {
Single<List<AttributeModel>> getAll(GraphQlRequestContext context);
Single<List<AttributeModel>> getAllExternal(GraphQlRequestContext context);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import javax.inject.Inject;
import javax.inject.Singleton;
import org.hypertrace.core.attribute.service.cachingclient.CachingAttributeClient;
import org.hypertrace.core.attribute.service.v1.AttributeMetadataFilter;
import org.hypertrace.core.graphql.context.GraphQlRequestContext;
import org.hypertrace.core.graphql.spi.config.GraphQlServiceConfig;
import org.hypertrace.core.graphql.utils.grpc.GrpcChannelRegistry;
Expand Down Expand Up @@ -37,7 +36,6 @@ class CachingAttributeStore implements AttributeStore {
channelRegistry.forAddress(
serviceConfig.getAttributeServiceHost(),
serviceConfig.getAttributeServicePort()))
.withAttributeFilter(AttributeMetadataFilter.newBuilder().setInternal(false).build())
.withCacheExpiration(Duration.ofMinutes(5))
.withMaximumCacheContexts(1000)
.build());
Expand All @@ -55,10 +53,11 @@ class CachingAttributeStore implements AttributeStore {
}

@Override
public Single<List<AttributeModel>> getAll(GraphQlRequestContext requestContext) {
public Single<List<AttributeModel>> getAllExternal(GraphQlRequestContext requestContext) {
return GrpcRxExecutionContext.forContext(this.grpcContextBuilder.build(requestContext))
.wrapSingle(this.cachingAttributeClient::getAll)
.flattenAsObservable(list -> list)
.filter(attribute -> !attribute.getInternal())
.mapOptional(this.translator::translate)
.toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,24 @@ void supportsBasicRead() {
.setInternal(false)
.build();

AttributeMetadata internalAttrResponse =
AttributeMetadata.newBuilder()
.setScopeString("SPAN")
.setKey("other")
.setInternal(true)
.build();

when(this.mockAttributeClient.get("SPAN", "id")).thenReturn(Single.just(spanIdResponse));
when(this.mockAttributeModeTranslator.translate(spanIdResponse))
.thenReturn(Optional.of(spanIdAttribute));

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

when(this.mockAttributeClient.getAll()).thenReturn(Single.just(List.of(spanIdResponse)));
when(this.mockAttributeClient.getAll())
.thenReturn(Single.just(List.of(spanIdResponse, internalAttrResponse)));

assertEquals(List.of(spanIdAttribute), this.attributeStore.getAll(mockContext).blockingGet());
assertEquals(
List.of(spanIdAttribute), this.attributeStore.getAllExternal(mockContext).blockingGet());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static final class MetadataFetcherImpl
@Override
public CompletableFuture<List<AttributeMetadata>> get(DataFetchingEnvironment environment) {
return this.attributeStore
.getAll(environment.getContext())
.getAllExternal(environment.getContext())
.flatMap(this.responseBuilder::build)
.toCompletionStage()
.toCompletableFuture();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void beforeEach() {
List<AttributeModel> mockModelResult = List.of(mockModel);
List<AttributeMetadata> mockMetadataResult = List.of(mockMetadata);
when(this.mockDataFetchingEnvironment.getContext()).thenReturn(this.mockContext);
when(this.mockAttributeStore.getAll(eq(this.mockContext)))
when(this.mockAttributeStore.getAllExternal(eq(this.mockContext)))
.thenReturn(Single.just(mockModelResult));
when(this.mockResponseBuilder.build(eq(mockModelResult)))
.thenReturn(Single.just(mockMetadataResult));
Expand Down