2016-09-28 11:35:15 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
2017-03-15 15:55:30 +00:00
|
|
|
"context"
|
2016-09-28 11:35:15 +00:00
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
2021-06-26 04:46:51 +00:00
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
2016-09-28 11:35:15 +00:00
|
|
|
)
|
|
|
|
|
2021-08-20 15:27:41 +00:00
|
|
|
func (mw metricsMiddleware) NewAppConfig(ctx context.Context, p fleet.AppConfig) (*fleet.AppConfig, error) {
|
2016-09-28 11:35:15 +00:00
|
|
|
var (
|
2021-06-06 22:07:29 +00:00
|
|
|
info *fleet.AppConfig
|
2016-09-28 11:35:15 +00:00
|
|
|
err error
|
|
|
|
)
|
|
|
|
defer func(begin time.Time) {
|
|
|
|
lvs := []string{"method", "NewOrgInfo", "error", fmt.Sprint(err != nil)}
|
|
|
|
mw.requestCount.With(lvs...).Add(1)
|
|
|
|
mw.requestLatency.With(lvs...).Observe(time.Since(begin).Seconds())
|
|
|
|
}(time.Now())
|
2016-11-04 20:44:38 +00:00
|
|
|
info, err = mw.Service.NewAppConfig(ctx, p)
|
2016-09-28 11:35:15 +00:00
|
|
|
return info, err
|
|
|
|
}
|
|
|
|
|
2021-06-06 22:07:29 +00:00
|
|
|
func (mw metricsMiddleware) AppConfig(ctx context.Context) (*fleet.AppConfig, error) {
|
2016-09-28 11:35:15 +00:00
|
|
|
var (
|
2021-06-06 22:07:29 +00:00
|
|
|
info *fleet.AppConfig
|
2016-09-28 11:35:15 +00:00
|
|
|
err error
|
|
|
|
)
|
|
|
|
defer func(begin time.Time) {
|
|
|
|
lvs := []string{"method", "OrgInfo", "error", fmt.Sprint(err != nil)}
|
|
|
|
mw.requestCount.With(lvs...).Add(1)
|
|
|
|
mw.requestLatency.With(lvs...).Observe(time.Since(begin).Seconds())
|
|
|
|
}(time.Now())
|
2016-11-04 20:44:38 +00:00
|
|
|
info, err = mw.Service.AppConfig(ctx)
|
2016-09-28 11:35:15 +00:00
|
|
|
return info, err
|
|
|
|
}
|
|
|
|
|
2021-08-20 15:27:41 +00:00
|
|
|
func (mw metricsMiddleware) ModifyAppConfig(ctx context.Context, p []byte) (*fleet.AppConfig, error) {
|
2016-09-28 11:35:15 +00:00
|
|
|
var (
|
2021-06-06 22:07:29 +00:00
|
|
|
info *fleet.AppConfig
|
2016-09-28 11:35:15 +00:00
|
|
|
err error
|
|
|
|
)
|
|
|
|
defer func(begin time.Time) {
|
|
|
|
lvs := []string{"method", "ModifyOrgInfo", "error", fmt.Sprint(err != nil)}
|
|
|
|
mw.requestCount.With(lvs...).Add(1)
|
|
|
|
mw.requestLatency.With(lvs...).Observe(time.Since(begin).Seconds())
|
|
|
|
}(time.Now())
|
2016-11-04 20:44:38 +00:00
|
|
|
info, err = mw.Service.ModifyAppConfig(ctx, p)
|
2016-09-28 11:35:15 +00:00
|
|
|
return info, err
|
|
|
|
}
|