Skip to content

Commit 3b62a17

Browse files
djaglowskimx-psi
andauthored
[receiver/elasticsearch] Bump 'receiver.elasticsearch.emitNodeVersionAttr' to stable (open-telemetry#23254)
* [receiver/elasticsearch] Bump 'receiver.elasticsearch.emitNodeVersionAttr' to stable * Update .chloggen/elastic-stable-nodevesiongate.yaml Co-authored-by: Pablo Baeyens <[email protected]> --------- Co-authored-by: Pablo Baeyens <[email protected]>
1 parent 6249ae8 commit 3b62a17

File tree

3 files changed

+36
-46
lines changed

3 files changed

+36
-46
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Use this changelog template to create an entry for release notes.
2+
# If your change doesn't affect end users, such as a test fix or a tooling change,
3+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
4+
5+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
6+
change_type: breaking
7+
8+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
9+
component: elasticsearchreceiver
10+
11+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
12+
note: Bump 'receiver.elasticsearch.emitNodeVersionAttr' to stable
13+
14+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
15+
issues: [16847]
16+
17+
# (Optional) One or more lines of additional information to render under the primary note.
18+
# These lines will be padded with 2 spaces and then inserted directly into the document.
19+
# Use pipe (|) for multiline entries.
20+
subtext: All node metrics are now enriched with the node version resource attribute.

receiver/elasticsearchreceiver/scraper.go

+16-38
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,12 @@ var (
3030
v, _ := version.NewVersion("7.13")
3131
return v
3232
}()
33-
)
34-
35-
const (
36-
readmeURL = "https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/elasticsearchreceiver/README.md"
37-
)
3833

39-
var (
40-
emitNodeVersionAttr = featuregate.GlobalRegistry().MustRegister(
34+
_ = featuregate.GlobalRegistry().MustRegister(
4135
"receiver.elasticsearch.emitNodeVersionAttr",
42-
featuregate.StageBeta,
43-
featuregate.WithRegisterDescription("When enabled, all node metrics will be enriched with the node version resource attribute."),
36+
featuregate.StageStable,
37+
featuregate.WithRegisterToVersion("0.82.0"),
38+
featuregate.WithRegisterDescription("All node metrics will be enriched with the node version resource attribute."),
4439
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/16847"),
4540
)
4641
)
@@ -54,29 +49,17 @@ type elasticsearchScraper struct {
5449
mb *metadata.MetricsBuilder
5550
version *version.Version
5651
clusterName string
57-
58-
// Feature gates
59-
emitNodeVersionAttr bool
6052
}
6153

6254
func newElasticSearchScraper(
6355
settings receiver.CreateSettings,
6456
cfg *Config,
6557
) *elasticsearchScraper {
66-
e := &elasticsearchScraper{
67-
settings: settings.TelemetrySettings,
68-
cfg: cfg,
69-
mb: metadata.NewMetricsBuilder(cfg.MetricsBuilderConfig, settings),
70-
emitNodeVersionAttr: emitNodeVersionAttr.IsEnabled(),
71-
}
72-
73-
if !e.emitNodeVersionAttr {
74-
settings.Logger.Warn(
75-
fmt.Sprintf("Feature gate %s is not enabled. Please see the README for more information: %s", emitNodeVersionAttr.ID(), readmeURL),
76-
)
58+
return &elasticsearchScraper{
59+
settings: settings.TelemetrySettings,
60+
cfg: cfg,
61+
mb: metadata.NewMetricsBuilder(cfg.MetricsBuilderConfig, settings),
7762
}
78-
79-
return e
8063
}
8164

8265
func (r *elasticsearchScraper) start(_ context.Context, host component.Host) (err error) {
@@ -128,15 +111,12 @@ func (r *elasticsearchScraper) scrapeNodeMetrics(ctx context.Context, now pcommo
128111
return
129112
}
130113

131-
var nodesInfo *model.Nodes
132-
if r.emitNodeVersionAttr {
133-
// Certain node metadata is not available from the /_nodes/stats endpoint. Therefore, we need to get this metadata
134-
// from the /_nodes endpoint. The metadata may or may not be used depending on feature gates.
135-
nodesInfo, err = r.client.Nodes(ctx, r.cfg.Nodes)
136-
if err != nil {
137-
errs.AddPartial(26, err)
138-
return
139-
}
114+
// Certain node metadata is not available from the /_nodes/stats endpoint. Therefore, we need to get this metadata
115+
// from the /_nodes endpoint.
116+
nodesInfo, err := r.client.Nodes(ctx, r.cfg.Nodes)
117+
if err != nil {
118+
errs.AddPartial(26, err)
119+
return
140120
}
141121

142122
for id, info := range nodeStats.Nodes {
@@ -346,10 +326,8 @@ func (r *elasticsearchScraper) scrapeNodeMetrics(ctx context.Context, now pcommo
346326
metadata.WithElasticsearchNodeName(info.Name),
347327
}
348328

349-
if r.emitNodeVersionAttr {
350-
if node, ok := nodesInfo.Nodes[id]; ok {
351-
nodeMetadata = append(nodeMetadata, metadata.WithElasticsearchNodeVersion(node.Version))
352-
}
329+
if node, ok := nodesInfo.Nodes[id]; ok {
330+
nodeMetadata = append(nodeMetadata, metadata.WithElasticsearchNodeVersion(node.Version))
353331
}
354332

355333
r.mb.EmitForResource(nodeMetadata...)

receiver/elasticsearchreceiver/scraper_test.go

-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"go.opentelemetry.io/collector/component/componenttest"
1616
"go.opentelemetry.io/collector/config/confighttp"
1717
"go.opentelemetry.io/collector/config/configtls"
18-
"go.opentelemetry.io/collector/featuregate"
1918
"go.opentelemetry.io/collector/receiver/receivertest"
2019
"go.opentelemetry.io/collector/receiver/scrapererror"
2120

@@ -29,13 +28,6 @@ const fullExpectedMetricsPath = "./testdata/expected_metrics/full.yaml"
2928
const skipClusterExpectedMetricsPath = "./testdata/expected_metrics/clusterSkip.yaml"
3029
const noNodesExpectedMetricsPath = "./testdata/expected_metrics/noNodes.yaml"
3130

32-
func TestMain(m *testing.M) {
33-
// Enable the feature gates before all tests to avoid flaky tests.
34-
_ = featuregate.GlobalRegistry().Set(emitNodeVersionAttr.ID(), true)
35-
code := m.Run()
36-
os.Exit(code)
37-
}
38-
3931
func TestScraper(t *testing.T) {
4032
t.Parallel()
4133

0 commit comments

Comments
 (0)