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

add correlation ids #20

Merged
merged 19 commits into from
Feb 17, 2022
Merged

add correlation ids #20

merged 19 commits into from
Feb 17, 2022

Conversation

PrathyushaLakkireddy
Copy link
Contributor

@PrathyushaLakkireddy PrathyushaLakkireddy commented Jan 3, 2022

@sgerogia
Copy link
Contributor

sgerogia commented Jan 5, 2022

If you have not seen it, @gsora has left a relevant comment in the issue.

Please replace the existing generated error id to be the int_correlation_id

@0xmuralik
Copy link
Contributor

0xmuralik commented Jan 6, 2022

If you have not seen it, @gsora has left a relevant comment in the issue.

Please replace the existing generated error id to be the int_correlation_id

Yup! Added that in the Deps.WriteError function here.

@sgerogia sgerogia force-pushed the prathyusha/correlation branch from 1b451c7 to 3197f33 Compare January 31, 2022 11:58
@sgerogia sgerogia marked this pull request as ready for review February 10, 2022 21:01
@sgerogia
Copy link
Contributor

@SpideyPool192 I do not think that this merge automatically created a release
Can you create a minor release of emeris-utils and update the code here?

This needs to be reviewed and merged today if possible

api/router/correlation.go Outdated Show resolved Hide resolved
@0xmuralik 0xmuralik requested a review from sgerogia February 11, 2022 10:27
Copy link
Contributor

@DeshErBojhaa DeshErBojhaa left a comment

Choose a reason for hiding this comment

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

Hi, can you write in short why you're panicking in the router instead of writing the error to log (even to the response maybe).

Also please shortly explain the logic behind the panic in deps.go

api/router/correlation_test.go Outdated Show resolved Hide resolved
api/router/correlation_test.go Show resolved Hide resolved
api/router/correlation_test.go Outdated Show resolved Hide resolved
api/router/correlation_test.go Outdated Show resolved Hide resolved
api/router/correlation_test.go Outdated Show resolved Hide resolved
if err != nil && r.l == nil {
panic("cant get logger from context")
}
r.l = l
Copy link
Contributor

Choose a reason for hiding this comment

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

is this safe to do? When multiple API calls arrive aren't them executed concurrently and sharing the same router object?

even it this was safe looks like an anti-pattern to me: request-related stuff should stay inside request's context. What's this r.l used for anyway?

Copy link
Contributor

Choose a reason for hiding this comment

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

We set a modified logger to the context in the CorrelationIDMiddleware function. Intention is to use this logger everywhere. As the api server uses the logger from router, I'm changing the router logger (r.l) to use the logger from context.

Copy link
Contributor

@Pitasi Pitasi Feb 14, 2022

Choose a reason for hiding this comment

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

We set a modified logger to the context in the CorrelationIDMiddleware function. Intention is to use this logger everywhere.

that's ok

As the api server uses the logger from router, I'm changing the router logger (r.l) to use the logger from context.

I don't get why we need a router logger (+ I'm still concerned about concurrency safety)

Copy link
Contributor

Choose a reason for hiding this comment

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

@0xmuralik
Copy link
Contributor

Hi, can you write in short why you're panicking in the router instead of writing the error to log (even to the response maybe).

Also please shortly explain the logic behind the panic in deps.go

Hi, can you write in short why you're panicking in the router instead of writing the error to log (even to the response maybe).

Also please shortly explain the logic behind the panic in deps.go

The issue suggests that we use a logger from the context if it doesn't exist check if there is another logger (to the router) provided. If there is no logger found we panic.

In deps.go we are trying to replace the error id with the internal correlation id which we created earlier. Hence, we try to find it in the context and panic if not found.

Copy link
Contributor

@DeshErBojhaa DeshErBojhaa left a comment

Choose a reason for hiding this comment

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

LGTM!

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.

8 participants