File tree Expand file tree Collapse file tree 3 files changed +13
-21
lines changed
exporter/prometheusexporter Expand file tree Collapse file tree 3 files changed +13
-21
lines changed Original file line number Diff line number Diff line change @@ -19,34 +19,26 @@ import (
1919 "go.opentelemetry.io/collector/config/configmodels"
2020)
2121
22- // NopHost mocks a receiver.ReceiverHost for test purposes.
23- type NopHost struct {
24- }
22+ // nopHost mocks a receiver.ReceiverHost for test purposes.
23+ type nopHost struct {}
2524
26- var _ component.Host = ( * NopHost )( nil )
25+ var nopHostInstance component.Host = & nopHost {}
2726
28- // NewNopHost returns a new instance of NopHost with proper defaults for most
29- // tests.
27+ // NewNopHost returns a new instance of nopHost with proper defaults for most tests.
3028func NewNopHost () component.Host {
31- return & NopHost {}
29+ return nopHostInstance
3230}
3331
34- // ReportFatalError is used to report to the host that the receiver encountered
35- // a fatal error (i.e.: an error that the instance can't recover from) after
36- // its start function has already returned.
37- func (nh * NopHost ) ReportFatalError (_ error ) {
38- // Do nothing for now.
39- }
32+ func (nh * nopHost ) ReportFatalError (_ error ) {}
4033
41- // GetFactory of the specified kind. Returns the factory for a component type.
42- func (nh * NopHost ) GetFactory (_ component.Kind , _ configmodels.Type ) component.Factory {
34+ func (nh * nopHost ) GetFactory (_ component.Kind , _ configmodels.Type ) component.Factory {
4335 return nil
4436}
4537
46- func (nh * NopHost ) GetExtensions () map [configmodels.Extension ]component.ServiceExtension {
38+ func (nh * nopHost ) GetExtensions () map [configmodels.Extension ]component.ServiceExtension {
4739 return nil
4840}
4941
50- func (nh * NopHost ) GetExporters () map [configmodels.DataType ]map [configmodels.Exporter ]component.Exporter {
42+ func (nh * nopHost ) GetExporters () map [configmodels.DataType ]map [configmodels.Exporter ]component.Exporter {
5143 return nil
5244}
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ import (
2727func TestNewNopHost (t * testing.T ) {
2828 nh := NewNopHost ()
2929 require .NotNil (t , nh )
30- require .IsType (t , & NopHost {}, nh )
30+ require .IsType (t , & nopHost {}, nh )
3131
3232 nh .ReportFatalError (errors .New ("TestError" ))
3333 assert .Nil (t , nh .GetExporters ())
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ func TestPrometheusExporter(t *testing.T) {
8080 }
8181
8282 assert .NotNil (t , exp )
83- err = exp .Start (context .Background (), & componenttest.NopHost {} )
83+ err = exp .Start (context .Background (), componenttest .NewNopHost () )
8484
8585 if tt .wantStartErr != "" {
8686 require .Error (t , err )
@@ -118,7 +118,7 @@ func TestPrometheusExporter_endToEnd(t *testing.T) {
118118
119119 assert .NotNil (t , exp )
120120
121- require .NoError (t , exp .Start (context .Background (), & componenttest.NopHost {} ))
121+ require .NoError (t , exp .Start (context .Background (), componenttest .NewNopHost () ))
122122
123123 // Should accumulate multiple metrics
124124 md := internaldata .OCToMetrics (internaldata.MetricsData {Metrics : metricBuilder (128 , "metric_1_" )})
@@ -193,7 +193,7 @@ func TestPrometheusExporter_endToEndWithTimestamps(t *testing.T) {
193193 })
194194
195195 assert .NotNil (t , exp )
196- require .NoError (t , exp .Start (context .Background (), & componenttest.NopHost {} ))
196+ require .NoError (t , exp .Start (context .Background (), componenttest .NewNopHost () ))
197197
198198 // Should accumulate multiple metrics
199199
You can’t perform that action at this time.
0 commit comments