-
Notifications
You must be signed in to change notification settings - Fork 148
Add instrumentation code for SSO #1003
base: master
Are you sure you want to change the base?
Conversation
New Gopher here so feel free to roast me on styling. It would be greatly appreciated to describe why we follow specific guidelines |
singleSignOn sso.SingleSignOn, | ||
webFrontendURL string, | ||
) router.Handle { | ||
return func(w http.ResponseWriter, r *http.Request, params router.Params) { | ||
i := instrumentationFactory.NewRequest() |
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 := instrumentationFactory.NewRequest() | |
i := instrumentationFactory.NewHTTP(r) |
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.
We are tracking HTTP traffic 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.
This is to prepare for distributed tracing in the future
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.
The main difference that I see is that its extracting the location from the HTTP call, is this true?
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.
@Ashakibp Exactly!
@@ -10,10 +11,14 @@ import ( | |||
|
|||
// SSOSignIn redirects user to the sign in page. | |||
func SSOSignIn( | |||
instrumentationFactory request.InstrumentationFactory, |
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.
instrumentationFactory request.InstrumentationFactory, | |
instrumentationFactory request.SSOInstrumentationFactory, |
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.
Can you explain this a bit further, are we trying to compose an instrumentationFactory
within an SSOInstrumentationFactory
?
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.
@Ashakibp Nope. SSO sign in only depends on SSOInstrumentationFactory
, which constructs instrumentation.SSO
singleSignOn sso.SingleSignOn, | ||
webFrontendURL string, | ||
) router.Handle { | ||
return func(w http.ResponseWriter, r *http.Request, params router.Params) { | ||
i := instrumentationFactory.NewRequest() | ||
i.SSOSignIn(singleSignOn.GetMetricName()) | ||
|
||
token := getToken(params) | ||
if singleSignOn.IsSignedIn(token) { |
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.
We need to invoke the instructation method here to actually track data.
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.
Also after this code path, we track the user is redirected to the generated sign in link at line 27.
singleSignOn sso.SingleSignOn, | ||
webFrontendURL string, | ||
) router.Handle { | ||
return func(w http.ResponseWriter, r *http.Request, params router.Params) { | ||
i := instrumentationFactory.NewRequest() | ||
i.SSOSignIn(singleSignOn.GetMetricName()) |
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.
The correct InstrumentationFactory
can be injected inside the caller of this function.
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.
Instrumentation code should be decoupled from SSO so that we can change them independently
…e-to-all-routes' into ashakibp-Add-instrumentation-code-to-all-routes
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!
@@ -10,10 +11,14 @@ import ( | |||
|
|||
// SSOSignIn redirects user to the sign in page. | |||
func SSOSignIn( | |||
instrumentationFactory request.InstrumentationFactory, |
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.
@Ashakibp Nope. SSO sign in only depends on SSOInstrumentationFactory
, which constructs instrumentation.SSO
singleSignOn sso.SingleSignOn, | ||
webFrontendURL string, | ||
) router.Handle { | ||
return func(w http.ResponseWriter, r *http.Request, params router.Params) { | ||
i := instrumentationFactory.NewRequest() |
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.
@Ashakibp Exactly!
…e-to-all-routes' into ashakibp-Add-instrumentation-code-to-all-routes
…e-to-all-routes' into ashakibp-Add-instrumentation-code-to-all-routes
Current Behavior
Currently we do not fire off metrics for SSOs, the objective of this PR is to fire off events whenever someone uses SSO and partition it by provider.
For #695
Description
We used a base instrumentation struct and then an implementation for every provider to make it easier for metric names to be traced down. The factory method will automatically pull the correct provider.