-
Notifications
You must be signed in to change notification settings - Fork 22
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
Conversation
if accountId != 0 { | ||
t = t.Int64("account_id", accountId) | ||
} | ||
|
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 👍
Ah sorry! I meant to merge it, thanks Lukáš! |
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.