Skip to content

Commit 6d2c0eb

Browse files
authored
Merge branch 'main' into main
2 parents dcb7baa + 3614764 commit 6d2c0eb

File tree

29 files changed

+1098
-92
lines changed

29 files changed

+1098
-92
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
7+
component: pkg/ottl
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add `unit` and `type` subpaths for `profile.sample_type` and `profile.period_type`.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [43723]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

.chloggen/trim-suffix-prefix.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog)
7+
component: pkg/ottl
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Add TrimPrefix and TrimSuffix to OTTL
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [43883]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: This is a much optimal way to remove prefix/suffix compare with `replace_pattern(name, "^prefixed", "")`
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

cmd/telemetrygen/internal/common/validate.go renamed to cmd/telemetrygen/internal/validate/validate.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 validate
55

66
import (
77
"encoding/hex"
@@ -15,7 +15,7 @@ var (
1515
errInvalidSpanID = errors.New("failed to create SpanID byte array from the given SpanID, make sure the SpanID is a hex representation of a [8]byte, like: '5828fa4960140870'")
1616
)
1717

18-
func ValidateTraceID(traceID string) error {
18+
func TraceID(traceID string) error {
1919
if len(traceID) != 32 {
2020
return errInvalidTraceIDLength
2121
}
@@ -28,7 +28,7 @@ func ValidateTraceID(traceID string) error {
2828
return nil
2929
}
3030

31-
func ValidateSpanID(spanID string) error {
31+
func SpanID(spanID string) error {
3232
if len(spanID) != 16 {
3333
return errInvalidSpanIDLength
3434
}

cmd/telemetrygen/internal/common/validate_test.go renamed to cmd/telemetrygen/internal/validate/validate_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 validate
55

66
import (
77
"testing"
@@ -33,7 +33,7 @@ func TestValidateTraceID(t *testing.T) {
3333
}
3434
for _, tt := range tests {
3535
t.Run(tt.name, func(t *testing.T) {
36-
err := ValidateTraceID(tt.traceID)
36+
err := TraceID(tt.traceID)
3737
assert.ErrorIs(t, err, tt.expected)
3838
})
3939
}
@@ -63,7 +63,7 @@ func TestValidateSpanID(t *testing.T) {
6363
}
6464
for _, tt := range tests {
6565
t.Run(tt.name, func(t *testing.T) {
66-
err := ValidateSpanID(tt.spanID)
66+
err := SpanID(tt.spanID)
6767
assert.ErrorIs(t, err, tt.expected)
6868
})
6969
}

cmd/telemetrygen/pkg/logs/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/spf13/pflag"
1111

1212
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/internal/common"
13+
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/internal/validate"
1314
types "github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/pkg"
1415
)
1516

@@ -70,13 +71,13 @@ func (c *Config) Validate() error {
7071
}
7172

7273
if c.TraceID != "" {
73-
if err := common.ValidateTraceID(c.TraceID); err != nil {
74+
if err := validate.TraceID(c.TraceID); err != nil {
7475
return err
7576
}
7677
}
7778

7879
if c.SpanID != "" {
79-
if err := common.ValidateSpanID(c.SpanID); err != nil {
80+
if err := validate.SpanID(c.SpanID); err != nil {
8081
return err
8182
}
8283
}

cmd/telemetrygen/pkg/metrics/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"go.opentelemetry.io/otel/sdk/metric/metricdata"
1313

1414
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/internal/common"
15+
"github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/internal/validate"
1516
types "github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen/pkg"
1617
)
1718

@@ -86,13 +87,13 @@ func (c *Config) Validate() error {
8687
}
8788

8889
if c.TraceID != "" {
89-
if err := common.ValidateTraceID(c.TraceID); err != nil {
90+
if err := validate.TraceID(c.TraceID); err != nil {
9091
return err
9192
}
9293
}
9394

9495
if c.SpanID != "" {
95-
if err := common.ValidateSpanID(c.SpanID); err != nil {
96+
if err := validate.SpanID(c.SpanID); err != nil {
9697
return err
9798
}
9899
}

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"`

0 commit comments

Comments
 (0)