Skip to content

Commit

Permalink
feat(observe) expose assertion runId and lastObservedMillis to graphql (
Browse files Browse the repository at this point in the history
  • Loading branch information
jayacryl authored and yoonhyejin committed Jul 16, 2024
1 parent cd4e8d0 commit 31cd807
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public com.linkedin.datahub.graphql.generated.AssertionRunEvent apply(
final com.linkedin.datahub.graphql.generated.AssertionRunEvent assertionRunEvent =
new com.linkedin.datahub.graphql.generated.AssertionRunEvent();

assertionRunEvent.setLastObservedMillis(envelopedAspect.getSystemMetadata().getLastObserved());
assertionRunEvent.setTimestampMillis(gmsAssertionRunEvent.getTimestampMillis());
assertionRunEvent.setAssertionUrn(gmsAssertionRunEvent.getAssertionUrn().toString());
assertionRunEvent.setAsserteeUrn(gmsAssertionRunEvent.getAsserteeUrn().toString());
Expand Down
7 changes: 6 additions & 1 deletion datahub-graphql-core/src/main/resources/entity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7404,6 +7404,11 @@ type AssertionRunEvent implements TimeSeriesAspect {
"""
timestampMillis: Long!

"""
The time at which the run event was last observed by the DataHub system - ie, when it was reported by external systems
"""
lastObservedMillis: Long

"""
Urn of assertion which is evaluated
"""
Expand All @@ -7420,7 +7425,7 @@ type AssertionRunEvent implements TimeSeriesAspect {
runId: String!

"""
The status of the assertion run as per this timeseries event.
The status of the assertion run as per this timeseries event
"""
status: AssertionRunStatus!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.linkedin.metadata.aspect.EnvelopedAspect;
import com.linkedin.metadata.query.filter.Filter;
import com.linkedin.metadata.utils.GenericRecordUtils;
import com.linkedin.mxe.SystemMetadata;
import graphql.schema.DataFetchingEnvironment;
import org.mockito.Mockito;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -58,7 +59,9 @@ public void testGetSuccess() throws Exception {
null, AssertionRunStatus.COMPLETE.toString()))))
.thenReturn(
ImmutableList.of(
new EnvelopedAspect().setAspect(GenericRecordUtils.serializeAspect(gmsRunEvent))));
new EnvelopedAspect()
.setAspect(GenericRecordUtils.serializeAspect(gmsRunEvent))
.setSystemMetadata(new SystemMetadata().setLastObserved(12L))));

AssertionRunEventResolver resolver = new AssertionRunEventResolver(mockClient);

Expand Down Expand Up @@ -108,6 +111,7 @@ public void testGetSuccess() throws Exception {
graphqlRunEvent.getStatus(),
com.linkedin.datahub.graphql.generated.AssertionRunStatus.COMPLETE);
assertEquals((float) graphqlRunEvent.getTimestampMillis(), 12L);
assertEquals((float) graphqlRunEvent.getLastObservedMillis(), 12L);
assertEquals((float) graphqlRunEvent.getResult().getActualAggValue(), 10);
assertEquals((long) graphqlRunEvent.getResult().getMissingCount(), 0L);
assertEquals((long) graphqlRunEvent.getResult().getRowCount(), 1L);
Expand Down
2 changes: 2 additions & 0 deletions datahub-web-react/src/graphql/assertion.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ fragment assertionDetails on Assertion {

fragment assertionRunEventDetails on AssertionRunEvent {
timestampMillis
lastObservedMillis
assertionUrn
status
runId
runtimeContext {
key
value
Expand Down

0 comments on commit 31cd807

Please sign in to comment.