From 048f2269f18dc7655b6a26db532b67b2971db50e Mon Sep 17 00:00:00 2001 From: Ryan Min Date: Fri, 3 Jan 2025 12:05:07 -0500 Subject: [PATCH] add to codeowners --- .github/CODEOWNERS | 2 +- .../dockerstatsreceiver/integration_test.go | 20 +++++++++++++++++-- receiver/dockerstatsreceiver/logs_receiver.go | 11 ++++++---- receiver/dockerstatsreceiver/metadata.yaml | 2 +- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5e17e88ddbe5..fd9ae2f4d91e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -218,7 +218,7 @@ receiver/cloudfoundryreceiver/ @open-telemetry/collector-cont receiver/collectdreceiver/ @open-telemetry/collector-contrib-approvers @atoulme receiver/couchdbreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski receiver/datadogreceiver/ @open-telemetry/collector-contrib-approvers @boostchicken @gouthamve @MovieStoreGuy -receiver/dockerstatsreceiver/ @open-telemetry/collector-contrib-approvers @jamesmoessis +receiver/dockerstatsreceiver/ @open-telemetry/collector-contrib-approvers @jamesmoessis @spiffyy99 receiver/elasticsearchreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski receiver/expvarreceiver/ @open-telemetry/collector-contrib-approvers @jamesmoessis @MovieStoreGuy receiver/filelogreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski diff --git a/receiver/dockerstatsreceiver/integration_test.go b/receiver/dockerstatsreceiver/integration_test.go index 789f1f242851..a8284bb5edd1 100644 --- a/receiver/dockerstatsreceiver/integration_test.go +++ b/receiver/dockerstatsreceiver/integration_test.go @@ -250,13 +250,21 @@ func TestContainerLifecycleEventsIntegration(t *testing.T) { require.NoError(t, nginxContainer.Terminate(ctx)) assert.Eventuallyf(t, func() bool { - return hasDockerEvents(consumer.AllLogs(), redisID, []string{ + return hasDockerEvents(consumer.AllLogs(), nginxID, []string{ "docker.container.die", "docker.container.stop", }) }, 5*time.Second, 1*time.Second, "failed to receive container stop/die events") + consumer.Reset() require.NoError(t, redisContainer.Terminate(ctx)) + + assert.Eventuallyf(t, func() bool { + return hasDockerEvents(consumer.AllLogs(), redisID, []string{ + "docker.container.die", + "docker.container.stop", + }) + }, 5*time.Second, 1*time.Second, "failed to receive container stop/die events") assert.NoError(t, recv.Shutdown(ctx)) } @@ -268,7 +276,7 @@ func TestFilteredContainerEventsIntegration(t *testing.T) { f, config := factory() // Only receive events from redis containers config.Logs.Filters = map[string][]string{ - "image": {"*redis*"}, + "image": {"docker.io/library/redis:latest"}, } consumer := new(consumertest.LogsSink) @@ -295,8 +303,16 @@ func TestFilteredContainerEventsIntegration(t *testing.T) { }) }, 5*time.Second, 1*time.Second, "failed to receive redis container events") + consumer.Reset() require.NoError(t, nginxContainer.Terminate(ctx)) require.NoError(t, redisContainer.Terminate(ctx)) + assert.Eventuallyf(t, func() bool { + return hasDockerEvents(consumer.AllLogs(), redisID, []string{ + "docker.container.die", + "docker.container.stop", + }) + }, 5*time.Second, 1*time.Second, "failed to receive container stop/die events") + assert.NoError(t, recv.Shutdown(ctx)) } diff --git a/receiver/dockerstatsreceiver/logs_receiver.go b/receiver/dockerstatsreceiver/logs_receiver.go index ded4ef8df108..0b0a61d1d3ec 100644 --- a/receiver/dockerstatsreceiver/logs_receiver.go +++ b/receiver/dockerstatsreceiver/logs_receiver.go @@ -101,10 +101,13 @@ func newDockerEventPoller( } func (d *dockerEventPoller) Start(ctx context.Context) { - filterArgs := filters.NewArgs() - for k, v := range d.config.Logs.Filters { - for _, elem := range v { - filterArgs.Add(k, elem) + filterArgs := filters.Args{} + if len(d.config.Logs.Filters) > 0 { + filterArgs = filters.NewArgs() + for k, v := range d.config.Logs.Filters { + for _, elem := range v { + filterArgs.Add(k, elem) + } } } for { diff --git a/receiver/dockerstatsreceiver/metadata.yaml b/receiver/dockerstatsreceiver/metadata.yaml index 3fc366e8fa4e..5378f2a21a26 100644 --- a/receiver/dockerstatsreceiver/metadata.yaml +++ b/receiver/dockerstatsreceiver/metadata.yaml @@ -7,7 +7,7 @@ status: alpha: [metrics] distributions: [contrib] codeowners: - active: [jamesmoessis] + active: [jamesmoessis, spiffyy99] emeritus: [rmfitzpatrick] unsupported_platforms: [darwin, windows]