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

v2: logging injected fields not in postcall log #570

Open
galexrt opened this issue Apr 21, 2023 · 3 comments
Open

v2: logging injected fields not in postcall log #570

galexrt opened this issue Apr 21, 2023 · 3 comments

Comments

@galexrt
Copy link

galexrt commented Apr 21, 2023

It seems that when injecting fields the fields are not in, e.g., PostCall, logs.

The reproduction for this seems to simply use InjectFields on a context and pass it on. The fields are in the newCtx but no the "original" ctx in the server.go.

Am I using InjectFields wrong or am I missing something else?

@chancez
Copy link
Contributor

chancez commented Apr 28, 2023

I'm noticing the same just using the example logrus logger, no fields being added, even with all the logging.Options configured.

@chancez
Copy link
Contributor

chancez commented Apr 28, 2023

The examples are wrong. They aren't iterating over the iterator.

instead of

if i.Next() {

it should be:

for i.Next() {

chancez added a commit to chancez/go-grpc-middleware that referenced this issue Jun 6, 2023
johanbrandhorst pushed a commit that referenced this issue Jun 7, 2023
* interceptors: Fix logrus example to iterate over all fields

Fixes #570

Signed-off-by: Chance Zibolski <[email protected]>

* interceptors: Update zap InterceptorLogger to use Iterator properly

The logic in the example is redundant with the logging.Fields Iterator

Signed-off-by: Chance Zibolski <[email protected]>

---------

Signed-off-by: Chance Zibolski <[email protected]>
rahulkhairwar pushed a commit to rahulkhairwar/go-grpc-middleware that referenced this issue Jul 6, 2023
* interceptors: Fix logrus example to iterate over all fields

Fixes grpc-ecosystem#570

Signed-off-by: Chance Zibolski <[email protected]>

* interceptors: Update zap InterceptorLogger to use Iterator properly

The logic in the example is redundant with the logging.Fields Iterator

Signed-off-by: Chance Zibolski <[email protected]>

---------

Signed-off-by: Chance Zibolski <[email protected]>
@jonathanmusto
Copy link

I'm also seeing the same with the zerolog example when using InjectFields to inject the subject from my JWT in my authentication interceptor function.

I can print the value fine via ExtractFields, but it's not output from the FinishCall event.

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

No branches or pull requests

3 participants