Skip to content

Commit

Permalink
Merge branch 'main' into codeboten/update-ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
codeboten authored Dec 2, 2024
2 parents d47fbb7 + e4b2bbf commit 3c9948a
Show file tree
Hide file tree
Showing 42 changed files with 215 additions and 68 deletions.
27 changes: 27 additions & 0 deletions .chloggen/file-grouping.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: pkg/stanza

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Introduce active file grouping mechanism."

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [23787]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
32 changes: 16 additions & 16 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ confmap/provider/secretsmanagerprovider/ @open-telemetry/collector-cont
connector/countconnector/ @open-telemetry/collector-contrib-approvers @djaglowski @jpkrohling
connector/datadogconnector/ @open-telemetry/collector-contrib-approvers @mx-psi @dineshg13 @ankitpatel96 @jade-guiton-dd
connector/exceptionsconnector/ @open-telemetry/collector-contrib-approvers @marctc
connector/failoverconnector/ @open-telemetry/collector-contrib-approvers @akats7 @djaglowski @fatsheep9146
connector/failoverconnector/ @open-telemetry/collector-contrib-approvers @akats7 @fatsheep9146
connector/grafanacloudconnector/ @open-telemetry/collector-contrib-approvers @rlankfo @jcreixell
connector/otlpjsonconnector/ @open-telemetry/collector-contrib-approvers @djaglowski @ChrsMark
connector/roundrobinconnector/ @open-telemetry/collector-contrib-approvers @bogdandrutu
Expand Down Expand Up @@ -179,10 +179,10 @@ processor/filterprocessor/ @open-telemetry/collector-cont
processor/geoipprocessor/ @open-telemetry/collector-contrib-approvers @andrzej-stencel @michalpristas @rogercoll
processor/groupbyattrsprocessor/ @open-telemetry/collector-contrib-approvers @rnishtala-sumo
processor/groupbytraceprocessor/ @open-telemetry/collector-contrib-approvers @jpkrohling
processor/intervalprocessor/ @open-telemetry/collector-contrib-approvers @RichieSams @sh0rez @djaglowski
processor/intervalprocessor/ @open-telemetry/collector-contrib-approvers @RichieSams @sh0rez
processor/k8sattributesprocessor/ @open-telemetry/collector-contrib-approvers @dmitryax @fatsheep9146 @TylerHelmuth
processor/logdedupprocessor/ @open-telemetry/collector-contrib-approvers @MikeGoldsmith @djaglowski
processor/logstransformprocessor/ @open-telemetry/collector-contrib-approvers @djaglowski @dehaansa
processor/logstransformprocessor/ @open-telemetry/collector-contrib-approvers @dehaansa
processor/metricsgenerationprocessor/ @open-telemetry/collector-contrib-approvers @Aneurysm9
processor/metricstransformprocessor/ @open-telemetry/collector-contrib-approvers @dmitryax
processor/probabilisticsamplerprocessor/ @open-telemetry/collector-contrib-approvers @jpkrohling @jmacd
Expand All @@ -198,9 +198,9 @@ processor/tailsamplingprocessor/ @open-telemetry/collector-cont
processor/transformprocessor/ @open-telemetry/collector-contrib-approvers @TylerHelmuth @kentquirk @bogdandrutu @evan-bradley

receiver/activedirectorydsreceiver/ @open-telemetry/collector-contrib-approvers @pjanotti
receiver/aerospikereceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @antonblock
receiver/aerospikereceiver/ @open-telemetry/collector-contrib-approvers @antonblock
receiver/apachereceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/apachesparkreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @Caleb-Hurshman @mrsillydog
receiver/apachesparkreceiver/ @open-telemetry/collector-contrib-approvers @Caleb-Hurshman @mrsillydog
receiver/awscloudwatchmetricsreceiver/ @open-telemetry/collector-contrib-approvers
receiver/awscloudwatchreceiver/ @open-telemetry/collector-contrib-approvers @schmikei
receiver/awscontainerinsightreceiver/ @open-telemetry/collector-contrib-approvers @Aneurysm9 @pxaws
Expand All @@ -211,10 +211,10 @@ receiver/awsxrayreceiver/ @open-telemetry/collector-cont
receiver/azureblobreceiver/ @open-telemetry/collector-contrib-approvers @eedorenko @mx-psi
receiver/azureeventhubreceiver/ @open-telemetry/collector-contrib-approvers @atoulme @cparkins
receiver/azuremonitorreceiver/ @open-telemetry/collector-contrib-approvers @nslaughter
receiver/bigipreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @StefanKurek
receiver/bigipreceiver/ @open-telemetry/collector-contrib-approvers @StefanKurek
receiver/carbonreceiver/ @open-telemetry/collector-contrib-approvers @aboguszewski-sumo
receiver/chronyreceiver/ @open-telemetry/collector-contrib-approvers @MovieStoreGuy @jamesmoessis
receiver/cloudflarereceiver/ @open-telemetry/collector-contrib-approvers @dehaansa @djaglowski
receiver/cloudflarereceiver/ @open-telemetry/collector-contrib-approvers @dehaansa
receiver/cloudfoundryreceiver/ @open-telemetry/collector-contrib-approvers @crobert-1
receiver/collectdreceiver/ @open-telemetry/collector-contrib-approvers @atoulme
receiver/couchdbreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
Expand All @@ -224,7 +224,7 @@ receiver/elasticsearchreceiver/ @open-telemetry/collector-cont
receiver/expvarreceiver/ @open-telemetry/collector-contrib-approvers @jamesmoessis @MovieStoreGuy
receiver/filelogreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/filestatsreceiver/ @open-telemetry/collector-contrib-approvers @atoulme
receiver/flinkmetricsreceiver/ @open-telemetry/collector-contrib-approvers @JonathanWamsley @djaglowski
receiver/flinkmetricsreceiver/ @open-telemetry/collector-contrib-approvers @JonathanWamsley
receiver/fluentforwardreceiver/ @open-telemetry/collector-contrib-approvers @dmitryax
receiver/githubreceiver/ @open-telemetry/collector-contrib-approvers @adrielp @andrzej-stencel @crobert-1 @TylerHelmuth
receiver/googlecloudmonitoringreceiver/ @open-telemetry/collector-contrib-approvers @dashpole @TylerHelmuth @abhishek-at-cloudwerx
Expand All @@ -246,8 +246,8 @@ receiver/kafkareceiver/ @open-telemetry/collector-cont
receiver/kubeletstatsreceiver/ @open-telemetry/collector-contrib-approvers @dmitryax @TylerHelmuth @ChrsMark
receiver/lokireceiver/ @open-telemetry/collector-contrib-approvers @mar4uk
receiver/memcachedreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/mongodbatlasreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @schmikei
receiver/mongodbreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @schmikei
receiver/mongodbatlasreceiver/ @open-telemetry/collector-contrib-approvers @schmikei
receiver/mongodbreceiver/ @open-telemetry/collector-contrib-approvers @schmikei
receiver/mysqlreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/namedpipereceiver/ @open-telemetry/collector-contrib-approvers @sinkingpoint @djaglowski
receiver/netflowreceiver/ @open-telemetry/collector-contrib-approvers @evan-bradley @dlopes7
Expand All @@ -266,30 +266,30 @@ receiver/prometheusremotewritereceiver/ @open-telemetry/collector-cont
receiver/pulsarreceiver/ @open-telemetry/collector-contrib-approvers @dmitryax @dao-jun
receiver/purefareceiver/ @open-telemetry/collector-contrib-approvers @jpkrohling @dgoscn @chrroberts-pure
receiver/purefbreceiver/ @open-telemetry/collector-contrib-approvers @jpkrohling @dgoscn @chrroberts-pure
receiver/rabbitmqreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @cpheps
receiver/rabbitmqreceiver/ @open-telemetry/collector-contrib-approvers @cpheps
receiver/receivercreator/ @open-telemetry/collector-contrib-approvers @dmitryax
receiver/redisreceiver/ @open-telemetry/collector-contrib-approvers @dmitryax @hughesjj
receiver/riakreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @armstrmi
receiver/riakreceiver/ @open-telemetry/collector-contrib-approvers @armstrmi
receiver/saphanareceiver/ @open-telemetry/collector-contrib-approvers @dehaansa
receiver/sapmreceiver/ @open-telemetry/collector-contrib-approvers @atoulme
receiver/signalfxreceiver/ @open-telemetry/collector-contrib-approvers @dmitryax
receiver/simpleprometheusreceiver/ @open-telemetry/collector-contrib-approvers @fatsheep9146
receiver/skywalkingreceiver/ @open-telemetry/collector-contrib-approvers @JaredTan95
receiver/snmpreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @StefanKurek @tamir-michaeli
receiver/snmpreceiver/ @open-telemetry/collector-contrib-approvers @StefanKurek @tamir-michaeli
receiver/snowflakereceiver/ @open-telemetry/collector-contrib-approvers @dmitryax @shalper2
receiver/solacereceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @mcardy
receiver/solacereceiver/ @open-telemetry/collector-contrib-approvers @mcardy
receiver/splunkenterprisereceiver/ @open-telemetry/collector-contrib-approvers @shalper2 @MovieStoreGuy @greatestusername
receiver/splunkhecreceiver/ @open-telemetry/collector-contrib-approvers @atoulme
receiver/sqlqueryreceiver/ @open-telemetry/collector-contrib-approvers @dmitryax @crobert-1
receiver/sqlserverreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @StefanKurek
receiver/sqlserverreceiver/ @open-telemetry/collector-contrib-approvers @StefanKurek
receiver/sshcheckreceiver/ @open-telemetry/collector-contrib-approvers @nslaughter
receiver/statsdreceiver/ @open-telemetry/collector-contrib-approvers @jmacd @dmitryax
receiver/syslogreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @andrzej-stencel
receiver/systemdreceiver/ @open-telemetry/collector-contrib-approvers @Hemansh31 @atoulme
receiver/tcplogreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/tlscheckreceiver/ @open-telemetry/collector-contrib-approvers @atoulme @michael-burt
receiver/udplogreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski
receiver/vcenterreceiver/ @open-telemetry/collector-contrib-approvers @djaglowski @schmikei @StefanKurek
receiver/vcenterreceiver/ @open-telemetry/collector-contrib-approvers @schmikei @StefanKurek
receiver/wavefrontreceiver/ @open-telemetry/collector-contrib-approvers @samiura
receiver/webhookeventreceiver/ @open-telemetry/collector-contrib-approvers @atoulme @shalper2
receiver/windowseventlogreceiver/ @open-telemetry/collector-contrib-approvers @armstrmi @pjanotti
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ CMD_MODS_1 := $(shell find ./cmd/[n-z]* $(FIND_MOD_ARGS) -not -path "./cmd/otel*
CMD_MODS := $(CMD_MODS_0) $(CMD_MODS_1)
OTHER_MODS := $(shell find . $(EX_COMPONENTS) $(EX_INTERNAL) $(EX_PKG) $(EX_CMD) $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) $(PWD)
ALL_MODS := $(RECEIVER_MODS) $(PROCESSOR_MODS) $(EXPORTER_MODS) $(EXTENSION_MODS) $(CONNECTOR_MODS) $(INTERNAL_MODS) $(PKG_MODS) $(CMD_MODS) $(OTHER_MODS)
CGO_MODS := ./receiver/hostmetricsreceiver
CGO_MODS := ./receiver/hostmetricsreceiver

FIND_INTEGRATION_TEST_MODS={ find . -type f -name "*integration_test.go" & find . -type f -name "*e2e_test.go" -not -path "./testbed/*"; }
INTEGRATION_MODS := $(shell $(FIND_INTEGRATION_TEST_MODS) | xargs $(TO_MOD_DIR) | uniq)
Expand Down Expand Up @@ -385,7 +385,7 @@ telemetrygenlite:
-tags $(GO_BUILD_TAGS) -ldflags $(GO_BUILD_LDFLAGS) .

# helper function to update the core packages in builder-config.yaml
# input parameters are
# input parameters are
# $(1) = path/to/versions.yaml (where it greps the relevant packages)
# $(2) = path/to/go.mod (where it greps the package-versions)
# $(3) = path/to/builder-config.yaml (where we want to update the versions)
Expand Down
2 changes: 1 addition & 1 deletion connector/failoverconnector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| ------------- |-----------|
| Distributions | [contrib], [k8s] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aconnector%2Ffailover%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aconnector%2Ffailover) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aconnector%2Ffailover%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aconnector%2Ffailover) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@akats7](https://www.github.com/akats7), [@djaglowski](https://www.github.com/djaglowski), [@fatsheep9146](https://www.github.com/fatsheep9146) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@akats7](https://www.github.com/akats7), [@fatsheep9146](https://www.github.com/fatsheep9146) |

[alpha]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#alpha
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
Expand Down
2 changes: 1 addition & 1 deletion connector/failoverconnector/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ status:
alpha: [traces_to_traces, metrics_to_metrics, logs_to_logs]
distributions: [contrib, k8s]
codeowners:
active: [akats7, djaglowski, fatsheep9146]
active: [akats7, fatsheep9146]

tests:
skip_lifecycle: true
Expand Down
17 changes: 17 additions & 0 deletions pkg/stanza/fileconsumer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,23 @@ func TestUnmarshal(t *testing.T) {
return newMockOperatorConfig(cfg)
}(),
},
{
Name: "sort_by_group_by",
Expect: func() *mockOperatorConfig {
cfg := NewConfig()
cfg.OrderingCriteria = matcher.OrderingCriteria{
Regex: `err\.(?P<file_num>[a-zA-Z])\.\d+\.\d{10}\.log`,
GroupBy: `err\.(?P<value>[a-z]+).[0-9]*.*log`,
SortBy: []matcher.Sort{
{
SortType: "numeric",
RegexKey: "file_num",
},
},
}
return newMockOperatorConfig(cfg)
}(),
},
{
Name: "poll_interval_no_units",
Expect: func() *mockOperatorConfig {
Expand Down
43 changes: 35 additions & 8 deletions pkg/stanza/fileconsumer/matcher/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ type Criteria struct {
}

type OrderingCriteria struct {
Regex string `mapstructure:"regex,omitempty"`
TopN int `mapstructure:"top_n,omitempty"`
SortBy []Sort `mapstructure:"sort_by,omitempty"`
Regex string `mapstructure:"regex,omitempty"`
TopN int `mapstructure:"top_n,omitempty"`
SortBy []Sort `mapstructure:"sort_by,omitempty"`
GroupBy string `mapstructure:"group_by,omitempty"`
}

type Sort struct {
Expand Down Expand Up @@ -80,6 +81,14 @@ func New(c Criteria) (*Matcher, error) {
m.filterOpts = append(m.filterOpts, filter.ExcludeOlderThan(c.ExcludeOlderThan))
}

if c.OrderingCriteria.GroupBy != "" {
r, err := regexp.Compile(c.OrderingCriteria.GroupBy)
if err != nil {
return nil, fmt.Errorf("compile group_by regex: %w", err)
}
m.groupBy = r
}

if len(c.OrderingCriteria.SortBy) == 0 {
return m, nil
}
Expand All @@ -92,14 +101,13 @@ func New(c Criteria) (*Matcher, error) {
c.OrderingCriteria.TopN = defaultOrderingCriteriaTopN
}

var regex *regexp.Regexp
if orderingCriteriaNeedsRegex(c.OrderingCriteria.SortBy) {
if c.OrderingCriteria.Regex == "" {
return nil, fmt.Errorf("'regex' must be specified when 'sort_by' is specified")
}

var err error
regex, err = regexp.Compile(c.OrderingCriteria.Regex)
regex, err := regexp.Compile(c.OrderingCriteria.Regex)
if err != nil {
return nil, fmt.Errorf("compile regex: %w", err)
}
Expand Down Expand Up @@ -158,6 +166,7 @@ type Matcher struct {
exclude []string
regex *regexp.Regexp
filterOpts []filter.Option
groupBy *regexp.Regexp
}

// MatchFiles gets a list of paths given an array of glob patterns to include and exclude
Expand All @@ -174,9 +183,27 @@ func (m Matcher) MatchFiles() ([]string, error) {
return files, errs
}

result, err := filter.Filter(files, m.regex, m.filterOpts...)
if len(result) == 0 {
return result, errors.Join(err, errs)
groups := make(map[string][]string)
if m.groupBy != nil {
for _, f := range files {
matches := m.groupBy.FindStringSubmatch(f)
if len(matches) > 1 {
group := matches[1]
groups[group] = append(groups[group], f)
}
}
} else {
groups["1"] = files
}

var result []string
for _, groupedFiles := range groups {
groupResult, err := filter.Filter(groupedFiles, m.regex, m.filterOpts...)
if len(groupResult) == 0 {
return groupResult, errors.Join(err, errs)
}
result = append(result, groupResult...)
}

return result, errs
}
Loading

0 comments on commit 3c9948a

Please sign in to comment.