Skip to content
Snippets Groups Projects
Commit a8b683853e67 authored by Florent Aide's avatar Florent Aide
Browse files

operation groups

parent 868dd61cd410
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
...@@ -110,5 +110,5 @@ ...@@ -110,5 +110,5 @@
operation_groups: operation_groups:
- name: operation_init_prometheus - name: operation_init_prometheus
source: server/operationInitPrometheus.gotmpl source: server/operationInitPrometheus.gotmpl
target: "{{ joinFilePath .Target .ServerPackage .APIPackage (snakize (pascalize .Name)) }}" target: "{{ if .Name }}{{ joinFilePath .Target .ServerPackage .APIPackage (snakize (pascalize .Name)) }}{{ else }}{{ joinFilePath .Target .ServerPackage .Package }}{{ end }}"
file_name: "prometheus.go" file_name: "prometheus_register.go"
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
"api_version": "{{ .Info.Version }}", "api_version": "{{ .Info.Version }}",
}, prometheus.DefaultRegisterer) }, prometheus.DefaultRegisterer)
{{ if gt (len .Tags) 0 }}
{{range .OperationGroups}} {{range .OperationGroups}}
{{ .Name }}.RegisterPrometheus(reg) {{ .Name }}.RegisterPrometheus(reg)
{{- end}} {{- end}}
...@@ -30,4 +31,7 @@ ...@@ -30,4 +31,7 @@
{{range .OperationGroups}} {{range .OperationGroups}}
{{ .Name }}.RegisterPrometheus(reg) {{ .Name }}.RegisterPrometheus(reg)
{{- end}} {{- end}}
{{- else }}
RegisterPrometheus(reg)
{{- end }}
} }
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
) )
func RegisterPrometheus(reg prometheus.Registerer) { func RegisterPrometheus(reg prometheus.Registerer) {
{{- if gt (len .GenOpts.Tags) 0 }}
reg = prometheus.WrapRegistererWith(prometheus.Labels{ reg = prometheus.WrapRegistererWith(prometheus.Labels{
"api_operation_group": "{{ .Name }}", "api_operation_group": "{{ .Name }}",
}, reg) }, reg)
...@@ -16,4 +17,5 @@ ...@@ -16,4 +17,5 @@
reg = prometheus.WrapRegistererWith(prometheus.Labels{ reg = prometheus.WrapRegistererWith(prometheus.Labels{
"api_operation_group": "{{ .Name }}", "api_operation_group": "{{ .Name }}",
}, reg) }, reg)
{{- end }}
...@@ -19,5 +21,5 @@ ...@@ -19,5 +21,5 @@
{{ range .Operations}} {{- range .Operations}}
reg.MustRegister( reg.MustRegister(
{{ camelize .Name }}HandlerDuration, {{ camelize .Name }}HandlerDuration,
{{ camelize .Name }}HandlerInFlight, {{ camelize .Name }}HandlerInFlight,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment