Skip to content

Commit 2850ff4

Browse files
committed
[internal/attraction] Remove stable feature gate
Remove `coreinternal.attraction.hash.sha256` feature gate
1 parent 6d74e53 commit 2850ff4

File tree

8 files changed

+21
-79
lines changed

8 files changed

+21
-79
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: breaking
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
5+
component: processor/attributes, processor/resource
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Remove stable coreinternal.attraction.hash.sha256 feature gate.
9+
10+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
11+
issues: [31997]
12+
13+
# If your change doesn't affect end users or the exported elements of any package,
14+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
15+
# Optional: The change log or logs in which this entry should be included.
16+
# e.g. '[user]' or '[user, api]'
17+
# Include 'user' if the change is relevant to end users.
18+
# Include 'api' if there is a change to a library API.
19+
# Default: '[user]'
20+
change_logs: []

internal/coreinternal/attraction/attraction.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,10 @@ import (
1010
"strings"
1111

1212
"go.opentelemetry.io/collector/client"
13-
"go.opentelemetry.io/collector/featuregate"
1413
"go.opentelemetry.io/collector/pdata/pcommon"
1514
"go.uber.org/zap"
1615
)
1716

18-
var enableSha256Gate = featuregate.GlobalRegistry().MustRegister(
19-
"coreinternal.attraction.hash.sha256",
20-
featuregate.StageStable,
21-
featuregate.WithRegisterDescription("When enabled, switches hashing algorithm from SHA-1 to SHA-2 256"),
22-
featuregate.WithRegisterToVersion("0.85.0"),
23-
)
24-
2517
// Settings specifies the processor settings.
2618
type Settings struct {
2719
// Actions specifies the list of attributes to act on.
@@ -404,11 +396,7 @@ func getSourceAttributeValue(ctx context.Context, action attributeAction, attrs
404396

405397
func hashAttribute(key string, attrs pcommon.Map) {
406398
if value, exists := attrs.Get(key); exists {
407-
if enableSha256Gate.IsEnabled() {
408-
sha2Hasher(value)
409-
} else {
410-
sha1Hasher(value)
411-
}
399+
sha2Hasher(value)
412400
}
413401
}
414402

internal/coreinternal/attraction/attraction_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package attraction
55

66
import (
77
"context"
8-
"crypto/sha1" // #nosec
98
"crypto/sha256"
109
"encoding/binary"
1110
"errors"
@@ -930,20 +929,6 @@ func TestValidConfiguration(t *testing.T) {
930929
}
931930

932931
func hash(b []byte) string {
933-
if enableSha256Gate.IsEnabled() {
934-
return sha2Hash(b)
935-
}
936-
return sha1Hash(b)
937-
}
938-
939-
func sha1Hash(b []byte) string {
940-
// #nosec
941-
h := sha1.New()
942-
h.Write(b)
943-
return fmt.Sprintf("%x", h.Sum(nil))
944-
}
945-
946-
func sha2Hash(b []byte) string {
947932
h := sha256.New()
948933
h.Write(b)
949934
return fmt.Sprintf("%x", h.Sum(nil))

internal/coreinternal/attraction/hasher.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package attraction // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal/attraction"
55

66
import (
7-
"crypto/sha1" // #nosec
87
"crypto/sha256"
98
"encoding/binary"
109
"encoding/hex"
@@ -23,44 +22,6 @@ var (
2322
byteFalse = [1]byte{0}
2423
)
2524

26-
// Deprecated: [v0.75.0] use sha2Hasher instead.
27-
// sha1Hasher hashes an AttributeValue using SHA1 and returns a
28-
// hashed version of the attribute. In practice, this would mostly be used
29-
// for string attributes but we support all types for completeness/correctness
30-
// and eliminate any surprises.
31-
func sha1Hasher(attr pcommon.Value) {
32-
var val []byte
33-
switch attr.Type() {
34-
case pcommon.ValueTypeStr:
35-
val = []byte(attr.Str())
36-
case pcommon.ValueTypeBool:
37-
if attr.Bool() {
38-
val = byteTrue[:]
39-
} else {
40-
val = byteFalse[:]
41-
}
42-
case pcommon.ValueTypeInt:
43-
val = make([]byte, int64ByteSize)
44-
binary.LittleEndian.PutUint64(val, uint64(attr.Int()))
45-
case pcommon.ValueTypeDouble:
46-
val = make([]byte, float64ByteSize)
47-
binary.LittleEndian.PutUint64(val, math.Float64bits(attr.Double()))
48-
}
49-
50-
var hashed string
51-
if len(val) > 0 {
52-
// #nosec
53-
h := sha1.New()
54-
_, _ = h.Write(val)
55-
val = h.Sum(nil)
56-
hashedBytes := make([]byte, hex.EncodedLen(len(val)))
57-
hex.Encode(hashedBytes, val)
58-
hashed = string(hashedBytes)
59-
}
60-
61-
attr.SetStr(hashed)
62-
}
63-
6425
// sha2Hasher hashes an AttributeValue using SHA2-256 and returns a
6526
// hashed version of the attribute. In practice, this would mostly be used
6627
// for string attributes but we support all types for completeness/correctness

internal/coreinternal/go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ require (
1212
go.opentelemetry.io/collector v0.97.0
1313
go.opentelemetry.io/collector/component v0.97.0
1414
go.opentelemetry.io/collector/consumer v0.97.0
15-
go.opentelemetry.io/collector/featuregate v1.4.0
1615
go.opentelemetry.io/collector/pdata v1.4.0
1716
go.opentelemetry.io/collector/receiver v0.97.0
1817
go.opentelemetry.io/collector/semconv v0.97.0
@@ -46,7 +45,6 @@ require (
4645
github.com/gogo/protobuf v1.3.2 // indirect
4746
github.com/golang/protobuf v1.5.3 // indirect
4847
github.com/google/uuid v1.6.0 // indirect
49-
github.com/hashicorp/go-version v1.6.0 // indirect
5048
github.com/json-iterator/go v1.1.12 // indirect
5149
github.com/klauspost/compress v1.17.2 // indirect
5250
github.com/knadh/koanf/maps v0.1.1 // indirect

internal/coreinternal/go.sum

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

processor/resourceprocessor/go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ require (
2727
github.com/gogo/protobuf v1.3.2 // indirect
2828
github.com/golang/protobuf v1.5.3 // indirect
2929
github.com/google/uuid v1.6.0 // indirect
30-
github.com/hashicorp/go-version v1.6.0 // indirect
3130
github.com/json-iterator/go v1.1.12 // indirect
3231
github.com/knadh/koanf/maps v0.1.1 // indirect
3332
github.com/knadh/koanf/providers/confmap v0.1.0 // indirect
@@ -44,7 +43,6 @@ require (
4443
github.com/prometheus/procfs v0.12.0 // indirect
4544
go.opentelemetry.io/collector v0.97.0 // indirect
4645
go.opentelemetry.io/collector/config/configtelemetry v0.97.0 // indirect
47-
go.opentelemetry.io/collector/featuregate v1.4.0 // indirect
4846
go.opentelemetry.io/otel v1.24.0 // indirect
4947
go.opentelemetry.io/otel/exporters/prometheus v0.46.0 // indirect
5048
go.opentelemetry.io/otel/sdk v1.24.0 // indirect

processor/resourceprocessor/go.sum

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)