-
Notifications
You must be signed in to change notification settings - Fork 222
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
SB-10000: Adding app- and pipeline-ids to server #290
Conversation
server/middleware.go
Outdated
if requestID == "" { | ||
requestID, err = idGen.ID() | ||
if err != nil { | ||
// TODO gah, what then? I have good mind to eliminate this err altogether |
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 think this is fine, we don't want to set the request ID to empty string, better to not set it at all.
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.
Agreed, but a) I shouldn't have let this TODO slip into the commit, and b) I think of this code as being important but not critical, and the idea that something that isn't critical blitzing stuff that is annoys me. In this case, this err is here solely because the UUID generator.
If you think this is fine I'll remove the TODO and leave the return.
I had a quick look at the code and it's not clear to me why this needs to live in gixmo.
|
@oliver-nyt thanks! I'll answer inline:
Thanks! That'd definitely be better than the one-off context stuffing in my handler. I assume that'll have to be called after the ID handler runs.
For more info, take a look at the parent ticket for SB-10000: https://jira.nyt.net/browse/SB-9987 As for OpenCensus (and OpenTracing), I looked at CloudTrace (CT) as a way to correlate all the reqs across all our services and it only seemed to want to log the right values (specifically, the trace ID) when CT actually sampled a req for tracing. (In other platforms -- Solarwinds', for instance -- you can use a trace ID whether or not tracing actually sampled the call, but not here.) I wasn't aware that Kit had the OC/OT stuff embedded. I'll take a look.
Fixed! |
server/middleware_test.go
Outdated
} | ||
|
||
for _, test := range tests { | ||
r, err := http.NewRequest("GET", "", nil) |
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.
for table driven test stuff each test case should be in a t.run, ie:
func TestPipelineIDHandler(t *testing.T) {
tests := []struct {
desc, prev, next, expected string
}{
{"new", "", "roger", "roger"},
{"existing", "roger", "roderick", "roger|roderick"},
{"chained", "roger|roderick", "brian", "roger|roderick|brian"},
}
for _, test := range tests {
t.Run(test.desc, func(t *testing.T) {
r, err := http.NewRequest("GET", "", nil)
...
})
}
}
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! fixed.
@oliver-nyt , @jonsabados & I did some research on your OpenCensus (and OpenTelemetry) suggestion, and it looks like the code needed to do this is on a wish list, not in a library: census-instrumentation/opencensus-go#950 At Solarwinds (prev. employer) we could create a trace ID whether or not the trace was actually sampled by a collector, and that trace ID would be logged to every apps' logs; I could not find a way to do that with CloudTrace or with OC/OT. But we may not even want to: we have a couple of fan-out steps in our pipeline and would like to differentiate between requests in the target of the fan-out. We won't be able to if we're using a CT/OC/OT trace ID. Pls. let me know if you have other thoughts on this! |
I still think this shouldn't be in Gizmo as it's not needed/used by Gizmo itself. |
Moving this change to another repo |
Helix jira ticket SB-10000: https://jira.nyt.net/browse/SB-10000
Pull Request Checklist
Description
Adding two types of IDs to gizmo:
To support these, middleware has been added that, in both cases, sets the
X-Request-ID
header (in the case of application IDs, only if the header is not present) to the request and response, and writes it to the context.Dependencies were updated as a part of running
make test
(as far as I can tell.) Happy to revert thego.mod
andgo.sum
files if needs be.