[chore]: enable gofumpt linter in receiver, scraper, semconv and service (#11856)

#### Description

[gofumpt](https://golangci-lint.run/usage/linters/#gofumpt) is a
stricter format than gofmt, while being backwards compatible.

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Co-authored-by: Alex Boten <223565+codeboten@users.noreply.github.com>
This commit is contained in:
Matthieu MOREL 2024-12-12 18:59:26 +01:00 committed by GitHub
parent 81b74822dd
commit 96e860b9cb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
24 changed files with 118 additions and 83 deletions

View File

@ -46,8 +46,10 @@ type Config struct {
Protocols `mapstructure:"protocols"` Protocols `mapstructure:"protocols"`
} }
var _ component.Config = (*Config)(nil) var (
var _ confmap.Unmarshaler = (*Config)(nil) _ component.Config = (*Config)(nil)
_ confmap.Unmarshaler = (*Config)(nil)
)
// Validate checks the receiver configuration is valid // Validate checks the receiver configuration is valid
func (cfg *Config) Validate() error { func (cfg *Config) Validate() error {

View File

@ -55,6 +55,7 @@ func TestExport_NonPermanentErrorConsumer(t *testing.T) {
assert.IsType(t, status.Error(codes.Unknown, ""), err) assert.IsType(t, status.Error(codes.Unknown, ""), err)
assert.Equal(t, pprofileotlp.ExportResponse{}, resp) assert.Equal(t, pprofileotlp.ExportResponse{}, resp)
} }
func TestExport_PermanentErrorConsumer(t *testing.T) { func TestExport_PermanentErrorConsumer(t *testing.T) {
ld := testdata.GenerateProfiles(1) ld := testdata.GenerateProfiles(1)
req := pprofileotlp.NewExportRequestFromProfiles(ld) req := pprofileotlp.NewExportRequestFromProfiles(ld)

View File

@ -58,6 +58,7 @@ func TestExport_NonPermanentErrorConsumer(t *testing.T) {
assert.IsType(t, status.Error(codes.Unknown, ""), err) assert.IsType(t, status.Error(codes.Unknown, ""), err)
assert.Equal(t, ptraceotlp.ExportResponse{}, resp) assert.Equal(t, ptraceotlp.ExportResponse{}, resp)
} }
func TestExport_PermanentErrorConsumer(t *testing.T) { func TestExport_PermanentErrorConsumer(t *testing.T) {
ld := testdata.GenerateTraces(1) ld := testdata.GenerateTraces(1)
req := ptraceotlp.NewExportRequestFromTraces(ld) req := ptraceotlp.NewExportRequestFromTraces(ld)

View File

@ -17,7 +17,7 @@ import (
) )
func TestNewFactory(t *testing.T) { func TestNewFactory(t *testing.T) {
var testType = component.MustNewType("test") testType := component.MustNewType("test")
defaultCfg := struct{}{} defaultCfg := struct{}{}
f := NewFactory( f := NewFactory(
testType, testType,
@ -33,7 +33,7 @@ func TestNewFactory(t *testing.T) {
} }
func TestNewFactoryWithOptions(t *testing.T) { func TestNewFactoryWithOptions(t *testing.T) {
var testType = component.MustNewType("test") testType := component.MustNewType("test")
defaultCfg := struct{}{} defaultCfg := struct{}{}
f := NewFactory( f := NewFactory(
testType, testType,

View File

@ -16,7 +16,7 @@ import (
) )
func TestNewFactoryWithProfiles(t *testing.T) { func TestNewFactoryWithProfiles(t *testing.T) {
var testType = component.MustNewType("test") testType := component.MustNewType("test")
defaultCfg := struct{}{} defaultCfg := struct{}{}
factory := NewFactory( factory := NewFactory(
testType, testType,

View File

@ -271,8 +271,10 @@ func (ds idSet) union(other idSet) (union idSet, duplicates []UniqueIDAttrVal) {
// between the receiver and it next consumer. // between the receiver and it next consumer.
type consumeDecisionFunc func(ids idSet) error type consumeDecisionFunc func(ids idSet) error
var errNonPermanent = errors.New("non permanent error") var (
var errPermanent = errors.New("permanent error") errNonPermanent = errors.New("non permanent error")
errPermanent = errors.New("permanent error")
)
// randomNonPermanentErrorConsumeDecision is a decision function that succeeds approximately // randomNonPermanentErrorConsumeDecision is a decision function that succeeds approximately
// half of the time and fails with a non-permanent error the rest of the time. // half of the time and fails with a non-permanent error the rest of the time.

View File

@ -11,9 +11,7 @@ import (
"go.uber.org/multierr" "go.uber.org/multierr"
) )
var ( var errNonPositiveInterval = errors.New("requires positive value")
errNonPositiveInterval = errors.New("requires positive value")
)
// ControllerConfig defines common settings for a scraper controller // ControllerConfig defines common settings for a scraper controller
// configuration. Scraper controller receivers can embed this struct, instead // configuration. Scraper controller receivers can embed this struct, instead

View File

@ -20,7 +20,8 @@ var testType = component.MustNewType("test")
func nopSettings() Settings { func nopSettings() Settings {
return Settings{ return Settings{
ID: component.NewID(testType), ID: component.NewID(testType),
TelemetrySettings: componenttest.NewNopTelemetrySettings()} TelemetrySettings: componenttest.NewNopTelemetrySettings(),
}
} }
func TestNewFactory(t *testing.T) { func TestNewFactory(t *testing.T) {
@ -35,7 +36,7 @@ func TestNewFactory(t *testing.T) {
} }
func TestNewFactoryWithOptions(t *testing.T) { func TestNewFactoryWithOptions(t *testing.T) {
var testType = component.MustNewType("test") testType := component.MustNewType("test")
defaultCfg := struct{}{} defaultCfg := struct{}{}
f := NewFactory( f := NewFactory(
testType, testType,

View File

@ -15,7 +15,7 @@ import (
func TestAllSemConvFilesAreCrated(t *testing.T) { func TestAllSemConvFilesAreCrated(t *testing.T) {
// Files that have to be present in each semconv package // Files that have to be present in each semconv package
var expectedFiles = []string{"generated_resource.go", "generated_trace.go", "schema.go", "nonstandard.go"} expectedFiles := []string{"generated_resource.go", "generated_trace.go", "schema.go", "nonstandard.go"}
files, err := os.ReadDir(".") files, err := os.ReadDir(".")
require.NoError(t, err) require.NoError(t, err)

View File

@ -21,7 +21,7 @@ import (
) )
func TestConfigValidate(t *testing.T) { func TestConfigValidate(t *testing.T) {
var testCases = []struct { testCases := []struct {
name string // test case name (also file name containing config yaml) name string // test case name (also file name containing config yaml)
cfgFn func() *Config cfgFn func() *Config
expected error expected error
@ -98,11 +98,13 @@ func generateConfig() *Config {
}, },
Metrics: telemetry.MetricsConfig{ Metrics: telemetry.MetricsConfig{
Level: configtelemetry.LevelNormal, Level: configtelemetry.LevelNormal,
Readers: []config.MetricReader{{ Readers: []config.MetricReader{
Pull: &config.PullMetricReader{Exporter: config.MetricExporter{Prometheus: &config.Prometheus{ {
Host: newPtr("localhost"), Pull: &config.PullMetricReader{Exporter: config.MetricExporter{Prometheus: &config.Prometheus{
Port: newPtr(8080), Host: newPtr("localhost"),
}}}}, Port: newPtr(8080),
}}},
},
}, },
}, },
}, },

View File

@ -490,12 +490,15 @@ type nopConnector struct {
func createConnectorTracesToTraces(context.Context, connector.Settings, component.Config, consumer.Traces) (connector.Traces, error) { func createConnectorTracesToTraces(context.Context, connector.Settings, component.Config, consumer.Traces) (connector.Traces, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
func createConnectorTracesToMetrics(context.Context, connector.Settings, component.Config, consumer.Metrics) (connector.Traces, error) { func createConnectorTracesToMetrics(context.Context, connector.Settings, component.Config, consumer.Metrics) (connector.Traces, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
func createConnectorTracesToLogs(context.Context, connector.Settings, component.Config, consumer.Logs) (connector.Traces, error) { func createConnectorTracesToLogs(context.Context, connector.Settings, component.Config, consumer.Logs) (connector.Traces, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
func createConnectorTracesToProfiles(context.Context, connector.Settings, component.Config, consumerprofiles.Profiles) (connector.Traces, error) { func createConnectorTracesToProfiles(context.Context, connector.Settings, component.Config, consumerprofiles.Profiles) (connector.Traces, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
@ -503,12 +506,15 @@ func createConnectorTracesToProfiles(context.Context, connector.Settings, compon
func createConnectorMetricsToTraces(context.Context, connector.Settings, component.Config, consumer.Traces) (connector.Metrics, error) { func createConnectorMetricsToTraces(context.Context, connector.Settings, component.Config, consumer.Traces) (connector.Metrics, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
func createConnectorMetricsToMetrics(context.Context, connector.Settings, component.Config, consumer.Metrics) (connector.Metrics, error) { func createConnectorMetricsToMetrics(context.Context, connector.Settings, component.Config, consumer.Metrics) (connector.Metrics, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
func createConnectorMetricsToLogs(context.Context, connector.Settings, component.Config, consumer.Logs) (connector.Metrics, error) { func createConnectorMetricsToLogs(context.Context, connector.Settings, component.Config, consumer.Logs) (connector.Metrics, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
func createConnectorMetricsToProfiles(context.Context, connector.Settings, component.Config, consumerprofiles.Profiles) (connector.Metrics, error) { func createConnectorMetricsToProfiles(context.Context, connector.Settings, component.Config, consumerprofiles.Profiles) (connector.Metrics, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
@ -516,12 +522,15 @@ func createConnectorMetricsToProfiles(context.Context, connector.Settings, compo
func createConnectorLogsToTraces(context.Context, connector.Settings, component.Config, consumer.Traces) (connector.Logs, error) { func createConnectorLogsToTraces(context.Context, connector.Settings, component.Config, consumer.Traces) (connector.Logs, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
func createConnectorLogsToMetrics(context.Context, connector.Settings, component.Config, consumer.Metrics) (connector.Logs, error) { func createConnectorLogsToMetrics(context.Context, connector.Settings, component.Config, consumer.Metrics) (connector.Logs, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
func createConnectorLogsToLogs(context.Context, connector.Settings, component.Config, consumer.Logs) (connector.Logs, error) { func createConnectorLogsToLogs(context.Context, connector.Settings, component.Config, consumer.Logs) (connector.Logs, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
func createConnectorLogsToProfiles(context.Context, connector.Settings, component.Config, consumerprofiles.Profiles) (connector.Logs, error) { func createConnectorLogsToProfiles(context.Context, connector.Settings, component.Config, consumerprofiles.Profiles) (connector.Logs, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
@ -529,12 +538,15 @@ func createConnectorLogsToProfiles(context.Context, connector.Settings, componen
func createConnectorProfilesToTraces(context.Context, connector.Settings, component.Config, consumer.Traces) (connectorprofiles.Profiles, error) { func createConnectorProfilesToTraces(context.Context, connector.Settings, component.Config, consumer.Traces) (connectorprofiles.Profiles, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
func createConnectorProfilesToMetrics(context.Context, connector.Settings, component.Config, consumer.Metrics) (connectorprofiles.Profiles, error) { func createConnectorProfilesToMetrics(context.Context, connector.Settings, component.Config, consumer.Metrics) (connectorprofiles.Profiles, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
func createConnectorProfilesToLogs(context.Context, connector.Settings, component.Config, consumer.Logs) (connectorprofiles.Profiles, error) { func createConnectorProfilesToLogs(context.Context, connector.Settings, component.Config, consumer.Logs) (connectorprofiles.Profiles, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }
func createConnectorProfilesToProfiles(context.Context, connector.Settings, component.Config, consumerprofiles.Profiles) (connectorprofiles.Profiles, error) { func createConnectorProfilesToProfiles(context.Context, connector.Settings, component.Config, consumerprofiles.Profiles) (connectorprofiles.Profiles, error) {
return nopConnectorInstance, nil return nopConnectorInstance, nil
} }

View File

@ -17,7 +17,7 @@ import (
) )
func TestExtensionBuilder(t *testing.T) { func TestExtensionBuilder(t *testing.T) {
var testType = component.MustNewType("test") testType := component.MustNewType("test")
defaultCfg := struct{}{} defaultCfg := struct{}{}
testID := component.NewID(testType) testID := component.NewID(testType)
unknownID := component.MustNewID("unknown") unknownID := component.MustNewID("unknown")

View File

@ -603,9 +603,11 @@ func connectorStability(f connector.Factory, expType, recType pipeline.Signal) c
return component.StabilityLevelUndefined return component.StabilityLevelUndefined
} }
var _ getExporters = (*HostWrapper)(nil) var (
var _ component.Host = (*HostWrapper)(nil) _ getExporters = (*HostWrapper)(nil)
var _ componentstatus.Reporter = (*HostWrapper)(nil) _ component.Host = (*HostWrapper)(nil)
_ componentstatus.Reporter = (*HostWrapper)(nil)
)
type HostWrapper struct { type HostWrapper struct {
*Host *Host

View File

@ -27,8 +27,10 @@ type getExporters interface {
GetExporters() map[pipeline.Signal]map[component.ID]component.Component GetExporters() map[pipeline.Signal]map[component.ID]component.Component
} }
var _ getExporters = (*Host)(nil) var (
var _ component.Host = (*Host)(nil) _ getExporters = (*Host)(nil)
_ component.Host = (*Host)(nil)
)
type Host struct { type Host struct {
AsyncErrorChannel chan error AsyncErrorChannel chan error
@ -92,10 +94,8 @@ const (
zFeaturePath = "featurez" zFeaturePath = "featurez"
) )
var ( // InfoVar is a singleton instance of the Info struct.
// InfoVar is a singleton instance of the Info struct. var runtimeInfoVar [][2]string
runtimeInfoVar [][2]string
)
func init() { func init() {
runtimeInfoVar = [][2]string{ runtimeInfoVar = [][2]string{

View File

@ -187,6 +187,7 @@ func createExampleProfilesToLogs(_ context.Context, set connector.Settings, _ co
mutatesData: set.ID.Name() == "mutate", mutatesData: set.ID.Name() == "mutate",
}, nil }, nil
} }
func createExampleProfilesToProfiles(_ context.Context, set connector.Settings, _ component.Config, profiles consumerprofiles.Profiles) (connectorprofiles.Profiles, error) { func createExampleProfilesToProfiles(_ context.Context, set connector.Settings, _ component.Config, profiles consumerprofiles.Profiles) (connectorprofiles.Profiles, error) {
return &ExampleConnector{ return &ExampleConnector{
ConsumeProfilesFunc: profiles.ConsumeProfiles, ConsumeProfilesFunc: profiles.ConsumeProfiles,

View File

@ -45,6 +45,7 @@ func createMetricsExporter(context.Context, exporter.Settings, component.Config)
func createLogsExporter(context.Context, exporter.Settings, component.Config) (exporter.Logs, error) { func createLogsExporter(context.Context, exporter.Settings, component.Config) (exporter.Logs, error) {
return &ExampleExporter{}, nil return &ExampleExporter{}, nil
} }
func createProfilesExporter(context.Context, exporter.Settings, component.Config) (exporterprofiles.Profiles, error) { func createProfilesExporter(context.Context, exporter.Settings, component.Config) (exporterprofiles.Profiles, error) {
return &ExampleExporter{}, nil return &ExampleExporter{}, nil
} }

View File

@ -18,7 +18,7 @@ import (
) )
func TestConfigValidate(t *testing.T) { func TestConfigValidate(t *testing.T) {
var testCases = []struct { testCases := []struct {
name string // test case name (also file name containing config yaml) name string // test case name (also file name containing config yaml)
cfgFn func(*testing.T) Config cfgFn func(*testing.T) Config
expected error expected error

View File

@ -139,7 +139,6 @@ func New(ctx context.Context, set Settings, cfg Config) (*Service, error) {
}, },
), ),
) )
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to create SDK: %w", err) return nil, fmt.Errorf("failed to create SDK: %w", err)
} }

View File

@ -58,10 +58,12 @@ type ownMetricsTestCase struct {
expectedLabels map[string]labelValue expectedLabels map[string]labelValue
} }
var testResourceAttrValue = "resource_attr_test_value" // #nosec G101: Potential hardcoded credentials var (
var testInstanceID = "test_instance_id" testResourceAttrValue = "resource_attr_test_value" // #nosec G101: Potential hardcoded credentials
var testServiceVersion = "2022-05-20" testInstanceID = "test_instance_id"
var testServiceName = "test name" testServiceVersion = "2022-05-20"
testServiceName = "test name"
)
// prometheusToOtelConv is used to check that the expected resource labels exist as // prometheusToOtelConv is used to check that the expected resource labels exist as
// part of the otel resource attributes. // part of the otel resource attributes.
@ -71,25 +73,28 @@ var prometheusToOtelConv = map[string]string{
"service_version": "service.version", "service_version": "service.version",
} }
const metricsVersion = "test version" const (
const otelCommand = "otelcoltest" metricsVersion = "test version"
otelCommand = "otelcoltest"
)
func ownMetricsTestCases() []ownMetricsTestCase { func ownMetricsTestCases() []ownMetricsTestCase {
return []ownMetricsTestCase{{ return []ownMetricsTestCase{
name: "no resource", {
userDefinedResource: nil, name: "no resource",
// All labels added to all collector metrics by default are listed below. userDefinedResource: nil,
// These labels are hard coded here in order to avoid inadvertent changes: // All labels added to all collector metrics by default are listed below.
// at this point changing labels should be treated as a breaking changing // These labels are hard coded here in order to avoid inadvertent changes:
// and requires a good justification. The reason is that changes to metric // at this point changing labels should be treated as a breaking changing
// names or labels can break alerting, dashboards, etc that are used to // and requires a good justification. The reason is that changes to metric
// monitor the Collector in production deployments. // names or labels can break alerting, dashboards, etc that are used to
expectedLabels: map[string]labelValue{ // monitor the Collector in production deployments.
"service_instance_id": {state: labelAnyValue}, expectedLabels: map[string]labelValue{
"service_name": {label: otelCommand, state: labelSpecificValue}, "service_instance_id": {state: labelAnyValue},
"service_version": {label: metricsVersion, state: labelSpecificValue}, "service_name": {label: otelCommand, state: labelSpecificValue},
"service_version": {label: metricsVersion, state: labelSpecificValue},
},
}, },
},
{ {
name: "resource with custom attr", name: "resource with custom attr",
userDefinedResource: map[string]*string{ userDefinedResource: map[string]*string{
@ -167,7 +172,8 @@ func ownMetricsTestCases() []ownMetricsTestCase {
"service_name": {label: otelCommand, state: labelSpecificValue}, "service_name": {label: otelCommand, state: labelSpecificValue},
"service_version": {state: labelNotPresent}, "service_version": {state: labelNotPresent},
}, },
}} },
}
} }
var ( var (
@ -397,7 +403,7 @@ func TestExtensionNotificationFailure(t *testing.T) {
set := newNopSettings() set := newNopSettings()
cfg := newNopConfig() cfg := newNopConfig()
var extName = component.MustNewType("configWatcher") extName := component.MustNewType("configWatcher")
configWatcherExtensionFactory := newConfigWatcherExtensionFactory(extName) configWatcherExtensionFactory := newConfigWatcherExtensionFactory(extName)
set.ExtensionsConfigs = map[component.ID]component.Config{component.NewID(extName): configWatcherExtensionFactory.CreateDefaultConfig()} set.ExtensionsConfigs = map[component.ID]component.Config{component.NewID(extName): configWatcherExtensionFactory.CreateDefaultConfig()}
set.ExtensionsFactories = map[component.Type]extension.Factory{extName: configWatcherExtensionFactory} set.ExtensionsFactories = map[component.Type]extension.Factory{extName: configWatcherExtensionFactory}
@ -419,7 +425,7 @@ func TestNilCollectorEffectiveConfig(t *testing.T) {
set.CollectorConf = nil set.CollectorConf = nil
cfg := newNopConfig() cfg := newNopConfig()
var extName = component.MustNewType("configWatcher") extName := component.MustNewType("configWatcher")
configWatcherExtensionFactory := newConfigWatcherExtensionFactory(extName) configWatcherExtensionFactory := newConfigWatcherExtensionFactory(extName)
set.ExtensionsConfigs = map[component.ID]component.Config{component.NewID(extName): configWatcherExtensionFactory.CreateDefaultConfig()} set.ExtensionsConfigs = map[component.ID]component.Config{component.NewID(extName): configWatcherExtensionFactory.CreateDefaultConfig()}
set.ExtensionsFactories = map[component.Type]extension.Factory{extName: configWatcherExtensionFactory} set.ExtensionsFactories = map[component.Type]extension.Factory{extName: configWatcherExtensionFactory}
@ -683,11 +689,13 @@ func newNopConfigPipelineConfigs(pipelineCfgs pipelines.Config) Config {
}, },
Metrics: telemetry.MetricsConfig{ Metrics: telemetry.MetricsConfig{
Level: configtelemetry.LevelBasic, Level: configtelemetry.LevelBasic,
Readers: []config.MetricReader{{ Readers: []config.MetricReader{
Pull: &config.PullMetricReader{Exporter: config.MetricExporter{Prometheus: &config.Prometheus{ {
Host: newPtr("localhost"), Pull: &config.PullMetricReader{Exporter: config.MetricExporter{Prometheus: &config.Prometheus{
Port: newPtr(8888), Host: newPtr("localhost"),
}}}}, Port: newPtr(8888),
}}},
},
}, },
}, },
}, },

View File

@ -117,11 +117,13 @@ func TestConfigValidate(t *testing.T) {
cfg: &Config{ cfg: &Config{
Metrics: MetricsConfig{ Metrics: MetricsConfig{
Level: configtelemetry.LevelBasic, Level: configtelemetry.LevelBasic,
Readers: []config.MetricReader{{ Readers: []config.MetricReader{
Pull: &config.PullMetricReader{Exporter: config.MetricExporter{Prometheus: &config.Prometheus{ {
Host: newPtr("127.0.0.1"), Pull: &config.PullMetricReader{Exporter: config.MetricExporter{Prometheus: &config.Prometheus{
Port: newPtr(3333), Host: newPtr("127.0.0.1"),
}}}}, Port: newPtr(3333),
}}},
},
}, },
}, },
}, },

View File

@ -115,11 +115,13 @@ func createDefaultConfig() component.Config {
}, },
Metrics: MetricsConfig{ Metrics: MetricsConfig{
Level: configtelemetry.LevelNormal, Level: configtelemetry.LevelNormal,
Readers: []config.MetricReader{{ Readers: []config.MetricReader{
Pull: &config.PullMetricReader{Exporter: config.MetricExporter{Prometheus: &config.Prometheus{ {
Host: &metricsHost, Pull: &config.PullMetricReader{Exporter: config.MetricExporter{Prometheus: &config.Prometheus{
Port: newPtr(8888), Host: &metricsHost,
}}}}, Port: newPtr(8888),
}}},
},
}, },
}, },
} }

View File

@ -65,11 +65,13 @@ func TestTelemetryConfiguration(t *testing.T) {
}, },
Metrics: MetricsConfig{ Metrics: MetricsConfig{
Level: configtelemetry.LevelBasic, Level: configtelemetry.LevelBasic,
Readers: []config.MetricReader{{ Readers: []config.MetricReader{
Pull: &config.PullMetricReader{Exporter: config.MetricExporter{Prometheus: &config.Prometheus{ {
Host: newPtr("127.0.0.1"), Pull: &config.PullMetricReader{Exporter: config.MetricExporter{Prometheus: &config.Prometheus{
Port: newPtr(3333), Host: newPtr("127.0.0.1"),
}}}}, Port: newPtr(3333),
}}},
},
}, },
}, },
}, },
@ -83,11 +85,13 @@ func TestTelemetryConfiguration(t *testing.T) {
}, },
Metrics: MetricsConfig{ Metrics: MetricsConfig{
Level: configtelemetry.LevelBasic, Level: configtelemetry.LevelBasic,
Readers: []config.MetricReader{{ Readers: []config.MetricReader{
Pull: &config.PullMetricReader{Exporter: config.MetricExporter{Prometheus: &config.Prometheus{ {
Host: newPtr("127.0.0.1"), Pull: &config.PullMetricReader{Exporter: config.MetricExporter{Prometheus: &config.Prometheus{
Port: newPtr(3333), Host: newPtr("127.0.0.1"),
}}}}, Port: newPtr(3333),
}}},
},
}, },
}, },
}, },

View File

@ -33,7 +33,6 @@ func newLogger(set Settings, cfg Config) (*zap.Logger, log.LoggerProvider, error
} }
logger, err := zapCfg.Build(set.ZapOptions...) logger, err := zapCfg.Build(set.ZapOptions...)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View File

@ -30,9 +30,7 @@ const (
b3Propagator = "b3" b3Propagator = "b3"
) )
var ( var errUnsupportedPropagator = errors.New("unsupported trace propagator")
errUnsupportedPropagator = errors.New("unsupported trace propagator")
)
type noopNoContextTracer struct { type noopNoContextTracer struct {
embedded.Tracer embedded.Tracer