File: tracker_options.go

package info (click to toggle)
golang-gitlab-gitlab-org-labkit 1.17.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,092 kB
  • sloc: sh: 210; javascript: 49; makefile: 4
file content (51 lines) | stat: -rw-r--r-- 1,205 bytes parent folder | download | duplicates (4)
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
package errortracking

// The configuration for Tracker.
type trackerConfig struct {
	sentryDSN         string
	version           string
	sentryEnvironment string
	loggerName        string
}

// TrackerOption will configure a Tracker.
type TrackerOption func(*trackerConfig)

func applyTrackerOptions(opts []TrackerOption) trackerConfig {
	config := trackerConfig{}

	for _, v := range opts {
		v(&config)
	}

	return config
}

// WithSentryDSN sets the sentry data source name.
func WithSentryDSN(sentryDSN string) TrackerOption {
	return func(config *trackerConfig) {
		config.sentryDSN = sentryDSN
	}
}

// WithVersion is used to configure the version of the service
// that is currently running.
func WithVersion(version string) TrackerOption {
	return func(config *trackerConfig) {
		config.version = version
	}
}

// WithSentryEnvironment sets the sentry environment.
func WithSentryEnvironment(sentryEnvironment string) TrackerOption {
	return func(config *trackerConfig) {
		config.sentryEnvironment = sentryEnvironment
	}
}

// WithLoggerName sets the logger name.
func WithLoggerName(loggerName string) TrackerOption {
	return func(config *trackerConfig) {
		config.loggerName = loggerName
	}
}