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

use knapsack and slogger in kolide service #1436

Merged
merged 15 commits into from
Nov 6, 2023

Conversation

James-Pickett
Copy link
Contributor

No description provided.

cmd/grpc.ext/grpc.go Outdated Show resolved Hide resolved
cmd/grpc.ext/grpc.go Outdated Show resolved Hide resolved
cmd/grpc.ext/grpc.go Outdated Show resolved Hide resolved
pkg/service/client_grpc.go Show resolved Hide resolved
)

type Middleware func(KolideService) KolideService

func LoggingMiddleware(logger log.Logger) Middleware {
func LoggingMiddleware(k types.Knapsack) Middleware {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could just pass slogger, but I think this is fine too.

pkg/log/multislogger/multislogger.go Outdated Show resolved Hide resolved
pkg/service/tls.go Outdated Show resolved Hide resolved
logger.Log(
"method", "PublishResults",

mw.knapsack.Slogger().Log(ctx, levelForError(err), "publish results",
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not quite right. -- the first argument should be the message from line 189. The method should remain a KV pair. (I think true for all of these)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I've added the message val as the msg for the logs.

Should we drop the kvp with the message key (now it would be msg) ... I don't think anything should rely on log output, but I have an urge to leave it in to maintain parity.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's no value in duplicating the message KV. It's fine that it changed from message to msg. (I just don't want to have method become msg which is semantically different)

eg: You should strike message.

@James-Pickett James-Pickett marked this pull request as ready for review November 3, 2023 18:42
zackattack01
zackattack01 previously approved these changes Nov 3, 2023
Copy link
Contributor

@zackattack01 zackattack01 left a comment

Choose a reason for hiding this comment

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

nice! 🔥

RebeccaMahany
RebeccaMahany previously approved these changes Nov 3, 2023
Copy link
Contributor

@RebeccaMahany RebeccaMahany left a comment

Choose a reason for hiding this comment

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

LGTM, my suggestion is optional

}
logger.Log(

mw.knapsack.Slogger().Log(ctx, levelForError(err), message,
Copy link
Contributor

Choose a reason for hiding this comment

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

For this one and PublishResults, it looks like the message is empty (at least in the successful case) -- do we want to do "publish logs" and "publish results" for the log message instead, like how you've got it for e.g. RequestConfig?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not quite sure what is correct. Possibly using "publish logs" when message is empty. see previous conversation on subject #1436 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

So these cases are a successful completion of the thing, right? And we have method there. So maybe just "success"?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with success or publish logs!

Copy link
Contributor

Choose a reason for hiding this comment

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

The case on "publish logs" feels wrong. Could be "published logs" or even "published"

Consider something like scoping the view down to just showing the publish logs method.

Copy link
Contributor Author

@James-Pickett James-Pickett Nov 6, 2023

Choose a reason for hiding this comment

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

I've updated all the publish methods to either have success or* failure as the message

Copy link
Contributor

@directionless directionless left a comment

Choose a reason for hiding this comment

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

Good enough!

@James-Pickett James-Pickett added this pull request to the merge queue Nov 6, 2023
Merged via the queue into kolide:main with commit 7046f38 Nov 6, 2023
26 checks passed
@James-Pickett James-Pickett deleted the james/slog-conversion branch November 6, 2023 21:36
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.

4 participants