Skip to content

Commit 3526390

Browse files
authored
Merge branch 'main' into mtls
2 parents 8bf36b0 + fc535d1 commit 3526390

File tree

185 files changed

+2888
-1500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+2888
-1500
lines changed

extension/agenthealth/factory.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ func createDefaultConfig() component.Config {
3030
}
3131
}
3232

33-
func createExtension(_ context.Context, settings extension.CreateSettings, cfg component.Config) (extension.Extension, error) {
33+
func createExtension(_ context.Context, settings extension.Settings, cfg component.Config) (extension.Extension, error) {
3434
return NewAgentHealth(settings.Logger, cfg.(*Config)), nil
3535
}

extension/agenthealth/factory_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ func TestCreateDefaultConfig(t *testing.T) {
1818
assert.NoError(t, componenttest.CheckConfigStruct(cfg))
1919
}
2020

21-
func TestCreateExtension(t *testing.T) {
21+
func TestCreate(t *testing.T) {
2222
cfg := &Config{}
23-
got, err := NewFactory().CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg)
23+
got, err := NewFactory().Create(context.Background(), extensiontest.NewNopSettings(), cfg)
2424
assert.NoError(t, err)
2525
assert.NotNil(t, got)
2626
}

extension/agenthealth/handler/useragent/useragent_test.go

+11-12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/stretchr/testify/assert"
1515
"go.opentelemetry.io/collector/component"
1616
"go.opentelemetry.io/collector/otelcol"
17+
"go.opentelemetry.io/collector/pipeline"
1718
"go.opentelemetry.io/collector/service"
1819
"go.opentelemetry.io/collector/service/pipelines"
1920

@@ -23,16 +24,15 @@ import (
2324
)
2425

2526
func TestSetComponents(t *testing.T) {
26-
metricsType, _ := component.NewType("metrics")
2727
telegrafCPUType, _ := component.NewType(adapter.TelegrafPrefix + "cpu")
2828
prometheusType, _ := component.NewType("prometheus")
2929
batchType, _ := component.NewType("batch")
3030
filterType, _ := component.NewType("filter")
3131
cloudwatchType, _ := component.NewType("cloudwatch")
3232
otelCfg := &otelcol.Config{
3333
Service: service.Config{
34-
Pipelines: map[component.ID]*pipelines.PipelineConfig{
35-
component.NewID(metricsType): {
34+
Pipelines: map[pipeline.ID]*pipelines.PipelineConfig{
35+
pipeline.NewID(pipeline.SignalMetrics): {
3636
Receivers: []component.ID{
3737
component.NewID(telegrafCPUType),
3838
component.NewID(prometheusType),
@@ -108,13 +108,12 @@ func TestAlternateUserAgent(t *testing.T) {
108108
}
109109

110110
func TestEmf(t *testing.T) {
111-
metricsType, _ := component.NewType("metrics")
112111
nopType, _ := component.NewType("nop")
113112
awsEMFType, _ := component.NewType("awsemf")
114113
otelCfg := &otelcol.Config{
115114
Service: service.Config{
116-
Pipelines: map[component.ID]*pipelines.PipelineConfig{
117-
component.NewID(metricsType): {
115+
Pipelines: map[pipeline.ID]*pipelines.PipelineConfig{
116+
pipeline.NewID(pipeline.SignalMetrics): {
118117
Receivers: []component.ID{
119118
component.NewID(nopType),
120119
},
@@ -142,8 +141,8 @@ func TestEmf(t *testing.T) {
142141
func TestMissingEmfExporterConfig(t *testing.T) {
143142
otelCfg := &otelcol.Config{
144143
Service: service.Config{
145-
Pipelines: map[component.ID]*pipelines.PipelineConfig{
146-
component.NewID(component.MustNewType("metrics")): {
144+
Pipelines: map[pipeline.ID]*pipelines.PipelineConfig{
145+
pipeline.NewID(pipeline.SignalMetrics): {
147146
Receivers: []component.ID{
148147
component.NewID(component.MustNewType("nop")),
149148
},
@@ -170,18 +169,18 @@ func TestJmx(t *testing.T) {
170169
jmxOther := "jmxOther"
171170
nopType, _ := component.NewType("nop")
172171
jmxType, _ := component.NewType(jmx)
173-
pipelineType, _ := component.NewType("pipeline")
174-
pipelineTypeOther, _ := component.NewType("pipelineOther")
172+
pipelineID := pipeline.NewIDWithName(pipeline.SignalMetrics, "pipeline")
173+
pipelineIDOther := pipeline.NewIDWithName(pipeline.SignalMetrics, "pipelineOther")
175174
pls := make(pipelines.Config)
176-
pls[component.NewID(pipelineType)] = &pipelines.PipelineConfig{
175+
pls[pipelineID] = &pipelines.PipelineConfig{
177176
Receivers: []component.ID{
178177
component.NewIDWithName(jmxType, jmx),
179178
},
180179
Exporters: []component.ID{
181180
component.NewID(nopType),
182181
},
183182
}
184-
pls[component.NewID(pipelineTypeOther)] = &pipelines.PipelineConfig{
183+
pls[pipelineIDOther] = &pipelines.PipelineConfig{
185184
Receivers: []component.ID{
186185
component.NewIDWithName(jmxType, jmxOther),
187186
},

extension/entitystore/eksInfo_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ func TestTTLServicePodEnvironmentMapping(t *testing.T) {
169169
ServiceName: "service",
170170
Environment: "environment",
171171
},
172-
}, time.Microsecond)
172+
}, 500*time.Millisecond)
173+
// this assertion relies on the speed of your computer to get this done before
174+
// the cache evicts the item based on the TTL
173175
assert.Equal(t, 1, ei.podToServiceEnvMap.Len())
174176

175177
//starting the ttl cache like we do in code. This will automatically evict expired pods.

extension/entitystore/extension_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ func TestEntityStore_ClearTerminatedPodsFromServiceMap(t *testing.T) {
519519
func TestEntityStore_StartPodToServiceEnvironmentMappingTtlCache(t *testing.T) {
520520
e := EntityStore{eksInfo: newEKSInfo(zap.NewExample())}
521521
e.done = make(chan struct{})
522-
e.eksInfo.podToServiceEnvMap = setupTTLCacheForTesting(map[string]ServiceEnvironment{}, time.Microsecond)
522+
e.eksInfo.podToServiceEnvMap = setupTTLCacheForTesting(map[string]ServiceEnvironment{}, 500*time.Millisecond)
523523

524524
go e.StartPodToServiceEnvironmentMappingTtlCache()
525525
assert.Equal(t, 0, e.GetPodServiceEnvironmentMapping().Len())
@@ -546,9 +546,9 @@ func TestEntityStore_StopPodToServiceEnvironmentMappingTtlCache(t *testing.T) {
546546
assert.Equal(t, 1, e.GetPodServiceEnvironmentMapping().Len())
547547

548548
time.Sleep(time.Millisecond)
549-
assert.NoError(t, e.Shutdown(nil))
549+
assert.NoError(t, e.Shutdown(context.TODO()))
550550
//cache should be cleared
551-
time.Sleep(time.Second)
551+
time.Sleep(500 * time.Millisecond)
552552
assert.Equal(t, 1, e.GetPodServiceEnvironmentMapping().Len())
553553
}
554554

@@ -627,7 +627,7 @@ func TestEntityStore_LogMessageDoesNotIncludeResourceInfo(t *testing.T) {
627627
metadataprovider: tt.args.metadataProvider,
628628
config: config,
629629
}
630-
go es.Start(nil, nil)
630+
go es.Start(context.TODO(), nil)
631631
time.Sleep(2 * time.Second)
632632

633633
logOutput := buf.String()

extension/entitystore/factory.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func createDefaultConfig() component.Config {
3939
return &Config{}
4040
}
4141

42-
func createExtension(_ context.Context, settings extension.CreateSettings, cfg component.Config) (extension.Extension, error) {
42+
func createExtension(_ context.Context, settings extension.Settings, cfg component.Config) (extension.Extension, error) {
4343
mutex.Lock()
4444
defer mutex.Unlock()
4545
entityStore = &EntityStore{

extension/entitystore/factory_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ func TestCreateDefaultConfig(t *testing.T) {
1818
assert.NoError(t, componenttest.CheckConfigStruct(cfg))
1919
}
2020

21-
func TestCreateExtension(t *testing.T) {
21+
func TestCreate(t *testing.T) {
2222
cfg := &Config{}
23-
got, err := NewFactory().CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg)
23+
got, err := NewFactory().Create(context.Background(), extensiontest.NewNopSettings(), cfg)
2424
assert.NoError(t, err)
2525
assert.NotNil(t, got)
2626
}

extension/server/factory.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ func createDefaultConfig() component.Config {
2727
return &Config{}
2828
}
2929

30-
func createExtension(_ context.Context, settings extension.CreateSettings, cfg component.Config) (extension.Extension, error) {
30+
func createExtension(_ context.Context, settings extension.Settings, cfg component.Config) (extension.Extension, error) {
3131
return NewServer(settings.Logger, cfg.(*Config)), nil
3232
}

extension/server/factory_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ func TestCreateDefaultConfig(t *testing.T) {
2020

2121
func TestCreateExtension(t *testing.T) {
2222
cfg := &Config{}
23-
got, err := NewFactory().CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg)
23+
got, err := NewFactory().Create(context.Background(), extensiontest.NewNopSettings(), cfg)
2424
assert.NoError(t, err)
2525
assert.NotNil(t, got)
2626
}
2727

28-
func TestCreateExtensionWithConfig(t *testing.T) {
28+
func TestCreateWithConfig(t *testing.T) {
2929
cfg := &Config{ListenAddress: ":8080", TLSCertPath: "./testdata/example-server-cert.pem",
3030
TLSKeyPath: "./testdata/example-server-key.pem",
3131
TLSCAPath: "./testdata/example-CA-cert.pem"}
32-
got, err := NewFactory().CreateExtension(context.Background(), extensiontest.NewNopCreateSettings(), cfg)
32+
got, err := NewFactory().Create(context.Background(), extensiontest.NewNopSettings(), cfg)
3333
assert.NoError(t, err)
3434
assert.NotNil(t, got)
3535
}

0 commit comments

Comments
 (0)