-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Publish metrics for: - created jobs tagged by release stage - failed jobs tagged by release stage - cancelled jobs tagged by release stage - succeed jobs tagged by release stage
- Loading branch information
Showing
14 changed files
with
322 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
airbyte-metrics/lib/src/main/java/io/airbyte/metrics/lib/MetricQueries.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.metrics.lib; | ||
|
||
import static io.airbyte.db.instance.configs.jooq.Tables.ACTOR; | ||
import static io.airbyte.db.instance.configs.jooq.Tables.ACTOR_DEFINITION; | ||
|
||
import io.airbyte.db.instance.configs.jooq.enums.ReleaseStage; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import org.jooq.DSLContext; | ||
|
||
/** | ||
* Keep track of all metric queries. | ||
*/ | ||
public class MetricQueries { | ||
|
||
public static List<ReleaseStage> jobIdToReleaseStages(final DSLContext ctx, final long jobId) { | ||
final var srcRelStageCol = "src_release_stage"; | ||
final var dstRelStageCol = "dst_release_stage"; | ||
|
||
final var query = String.format(""" | ||
SELECT src_def_data.release_stage AS %s, | ||
dest_def_data.release_stage AS %s | ||
FROM connection | ||
INNER JOIN jobs ON connection.id=CAST(jobs.scope AS uuid) | ||
INNER JOIN actor AS dest_data ON connection.destination_id = dest_data.id | ||
INNER JOIN actor_definition AS dest_def_data ON dest_data.actor_definition_id = dest_def_data.id | ||
INNER JOIN actor AS src_data ON connection.source_id = src_data.id | ||
INNER JOIN actor_definition AS src_def_data ON src_data.actor_definition_id = src_def_data.id | ||
WHERE jobs.id = '%d';""", srcRelStageCol, dstRelStageCol, jobId); | ||
|
||
final var res = ctx.fetch(query); | ||
final var stages = res.getValues(srcRelStageCol, ReleaseStage.class); | ||
stages.addAll(res.getValues(dstRelStageCol, ReleaseStage.class)); | ||
return stages; | ||
} | ||
|
||
public static List<ReleaseStage> srcIdAndDestIdToReleaseStages(final DSLContext ctx, final UUID srcId, final UUID dstId) { | ||
return ctx.select(ACTOR_DEFINITION.RELEASE_STAGE).from(ACTOR).join(ACTOR_DEFINITION).on(ACTOR.ACTOR_DEFINITION_ID.eq(ACTOR_DEFINITION.ID)) | ||
.where(ACTOR.ID.eq(srcId)) | ||
.or(ACTOR.ID.eq(dstId)).fetch().getValues(ACTOR_DEFINITION.RELEASE_STAGE); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
airbyte-metrics/lib/src/main/java/io/airbyte/metrics/lib/MetricTags.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.metrics.lib; | ||
|
||
import io.airbyte.db.instance.configs.jooq.enums.ReleaseStage; | ||
|
||
/** | ||
* Keep track of all metric tags. | ||
*/ | ||
public class MetricTags { | ||
|
||
private static final String RELEASE_STAGE = "release_stage:"; | ||
|
||
public static String getReleaseStage(final ReleaseStage stage) { | ||
return RELEASE_STAGE + ":" + stage.getLiteral(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.