Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.23.0

require (
github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.125.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/groupbyattrsprocessor v0.125.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor v0.125.0
github.com/stretchr/testify v1.10.0
go.opentelemetry.io/collector/component v1.31.0
Expand Down Expand Up @@ -77,7 +78,6 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20250505200425-f936aa4a68b2 // indirect
google.golang.org/grpc v1.72.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Expand Down
128 changes: 24 additions & 104 deletions go.sum

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions internal/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ func Executors() []Executor {
return []Executor{
NewTransformProcessorExecutor(),
NewFilterProcessorExecutor(),
NewGroupByAttrsProcessorExecutor(),
}
}
44 changes: 44 additions & 0 deletions internal/groupbyattrsprocessorexecutor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package internal

import (
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/groupbyattrsprocessor"
)

type groupByAttrsProcessorExecutor struct {
*processorExecutor[groupbyattrsprocessor.Config]
}

func (f groupByAttrsProcessorExecutor) Metadata() Metadata {
return newMetadata(
"group_by_attrs_processor",
"Group by attrs processor",
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/groupbyattrsprocessor",
"https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/groupbyattrsprocessor",
)
}

// NewGroupByAttrsProcessorExecutor creates an internal.Executor that runs OTTL statements using
// the [groupbyattrsprocessor].
func NewGroupByAttrsProcessorExecutor() Executor {
executor := newProcessorExecutor[groupbyattrsprocessor.Config](groupbyattrsprocessor.NewFactory())
return &groupByAttrsProcessorExecutor{executor}
}
45 changes: 45 additions & 0 deletions internal/groupbyattrsprocessorexecutor_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package internal

import (
"os"
"path/filepath"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

const (
groupbyattrsprocessorConfig = "groupbyattrsprocessor.yaml"
)

func Test_GroupByAttrsProcessorExecutor_ParseConfig(t *testing.T) {
yamlConfig, err := os.ReadFile(filepath.Join("..", "testdata", groupbyattrsprocessorConfig))
require.NoError(t, err)

executor := NewGroupByAttrsProcessorExecutor().(*groupByAttrsProcessorExecutor)
assert.NotNil(t, executor)
parsedConfig, err := executor.parseConfig(string(yamlConfig))
require.NoError(t, err)
require.NotNil(t, parsedConfig)
require.NotEmpty(t, parsedConfig.GroupByKeys)
}
2 changes: 2 additions & 0 deletions testdata/groupbyattrsprocessor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
keys:
- my.span.attr
11 changes: 11 additions & 0 deletions web/src/components/examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,16 @@ const FILTER_PROCESSOR_CONFIG_EXAMPLES = [
},
];

const GROUP_BY_ATTRS_PROCESSOR_CONFIG_EXAMPLES = [
{
name: 'Move common span attribute to resource',
otlp_type: 'traces',
config:
'keys:\n' +
' - my.span.attr',
},
];

const sortBy = (property) => {
return function (a, b) {
return a[property] < b[property] ? -1 : a[property] > b[property] ? 1 : 0;
Expand All @@ -203,4 +213,5 @@ const sortBy = (property) => {
export const CONFIG_EXAMPLES = {
transform_processor: TRANSFORM_PROCESSOR_CONFIG_EXAMPLES.sort(sortBy('name')),
filter_processor: FILTER_PROCESSOR_CONFIG_EXAMPLES.sort(sortBy('name')),
group_by_attrs_processor: GROUP_BY_ATTRS_PROCESSOR_CONFIG_EXAMPLES.sort(sortBy('name')),
};