Skip to content

Commit 3614764

Browse files
authored
[connector/routing] remove internal common package (open-telemetry#43903)
The functions in the package were only used in one package, moved the code there instead. Signed-off-by: alex boten <[email protected]>
1 parent 2c0d146 commit 3614764

File tree

6 files changed

+18
-22
lines changed

6 files changed

+18
-22
lines changed

connector/routingconnector/internal/common/functions.go renamed to connector/routingconnector/functions.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package common // import "github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/internal/common"
4+
package routingconnector // import "github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector"
55

66
import (
77
"context"
@@ -17,7 +17,7 @@ func createRouteFunction[K any](ottl.FunctionContext, ottl.Arguments) (ottl.Expr
1717
}, nil
1818
}
1919

20-
func StandardFunctions[K any]() map[string]ottl.Factory[K] {
20+
func standardFunctions[K any]() map[string]ottl.Factory[K] {
2121
// standard converters do not transform data, so we can safely use them
2222
funcs := ottlfuncs.StandardConverters[K]()
2323

@@ -33,8 +33,8 @@ func StandardFunctions[K any]() map[string]ottl.Factory[K] {
3333
return funcs
3434
}
3535

36-
func SpanFunctions() map[string]ottl.Factory[ottlspan.TransformContext] {
37-
funcs := StandardFunctions[ottlspan.TransformContext]()
36+
func spanFunctions() map[string]ottl.Factory[ottlspan.TransformContext] {
37+
funcs := standardFunctions[ottlspan.TransformContext]()
3838

3939
isRootSpan := ottlfuncs.NewIsRootSpanFactory()
4040
funcs[isRootSpan.Name()] = isRootSpan

connector/routingconnector/internal/common/functions_test.go renamed to connector/routingconnector/functions_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4-
package common
4+
package routingconnector
55

66
import (
77
"maps"
@@ -15,11 +15,11 @@ import (
1515
)
1616

1717
func TestStandardFunctions(t *testing.T) {
18-
assertStandardFunctions(t, StandardFunctions[any]())
18+
assertStandardFunctions(t, standardFunctions[any]())
1919
}
2020

2121
func TestSpanFunctions(t *testing.T) {
22-
funcs := SpanFunctions()
22+
funcs := spanFunctions()
2323
assertStandardFunctions(t, funcs)
2424

2525
isRouteFuncName := ottlfuncs.NewIsRootSpanFactory().Name()

connector/routingconnector/logs_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"go.opentelemetry.io/collector/pdata/plog"
1818
"go.opentelemetry.io/collector/pipeline"
1919

20-
"github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/internal/common"
2120
"github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/internal/metadata"
2221
"github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/internal/plogutiltest"
2322
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottllog"
@@ -437,9 +436,9 @@ func TestLogsConnectorDetailed(t *testing.T) {
437436

438437
// IsMap and IsString are just candidate for Standard Converter Function to prevent any unknown regressions for this component
439438
isBodyString := `IsString(body) == true`
440-
require.Contains(t, common.StandardFunctions[ottllog.TransformContext](), "IsString")
439+
require.Contains(t, standardFunctions[ottllog.TransformContext](), "IsString")
441440
isBodyMap := `IsMap(body) == true`
442-
require.Contains(t, common.StandardFunctions[ottllog.TransformContext](), "IsMap")
441+
require.Contains(t, standardFunctions[ottllog.TransformContext](), "IsMap")
443442

444443
isScopeCFromLowerContext := `instrumentation_scope.name == "scopeC"`
445444
isScopeDFromLowerContext := `instrumentation_scope.name == "scopeD"`

connector/routingconnector/metrics_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"go.opentelemetry.io/collector/pdata/pmetric"
1818
"go.opentelemetry.io/collector/pipeline"
1919

20-
"github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/internal/common"
2120
"github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/internal/metadata"
2221
"github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/internal/pmetricutiltest"
2322
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottlresource"
@@ -453,9 +452,9 @@ func TestMetricsConnectorDetailed(t *testing.T) {
453452

454453
// IsMap and IsString are just candidate for Standard Converter Function to prevent any unknown regressions for this component
455454
isResourceString := `IsString(attributes["resourceName"]) == true`
456-
require.Contains(t, common.StandardFunctions[ottlresource.TransformContext](), "IsString")
455+
require.Contains(t, standardFunctions[ottlresource.TransformContext](), "IsString")
457456
isAttributesMap := `IsMap(attributes) == true`
458-
require.Contains(t, common.StandardFunctions[ottlresource.TransformContext](), "IsMap")
457+
require.Contains(t, standardFunctions[ottlresource.TransformContext](), "IsMap")
459458

460459
isMetricE := `name == "metricE"`
461460
isMetricF := `name == "metricF"`

connector/routingconnector/router.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"go.opentelemetry.io/collector/pipeline"
1313
"go.uber.org/zap"
1414

15-
"github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/internal/common"
1615
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
1716
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottldatapoint"
1817
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/contexts/ottllog"
@@ -102,7 +101,7 @@ func (r *router[C]) buildParsers(table []RoutingTableItem, settings component.Te
102101
var errs error
103102
if buildResource {
104103
parser, err := ottlresource.NewParser(
105-
common.StandardFunctions[ottlresource.TransformContext](),
104+
standardFunctions[ottlresource.TransformContext](),
106105
settings,
107106
)
108107
if err == nil {
@@ -113,7 +112,7 @@ func (r *router[C]) buildParsers(table []RoutingTableItem, settings component.Te
113112
}
114113
if buildSpan {
115114
parser, err := ottlspan.NewParser(
116-
common.SpanFunctions(),
115+
spanFunctions(),
117116
settings,
118117
)
119118
if err == nil {
@@ -124,7 +123,7 @@ func (r *router[C]) buildParsers(table []RoutingTableItem, settings component.Te
124123
}
125124
if buildMetric {
126125
parser, err := ottlmetric.NewParser(
127-
common.StandardFunctions[ottlmetric.TransformContext](),
126+
standardFunctions[ottlmetric.TransformContext](),
128127
settings,
129128
)
130129
if err == nil {
@@ -135,7 +134,7 @@ func (r *router[C]) buildParsers(table []RoutingTableItem, settings component.Te
135134
}
136135
if buildDataPoint {
137136
parser, err := ottldatapoint.NewParser(
138-
common.StandardFunctions[ottldatapoint.TransformContext](),
137+
standardFunctions[ottldatapoint.TransformContext](),
139138
settings,
140139
)
141140
if err == nil {
@@ -146,7 +145,7 @@ func (r *router[C]) buildParsers(table []RoutingTableItem, settings component.Te
146145
}
147146
if buildLog {
148147
parser, err := ottllog.NewParser(
149-
common.StandardFunctions[ottllog.TransformContext](),
148+
standardFunctions[ottllog.TransformContext](),
150149
settings,
151150
)
152151
if err == nil {

connector/routingconnector/traces_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"go.opentelemetry.io/collector/pdata/ptrace"
1818
"go.opentelemetry.io/collector/pipeline"
1919

20-
"github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/internal/common"
2120
"github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/internal/metadata"
2221
"github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/internal/ptraceutiltest"
2322
)
@@ -410,9 +409,9 @@ func TestTracesConnectorDetailed(t *testing.T) {
410409

411410
// IsMap and IsString are just candidate for Standard Converter Function to prevent any unknown regressions for this component
412411
isResourceString := `IsString(attributes["resourceName"]) == true`
413-
require.Contains(t, common.SpanFunctions(), "IsString")
412+
require.Contains(t, spanFunctions(), "IsString")
414413
isAttributesMap := `IsMap(attributes) == true`
415-
require.Contains(t, common.SpanFunctions(), "IsMap")
414+
require.Contains(t, spanFunctions(), "IsMap")
416415

417416
isSpanE := `name == "spanE"`
418417
isSpanF := `name == "spanF"`

0 commit comments

Comments
 (0)