-
Notifications
You must be signed in to change notification settings - Fork 173
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
[specific ci=Group23-Vic-Machine-Service] Use trace.NewOperation pattern in vic-machine service API handlers #6563
[specific ci=Group23-Vic-Machine-Service] Use trace.NewOperation pattern in vic-machine service API handlers #6563
Conversation
@@ -77,17 +78,19 @@ func (h *VCHCreate) Handle(params operations.PostTargetTargetVchParams, principa | |||
return operations.NewPostTargetTargetVchDefault(util.StatusCode(err)).WithPayload(&models.Error{Message: err.Error()}) | |||
} | |||
|
|||
validator, err := validateTarget(params.HTTPRequest.Context(), d) | |||
op := trace.NewOperation(params.HTTPRequest.Context(), "vch create handler") | |||
|
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.
Minor, but for consistency with the other files, can we remove this empty line?
@@ -113,17 +116,19 @@ func (h *VCHDatacenterCreate) Handle(params operations.PostTargetTargetDatacente | |||
return operations.NewPostTargetTargetDatacenterDatacenterVchDefault(util.StatusCode(err)).WithPayload(&models.Error{Message: err.Error()}) | |||
} | |||
|
|||
validator, err := validateTarget(params.HTTPRequest.Context(), d) | |||
op := trace.NewOperation(params.HTTPRequest.Context(), "vch create handler") | |||
|
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.
Same here
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.
Sorry I didn't notice this on the first pass, but in my own related task I've noticed a couple of things:
One is that there are calls to functions that take context.Context
and we are passing op.Context
when just op
would work.
The other is that those receiving functions are taking context.Context
when they should be taking trace.Operation
.
We can kill these two birds with one stone by a) passing op
around as op
(vs. op.Context
) and b) refactoring functions in the call chain to accept trace.Operation
instead of context.Context
. This would allow us to use op
when logging messages, which will give us more clarity when debugging in concurrent scenarios.
It's probably outside of the scope of the issue associated with this PR. If it is, just let me know and I'll create a new issue around this that we can tackle later.
@jzt thanks a lot for the comment, makes perfect sense |
LGTM, thanks @AngieCris! |
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.
lgtm
…6563) * trace.NewOperation pattern used for vic-machine service API * whitespace * whitespace * clean up trace.op pattern in API handler functions * bug fix: validateTarget takes in context since used by buildData
…6563) * trace.NewOperation pattern used for vic-machine service API * whitespace * whitespace * clean up trace.op pattern in API handler functions * bug fix: validateTarget takes in context since used by buildData
…6563) * trace.NewOperation pattern used for vic-machine service API * whitespace * whitespace * clean up trace.op pattern in API handler functions * bug fix: validateTarget takes in context since used by buildData
…6563) * trace.NewOperation pattern used for vic-machine service API * whitespace * whitespace * clean up trace.op pattern in API handler functions * bug fix: validateTarget takes in context since used by buildData
…6563) * trace.NewOperation pattern used for vic-machine service API * whitespace * whitespace * clean up trace.op pattern in API handler functions * bug fix: validateTarget takes in context since used by buildData
…mware#6563) * trace.NewOperation pattern used for vic-machine service API * whitespace * whitespace * clean up trace.op pattern in API handler functions * bug fix: validateTarget takes in context since used by buildData
…mware#6563) * trace.NewOperation pattern used for vic-machine service API * whitespace * whitespace * clean up trace.op pattern in API handler functions * bug fix: validateTarget takes in context since used by buildData
…6563) * trace.NewOperation pattern used for vic-machine service API * whitespace * whitespace * clean up trace.op pattern in API handler functions * bug fix: validateTarget takes in context since used by buildData
…6563) * trace.NewOperation pattern used for vic-machine service API * whitespace * whitespace * clean up trace.op pattern in API handler functions * bug fix: validateTarget takes in context since used by buildData
…6563) * trace.NewOperation pattern used for vic-machine service API * whitespace * whitespace * clean up trace.op pattern in API handler functions * bug fix: validateTarget takes in context since used by buildData
…mware#6563) * trace.NewOperation pattern used for vic-machine service API * whitespace * whitespace * clean up trace.op pattern in API handler functions * bug fix: validateTarget takes in context since used by buildData
Fixes #6374