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

chore: add more otel params #716

Merged
merged 1 commit into from
Oct 12, 2023
Merged

chore: add more otel params #716

merged 1 commit into from
Oct 12, 2023

Conversation

lzap
Copy link
Member

@lzap lzap commented Oct 12, 2023

Add few more important correlation params into otel logger, also store job id and type in context for later use. Finally, rename one context function to better reflect what it returns.

if accountId != 0 {
t = t.Int64("account_id", accountId)
}

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the gist of the patch - I need to have in our zerolog exporter (which is used on stage/prod) request id which I can use to correlate all the records. It was not present at all, only trace_id which is unfortunately different because we cannot use it between api and worker pods (it gets closed).

Copy link
Member

Choose a reason for hiding this comment

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

The job_id and job_type should be optional (set only when available) IMO, not to set them from all processes, having them blank may confuse us.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, rebased. All fields are now compared and only added when needed.

@@ -90,6 +90,8 @@ func contextLogger(origCtx context.Context, job *Job) (context.Context, *zerolog
ctx = logging.WithTraceId(ctx, job.TraceID)
ctx = logging.WithEdgeRequestId(ctx, job.EdgeID)
ctx = identity.WithAccountId(ctx, job.AccountID)
ctx = logging.WithJobId(ctx, job.ID.String())
ctx = logging.WithJobType(ctx, job.Type.String())
Copy link
Member Author

Choose a reason for hiding this comment

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

In addition, I add job id and type which is sometimes useful for correlating records. For this I need to put these into context when job starts.

// AccountIdOrNil returns current account model or 0 when not set.
func AccountIdOrNil(ctx context.Context) int64 {
// AccountIdOrZero returns current account model or 0 when not set.
func AccountIdOrZero(ctx context.Context) int64 {
Copy link
Member Author

Choose a reason for hiding this comment

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

This had wrong name, it does not return nil but 0 in fact.

Signed-off-by: Lukáš Zapletal <[email protected]>
Copy link
Member

@ezr-ondrej ezr-ondrej left a comment

Choose a reason for hiding this comment

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

Thanks! 👍

@lzap lzap merged commit c0b85a0 into RHEnVision:main Oct 12, 2023
6 checks passed
@lzap lzap deleted the otel-params branch October 12, 2023 15:47
@ezr-ondrej
Copy link
Member

Ah sorry! I meant to merge it, thanks Lukáš!

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.

2 participants