aboutsummaryrefslogtreecommitdiffstats
path: root/library/go/core/metrics/mock/registry_opts.go
blob: 1cc1c3970d093358ded7bf5cfe2bd8e99a4154f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package mock

import (
	"github.com/ydb-platform/ydb/library/go/core/metrics/internal/pkg/registryutil"
)

type RegistryOpts struct {
	Separator                  rune
	Prefix                     string
	Tags                       map[string]string
	AllowLoadRegisteredMetrics bool
}

// NewRegistryOpts returns new initialized instance of RegistryOpts
func NewRegistryOpts() *RegistryOpts {
	return &RegistryOpts{
		Separator: '.',
		Tags:      make(map[string]string),
	}
}

// SetTags overrides existing tags
func (o *RegistryOpts) SetTags(tags map[string]string) *RegistryOpts {
	o.Tags = tags
	return o
}

// AddTags merges given tags with existing
func (o *RegistryOpts) AddTags(tags map[string]string) *RegistryOpts {
	for k, v := range tags {
		o.Tags[k] = v
	}
	return o
}

// SetPrefix overrides existing prefix
func (o *RegistryOpts) SetPrefix(prefix string) *RegistryOpts {
	o.Prefix = prefix
	return o
}

// AppendPrefix adds given prefix as postfix to existing using separator
func (o *RegistryOpts) AppendPrefix(prefix string) *RegistryOpts {
	o.Prefix = registryutil.BuildFQName(string(o.Separator), o.Prefix, prefix)
	return o
}

// SetSeparator overrides existing separator
func (o *RegistryOpts) SetSeparator(separator rune) *RegistryOpts {
	o.Separator = separator
	return o
}