Skip to content

Commit c8a2369

Browse files
authored
[processor/resourcedetection] Move processor.resourcedetection.hostCPUModelAndFamilyAsString feature gate to stable (#33077)
**Description:** <Describe what has changed.> <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> Follows #29152 and #29462. The feature gate has been in beta since v0.91.0. **Link to tracking Issue:** Relates to #29025 and to open-telemetry/semantic-conventions#495
1 parent 3868323 commit c8a2369

File tree

3 files changed

+35
-53
lines changed

3 files changed

+35
-53
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: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: resourcedetectionprocessor
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Move `processor.resourcedetection.hostCPUModelAndFamilyAsString` feature gate to stable.
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: [29025]
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: []

processor/resourcedetectionprocessor/internal/system/internal/metadata/resource_int_version.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,6 @@
33

44
package metadata // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/system/internal/metadata"
55

6-
// SetHostCPUFamilyAsInt sets provided value as "host.cpu.family" attribute as int.
7-
func (rb *ResourceBuilder) SetHostCPUFamilyAsInt(val int64) {
8-
if rb.config.HostCPUFamily.Enabled {
9-
rb.res.Attributes().PutInt("host.cpu.family", val)
10-
}
11-
}
12-
13-
// SetHostCPUModelIDAsInt sets provided value as "host.cpu.model.id" attribute as int.
14-
func (rb *ResourceBuilder) SetHostCPUModelIDAsInt(val int64) {
15-
if rb.config.HostCPUModelID.Enabled {
16-
rb.res.Attributes().PutInt("host.cpu.model.id", val)
17-
}
18-
}
19-
206
// SetHostCPUSteppingAsInt sets provided value as "host.cpu.stepping" attribute as int.
217
func (rb *ResourceBuilder) SetHostCPUSteppingAsInt(val int64) {
228
if rb.config.HostCPUModelID.Enabled {

processor/resourcedetectionprocessor/internal/system/system.go

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"errors"
99
"fmt"
1010
"net"
11-
"strconv"
1211
"strings"
1312

1413
"github.com/shirou/gopsutil/v3/cpu"
@@ -24,12 +23,12 @@ import (
2423
)
2524

2625
var (
27-
hostCPUModelAndFamilyAsStringID = "processor.resourcedetection.hostCPUModelAndFamilyAsString"
28-
hostCPUModelAndFamilyAsStringFeatureGate = featuregate.GlobalRegistry().MustRegister(
29-
hostCPUModelAndFamilyAsStringID,
30-
featuregate.StageBeta,
26+
_ = featuregate.GlobalRegistry().MustRegister(
27+
"processor.resourcedetection.hostCPUModelAndFamilyAsString",
28+
featuregate.StageStable,
3129
featuregate.WithRegisterDescription("Change type of host.cpu.model.id and host.cpu.model.family to string."),
3230
featuregate.WithRegisterFromVersion("v0.89.0"),
31+
featuregate.WithRegisterToVersion("v0.101.0"),
3332
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/semantic-conventions/issues/495"),
3433
)
3534
hostCPUSteppingAsStringID = "processor.resourcedetection.hostCPUSteppingAsString"
@@ -154,10 +153,7 @@ func (d *Detector) Detect(ctx context.Context) (resource pcommon.Resource, schem
154153
d.rb.SetHostMac(hostMACAttribute)
155154
d.rb.SetOsDescription(osDescription)
156155
if len(cpuInfo) > 0 {
157-
err = setHostCPUInfo(d, cpuInfo[0])
158-
if err != nil {
159-
d.logger.Warn("failed to get host cpuinfo", zap.Error(err))
160-
}
156+
setHostCPUInfo(d, cpuInfo[0])
161157
}
162158
return d.rb.Emit(), conventions.SchemaURL, nil
163159
}
@@ -201,42 +197,16 @@ func reverseLookupHost(d *Detector) (string, error) {
201197
return hostname, nil
202198
}
203199

204-
func setHostCPUInfo(d *Detector, cpuInfo cpu.InfoStat) error {
200+
func setHostCPUInfo(d *Detector, cpuInfo cpu.InfoStat) {
205201
d.logger.Debug("getting host's cpuinfo", zap.String("coreID", cpuInfo.CoreID))
206202
d.rb.SetHostCPUVendorID(cpuInfo.VendorID)
207-
if hostCPUModelAndFamilyAsStringFeatureGate.IsEnabled() {
208-
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/29025
209-
d.logger.Info("This attribute changed from int to string. Temporarily switch back to int using the feature gate.",
210-
zap.String("attribute", "host.cpu.family"),
211-
zap.String("feature gate", hostCPUModelAndFamilyAsStringID),
212-
)
213-
d.rb.SetHostCPUFamily(cpuInfo.Family)
214-
} else {
215-
family, err := strconv.ParseInt(cpuInfo.Family, 10, 64)
216-
if err != nil {
217-
return fmt.Errorf("failed to convert cpuinfo family to integer: %w", err)
218-
}
219-
d.rb.SetHostCPUFamilyAsInt(family)
220-
}
203+
d.rb.SetHostCPUFamily(cpuInfo.Family)
221204

222205
// For windows, this field is left blank. See https://github.com/shirou/gopsutil/blob/v3.23.9/cpu/cpu_windows.go#L113
223206
// Skip setting modelId if the field is blank.
224207
// ISSUE: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/27675
225208
if cpuInfo.Model != "" {
226-
if hostCPUModelAndFamilyAsStringFeatureGate.IsEnabled() {
227-
// https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/29025
228-
d.logger.Info("This attribute changed from int to string. Temporarily switch back to int using the feature gate.",
229-
zap.String("attribute", "host.cpu.model.id"),
230-
zap.String("feature gate", hostCPUModelAndFamilyAsStringID),
231-
)
232-
d.rb.SetHostCPUModelID(cpuInfo.Model)
233-
} else {
234-
model, err := strconv.ParseInt(cpuInfo.Model, 10, 64)
235-
if err != nil {
236-
return fmt.Errorf("failed to convert cpuinfo model to integer: %w", err)
237-
}
238-
d.rb.SetHostCPUModelIDAsInt(model)
239-
}
209+
d.rb.SetHostCPUModelID(cpuInfo.Model)
240210
}
241211

242212
d.rb.SetHostCPUModelName(cpuInfo.ModelName)
@@ -251,5 +221,4 @@ func setHostCPUInfo(d *Detector, cpuInfo cpu.InfoStat) error {
251221
d.rb.SetHostCPUSteppingAsInt(int64(cpuInfo.Stepping))
252222
}
253223
d.rb.SetHostCPUCacheL2Size(int64(cpuInfo.CacheSize))
254-
return nil
255224
}

0 commit comments

Comments
 (0)