@@ -50,8 +50,8 @@ type Exporter struct {
50
50
var _ export.Exporter = & Exporter {}
51
51
var _ http.Handler = & Exporter {}
52
52
53
- // Options is a set of options for the tally reporter.
54
- type Options struct {
53
+ // Config is a set of configs for the tally reporter.
54
+ type Config struct {
55
55
// Registry is the prometheus registry that will be used as the default Registerer and
56
56
// Gatherer if these are not specified.
57
57
//
@@ -81,51 +81,51 @@ type Options struct {
81
81
82
82
// NewRawExporter returns a new prometheus exporter for prometheus metrics
83
83
// for use in a pipeline.
84
- func NewRawExporter (opts Options ) (* Exporter , error ) {
85
- if opts .Registry == nil {
86
- opts .Registry = prometheus .NewRegistry ()
84
+ func NewRawExporter (config Config ) (* Exporter , error ) {
85
+ if config .Registry == nil {
86
+ config .Registry = prometheus .NewRegistry ()
87
87
}
88
88
89
- if opts .Registerer == nil {
90
- opts .Registerer = opts .Registry
89
+ if config .Registerer == nil {
90
+ config .Registerer = config .Registry
91
91
}
92
92
93
- if opts .Gatherer == nil {
94
- opts .Gatherer = opts .Registry
93
+ if config .Gatherer == nil {
94
+ config .Gatherer = config .Registry
95
95
}
96
96
97
- if opts .OnError == nil {
98
- opts .OnError = func (err error ) {
97
+ if config .OnError == nil {
98
+ config .OnError = func (err error ) {
99
99
fmt .Println (err .Error ())
100
100
}
101
101
}
102
102
103
103
e := & Exporter {
104
- handler : promhttp .HandlerFor (opts .Gatherer , promhttp.HandlerOpts {}),
105
- registerer : opts .Registerer ,
106
- gatherer : opts .Gatherer ,
107
- defaultSummaryQuantiles : opts .DefaultSummaryQuantiles ,
104
+ handler : promhttp .HandlerFor (config .Gatherer , promhttp.HandlerOpts {}),
105
+ registerer : config .Registerer ,
106
+ gatherer : config .Gatherer ,
107
+ defaultSummaryQuantiles : config .DefaultSummaryQuantiles ,
108
108
}
109
109
110
110
c := newCollector (e )
111
- if err := opts .Registerer .Register (c ); err != nil {
112
- opts .OnError (fmt .Errorf ("cannot register the collector: %w" , err ))
111
+ if err := config .Registerer .Register (c ); err != nil {
112
+ config .OnError (fmt .Errorf ("cannot register the collector: %w" , err ))
113
113
}
114
114
115
115
return e , nil
116
116
}
117
117
118
118
// InstallNewPipeline instantiates a NewExportPipeline and registers it globally.
119
119
// Typically called as:
120
- // pipeline, hf, err := prometheus.InstallNewPipeline(prometheus.Options {...})
120
+ // pipeline, hf, err := prometheus.InstallNewPipeline(prometheus.Config {...})
121
121
// if err != nil {
122
122
// ...
123
123
// }
124
124
// http.HandleFunc("/metrics", hf)
125
125
// defer pipeline.Stop()
126
126
// ... Done
127
- func InstallNewPipeline (options Options ) (* push.Controller , http.HandlerFunc , error ) {
128
- controller , hf , err := NewExportPipeline (options )
127
+ func InstallNewPipeline (config Config ) (* push.Controller , http.HandlerFunc , error ) {
128
+ controller , hf , err := NewExportPipeline (config )
129
129
if err != nil {
130
130
return controller , hf , err
131
131
}
@@ -135,9 +135,9 @@ func InstallNewPipeline(options Options) (*push.Controller, http.HandlerFunc, er
135
135
136
136
// NewExportPipeline sets up a complete export pipeline with the recommended setup,
137
137
// chaining a NewRawExporter into the recommended selectors and batchers.
138
- func NewExportPipeline (options Options ) (* push.Controller , http.HandlerFunc , error ) {
138
+ func NewExportPipeline (config Config ) (* push.Controller , http.HandlerFunc , error ) {
139
139
selector := simple .NewWithExactMeasure ()
140
- exporter , err := NewRawExporter (options )
140
+ exporter , err := NewRawExporter (config )
141
141
if err != nil {
142
142
return nil , nil , err
143
143
}
0 commit comments