-
Notifications
You must be signed in to change notification settings - Fork 743
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
Initial metrics integration #290
Initial metrics integration #290
Conversation
Signed-off-by: Sertaç Özercan <sozercan@gmail.com>
ef5930d
to
2fc30aa
Compare
Signed-off-by: Sertaç Özercan <sozercan@gmail.com>
fbc5aa5
to
34a0d07
Compare
Signed-off-by: Sertaç Özercan <sozercan@gmail.com>
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 for doing this! Apologies for the delay, I was heads down on Kubebuilder v2.
I've done a first-pass review though I'd definitely like to take a closer look. I'd also like to get Erik (our metrics expert) to take a look.
pkg/metrics/exporter.go
Outdated
return curMetricsExporter | ||
} | ||
|
||
func SetCurMetricsExporter(e view.Exporter) { |
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.
Is it necessary to separate this from NewMetricsExporter()? It looks like it's called immediately after NewMetricsExporter() anyway, and NewMetricsExporter() returns a cached object.
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.
updated. let me know what you think
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. I'm on the fence between GetMetricsExporter() and NewMetricsExporter() as the behavior changes depending on when this is called. Maybe just MetricsExporter()?
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.
NVM, NewMetricsExporter() always creates a new one. The name is apt.
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.
Style nit picks: avoid "Get" as a prefix, per https://golang.org/doc/effective_go.html#Getters . Also avoid package stutter, per https://golang.org/doc/effective_go.html#package-names
With those in mind, I suggest New() so that you have exporter.New()
. This is coding style, so feel free defer for now.
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.
Hello! My name is Erik and I work with Max on various projects. I have some experience with setting up Prometheus metrics for other projects so he asked me to lend another pair of eyes to this review. I hope that's alright and feel free to ask for any clarification on my comments or suggestions.
pkg/metrics/exporter.go
Outdated
) | ||
|
||
var ( | ||
metricsBackend = flag.String("metricsBackend", "Prometheus", "Backend used for metrics") |
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.
Have you considered exporting to the OpenCensus Agent instead? That would allow your users to choose for themselves if they want Prometheus, Jaeger, Datadog, etc.
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, we can add OC Agent as a follow up to limit the scope of this PR
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.
Sounds good. Since you already have the exporter behind a flag, you could just add "open-census-agent" as another value that you handle. Alternatively you could just always initialize both exporters and configure them on separate ports.
Signed-off-by: Sertaç Özercan <sozercan@users.noreply.github.com>
39b70c4
to
9e68577
Compare
Signed-off-by: Sertaç Özercan <sozercan@users.noreply.github.com>
Signed-off-by: Sertaç Özercan <sozercan@users.noreply.github.com>
Signed-off-by: Sertaç Özercan <sozercan@users.noreply.github.com>
Signed-off-by: Sertaç Özercan <sozercan@gmail.com>
Signed-off-by: Sertaç Özercan <sozercan@gmail.com>
Signed-off-by: Sertaç Özercan <sozercan@gmail.com>
7bd357b
to
84af144
Compare
Signed-off-by: Sertaç Özercan <sozercan@users.noreply.github.com> # Conflicts: # Gopkg.lock # main.go # pkg/audit/manager.go # pkg/webhook/policy.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.
Looks good! I think these are probably my last suggestions for this PR.
pkg/controller/constrainttemplate/constrainttemplate_controller.go
Outdated
Show resolved
Hide resolved
4fe498c
to
ea07168
Compare
Signed-off-by: Sertaç Özercan <sozercan@gmail.com>
ea07168
to
314594f
Compare
@@ -112,6 +137,16 @@ func (r *ReconcileConstraint) Reconcile(request reconcile.Request) (reconcile.Re | |||
return reconcile.Result{}, err | |||
} | |||
|
|||
constraintKindName := strings.Join([]string{instance.GetKind(), instance.GetName()}, "/") |
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.
When I suggested string joining, I was forgetting that
struct {
Kind string
Name string
}
would also work.
Either method is fine with me.
Needs rebase and DCO check failing. |
Signed-off-by: Sertaç Özercan <sozercan@gmail.com>
pkg/webhook/policy.go
Outdated
@@ -118,6 +131,15 @@ func (h *validationHandler) Handle(ctx context.Context, req admission.Request) a | |||
return vResp | |||
} | |||
|
|||
var requestResponse requestResponse |
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.
ping
Signed-off-by: Sertaç Özercan <sozercan@users.noreply.github.com>
447b8c0
to
77aed07
Compare
e2ba39b
to
2fa7a98
Compare
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
0d17c64
to
0d4e561
Compare
972da17
to
a246318
Compare
) Fixes open-policy-agent#346 Signed-off-by: Max Smythe <smythe@google.com>
* Add capability PSP control aspect to library Signed-off-by: Max Smythe <smythe@google.com> * Update PSP library README Signed-off-by: Max Smythe <smythe@google.com> * Fix template kind Signed-off-by: Max Smythe <smythe@google.com> Signed-off-by: Sertaç Özercan <sozercan@gmail.com>
a246318
to
5120010
Compare
Adds initial set up for OpenCensus metrics with Prometheus exporter and implements following metrics to get started:
Audit:
Webhook: (with tags for admission allowed)
Related #157