Skip to content

Fix error NPE in metrics emission. #10675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 28, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ public JobCreationOutput createNewJob(final JobCreationInput input) {

private void emitSrcIdDstIdToReleaseStagesMetric(final UUID srcId, final UUID dstId) throws IOException {
final var releaseStages = configRepository.getDatabase().query(ctx -> MetricQueries.srcIdAndDestIdToReleaseStages(ctx, srcId, dstId));
if (releaseStages == null) {
if (releaseStages == null || releaseStages.size() == 0) {
return;
}

for (final ReleaseStage stage : releaseStages) {
DogStatsDMetricSingleton.count(MetricsRegistry.JOB_CREATED_BY_RELEASE_STAGE, 1, MetricTags.getReleaseStage(stage));
if (stage != null) {
DogStatsDMetricSingleton.count(MetricsRegistry.JOB_CREATED_BY_RELEASE_STAGE, 1, MetricTags.getReleaseStage(stage));
}
}
}

Expand Down Expand Up @@ -213,12 +215,14 @@ public void reportJobStart(final ReportJobStartInput input) {

private void emitJobIdToReleaseStagesMetric(final MetricsRegistry metric, final long jobId) throws IOException {
final var releaseStages = configRepository.getDatabase().query(ctx -> MetricQueries.jobIdToReleaseStages(ctx, jobId));
if (releaseStages == null) {
if (releaseStages == null || releaseStages.size() == 0) {
return;
}

for (final ReleaseStage stage : releaseStages) {
DogStatsDMetricSingleton.count(metric, 1, MetricTags.getReleaseStage(stage));
if (stage != null) {
DogStatsDMetricSingleton.count(metric, 1, MetricTags.getReleaseStage(stage));
}
}
}

Expand Down