Skip to content
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

Emiting reconcile_elapsed_ms metrics #6534

Merged
merged 4 commits into from
Feb 4, 2025
Merged

Conversation

NamanMahor
Copy link
Contributor

@NamanMahor NamanMahor commented Jan 30, 2025

Emiting reconcile_elapsed_ms metrics

Copy link
Member

@k-anshul k-anshul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey

So we already have the metric being logged. But there are some changes that needs to be done.

  1. It should be a EventTypeMetric and not log.
  2. Needs to log for cancellations as well.
  3. Need to separate out normal errors from timeouts.
  4. Need to include retrigger_time.
  5. Need to include rill_version. It is not present in runtime as of now but you can populate the same by making changes similar to admin service here :

    rill/cli/cmd/admin/start.go

    Lines 292 to 293 in baa6274

    VersionNumber: ch.Version.Number,
    VersionCommit: ch.Version.Commit,

@NamanMahor NamanMahor requested a review from k-anshul January 31, 2025 16:52
@NamanMahor
Copy link
Contributor Author

Hey

So we already have the metric being logged. But there are some changes that needs to be done.

  1. It should be a EventTypeMetric and not log.
  2. Needs to log for cancellations as well.
  3. Need to separate out normal errors from timeouts.
  4. Need to include retrigger_time.
  5. Need to include rill_version. It is not present in runtime as of now but you can populate the same by making changes similar to admin service here :

    rill/cli/cmd/admin/start.go

    Lines 292 to 293 in baa6274

    VersionNumber: ch.Version.Number,
    VersionCommit: ch.Version.Commit,

@k-anshul rill_version should already be there because it got added in activety
I added new EvenTypeMetric(which handled retrigger_time n cancellations ) but did't removed the log type which was there.
Seems like we do not need log so removed it in latest commit.
And also Handling timeout using DeadlineExceeded error.

@NamanMahor NamanMahor changed the title Emiting reconcile_time_ms metrics Emiting reconcile_elapsed_ms metrics Jan 31, 2025
commonDims = append(commonDims, attribute.String("reconcile_status", "Cancelled"))
} else if inv.result.Err != nil {
if errors.Is(inv.result.Err, context.Canceled) {
commonDims = append(commonDims, attribute.String("reconcile_status", "Cancelled"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit : Canceled and not Cancelled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if inv.result.Err != nil {
eventArgs = append(eventArgs, attribute.String("error", inv.result.Err.Error()))
commonDims := []attribute.KeyValue{
attribute.String("resource_id", inv.name.Name),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
attribute.String("resource_id", inv.name.Name),
attribute.String("resource_name", inv.name.Name),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 1365 to 1370
if inv.isDelete {
commonDims = append(commonDims, attribute.Bool("is_deleted", true))
}
if inv.isRename {
commonDims = append(commonDims, attribute.Bool("is_renamed", true))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar:

Suggested change
if inv.isDelete {
commonDims = append(commonDims, attribute.Bool("is_deleted", true))
}
if inv.isRename {
commonDims = append(commonDims, attribute.Bool("is_renamed", true))
}
if inv.isDelete {
commonDims = append(commonDims, attribute.Bool("is_delete", true))
}
if inv.isRename {
commonDims = append(commonDims, attribute.Bool("is_rename", true))
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added reconcile_operation instead of two different dimensions

}

if !inv.cancelledOn.IsZero() {
commonDims = append(commonDims, attribute.String("reconcile_status", "Cancelled"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reconcile_status is not a good key here – we already have something called ReconcileStatus and it takes different values:

enum ReconcileStatus {
RECONCILE_STATUS_UNSPECIFIED = 0;
RECONCILE_STATUS_IDLE = 1;
RECONCILE_STATUS_PENDING = 2;
RECONCILE_STATUS_RUNNING = 3;
}

Maybe consider reconcile_result instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
c.Activity.Record(context.Background(), activity.EventTypeLog, "reconciled_resource", eventArgs...)
} else {
commonDims = append(commonDims, attribute.String("reconcile_status", "Succeeded"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: call it "success" instead of "Succeeded"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

commonDims = append(commonDims, attribute.String("reconcile_status", "Cancelled"))
} else if inv.result.Err != nil {
if errors.Is(inv.result.Err, context.Canceled) {
commonDims = append(commonDims, attribute.String("reconcile_status", "Cancelled"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the key is snake case, consider also using snake case for the values (this seems like pascal case or title case). E.g. canceled instead of Cancelled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@k-anshul k-anshul merged commit 4b428ec into main Feb 4, 2025
7 checks passed
@k-anshul k-anshul deleted the Emiting_reconcile_time_metrix branch February 4, 2025 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants