-
Notifications
You must be signed in to change notification settings - Fork 103
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
populate device id attributes to buffered logs before turning on shipping #1472
populate device id attributes to buffered logs before turning on shipping #1472
Conversation
James-Pickett
commented
Nov 22, 2023
•
edited
Loading
edited
- log shipper waits until it has all device id attributes before shipping
- populates buffered logs with device id attributes before sending
} else { | ||
ls.shippingLogger = log.With(ls.shippingLogger, "k2_device_id", string(deviceId)) | ||
additionalSlogAttrs = append(additionalSlogAttrs, slog.String("k2_device_id", string(deviceId))) | ||
for _, key := range []string{"device_id", "munemo", "organization_id", "serial_number"} { |
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 drops the k2
prefix from some of the attributes, is that okay?
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.
I don't feel strongly.
I often like k2
because it makes it very clear what I'm looking at. But I'm not sure we need that disambiguation
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.
Some nits/questions, but I think this is mostly okay.
If I understand correctly, the way this works is to have the log shipper keep a set of attributes it uses to apply to things shipped through it.
And when it receives a Ping
, it does two things:
- it rebuilds the saved shipper with the new attributes
- it iterates over the logs pending and updates them
That seems reasonable
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.
looks great 🔥
pkg/log/logshipper/logshipper.go
Outdated
deviceInfo[key] = string(v) | ||
} | ||
|
||
ls.shippingLogger = log.With(ls.shippingLogger, deviceInfo) |
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.
Okay, I'm somewhat wrong -- you have to splat it out. Calling like this has the key set to deviceInfo
and the value nil. Take a look at https://go.dev/play/p/bJMUWw28Ekp (Or building the array as you go)
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.
ahh, good catch, updated