Skip to content

Commit 9d5526c

Browse files
authored
[receiver/nginx] Bump 'receiver.nginx.emitConnectionsCurrentAsSum' featuregate to beta (open-telemetry#23255)
1 parent bbea8aa commit 9d5526c

12 files changed

+89
-67
lines changed

.chloggen/nginx-beta-featuregate.yaml

+20
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: nginxreceiver
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.nginx.emitConnectionsCurrentAsSum' featuregate to beta (enabled by default)
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: [4326]
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:

receiver/nginxreceiver/documentation.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ The total number of accepted client connections
2424
2525
The current number of nginx connections by state
2626
27-
| Unit | Metric Type | Value Type |
28-
| ---- | ----------- | ---------- |
29-
| connections | Gauge | Int |
27+
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
28+
| ---- | ----------- | ---------- | ----------------------- | --------- |
29+
| connections | Sum | Int | Cumulative | false |
3030
3131
#### Attributes
3232
@@ -52,11 +52,11 @@ Total number of requests made to the server since it started
5252
5353
### temp.connections_current
5454
55-
Temporary placeholder for new version of nginx.connections_current. See featuregate 'nginx.connections_as_sum'.
55+
Temporary placeholder for old version of nginx.connections_current. See featuregate 'nginx.connections_as_sum'.
5656
57-
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
58-
| ---- | ----------- | ---------- | ----------------------- | --------- |
59-
| connections | Sum | Int | Cumulative | false |
57+
| Unit | Metric Type | Value Type |
58+
| ---- | ----------- | ---------- |
59+
| connections | Gauge | Int |
6060
6161
#### Attributes
6262

receiver/nginxreceiver/factory.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323

2424
var connectorsAsSumGate = featuregate.GlobalRegistry().MustRegister(
2525
connectionsAsSum,
26-
featuregate.StageAlpha,
26+
featuregate.StageBeta,
2727
featuregate.WithRegisterDescription("When enabled, the receiver will emit the 'nginx.connections_current' metric as a nonmonotonic sum, rather than a gauge."),
2828
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/4326"),
2929
featuregate.WithRegisterFromVersion("v0.78.0"),

receiver/nginxreceiver/internal/metadata/generated_metrics.go

+15-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/nginxreceiver/internal/metadata/generated_metrics_test.go

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/nginxreceiver/internal/metadata/temporary_metrics.go

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/nginxreceiver/metadata.yaml

+6-8
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,21 @@ metrics:
4444
monotonic: true
4545
aggregation: cumulative
4646
attributes: []
47-
48-
# Old version of metric, to be enabled when featuregate is stable
4947
nginx.connections_current:
5048
enabled: true
5149
description: The current number of nginx connections by state
5250
unit: connections
53-
gauge:
51+
sum:
5452
value_type: int
53+
monotonic: false
54+
aggregation: cumulative
5555
attributes: [state]
5656

57-
# New version of metric, to be enabled when featuregate is stable
57+
# Old version of metric, to be removed when featuregate is stable
5858
temp.connections_current:
5959
enabled: true # must be enabled by default in order to apply necessary MetricBuilder option
60-
description: Temporary placeholder for new version of nginx.connections_current. See featuregate 'nginx.connections_as_sum'.
60+
description: Temporary placeholder for old version of nginx.connections_current. See featuregate 'nginx.connections_as_sum'.
6161
unit: connections
62-
sum:
62+
gauge:
6363
value_type: int
64-
monotonic: false
65-
aggregation: cumulative
6664
attributes: [state]

receiver/nginxreceiver/scraper.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ func newNginxScraper(
3333
) *nginxScraper {
3434
var mb *metadata.MetricsBuilder
3535
if connectorsAsSumGate.IsEnabled() {
36-
mb = metadata.NewMetricsBuilder(cfg.MetricsBuilderConfig, settings, metadata.WithCurrentConnectionsAsSum())
36+
mb = metadata.NewMetricsBuilder(cfg.MetricsBuilderConfig, settings, metadata.WithCurrentConnectionsAsGaugeDisabled())
3737
} else {
38-
mb = metadata.NewMetricsBuilder(cfg.MetricsBuilderConfig, settings, metadata.WithCurrentConnectionsAsSumDisabled())
38+
mb = metadata.NewMetricsBuilder(cfg.MetricsBuilderConfig, settings, metadata.WithCurrentConnectionsAsGauge())
3939
}
4040
return &nginxScraper{
4141
settings: settings.TelemetrySettings,
@@ -78,15 +78,15 @@ func (r *nginxScraper) scrape(context.Context) (pmetric.Metrics, error) {
7878
r.mb.RecordNginxConnectionsHandledDataPoint(now, stats.Connections.Handled)
7979

8080
if connectorsAsSumGate.IsEnabled() {
81-
r.mb.RecordTempConnectionsCurrentDataPoint(now, stats.Connections.Active, metadata.AttributeStateActive)
82-
r.mb.RecordTempConnectionsCurrentDataPoint(now, stats.Connections.Reading, metadata.AttributeStateReading)
83-
r.mb.RecordTempConnectionsCurrentDataPoint(now, stats.Connections.Writing, metadata.AttributeStateWriting)
84-
r.mb.RecordTempConnectionsCurrentDataPoint(now, stats.Connections.Waiting, metadata.AttributeStateWaiting)
85-
} else {
8681
r.mb.RecordNginxConnectionsCurrentDataPoint(now, stats.Connections.Active, metadata.AttributeStateActive)
8782
r.mb.RecordNginxConnectionsCurrentDataPoint(now, stats.Connections.Reading, metadata.AttributeStateReading)
8883
r.mb.RecordNginxConnectionsCurrentDataPoint(now, stats.Connections.Writing, metadata.AttributeStateWriting)
8984
r.mb.RecordNginxConnectionsCurrentDataPoint(now, stats.Connections.Waiting, metadata.AttributeStateWaiting)
85+
} else {
86+
r.mb.RecordTempConnectionsCurrentDataPoint(now, stats.Connections.Active, metadata.AttributeStateActive)
87+
r.mb.RecordTempConnectionsCurrentDataPoint(now, stats.Connections.Reading, metadata.AttributeStateReading)
88+
r.mb.RecordTempConnectionsCurrentDataPoint(now, stats.Connections.Writing, metadata.AttributeStateWriting)
89+
r.mb.RecordTempConnectionsCurrentDataPoint(now, stats.Connections.Waiting, metadata.AttributeStateWaiting)
9090
}
9191

9292
return r.mb.Emit(), nil

receiver/nginxreceiver/scraper_test.go

+12-10
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,22 @@ func TestScraper(t *testing.T) {
4141
expectedMetrics, err := golden.ReadMetrics(expectedFile)
4242
require.NoError(t, err)
4343

44-
require.NoError(t, pmetrictest.CompareMetrics(expectedMetrics, actualMetrics, pmetrictest.IgnoreStartTimestamp(),
44+
require.NoError(t, pmetrictest.CompareMetrics(expectedMetrics, actualMetrics,
45+
pmetrictest.IgnoreStartTimestamp(),
4546
pmetrictest.IgnoreMetricDataPointsOrder(),
46-
pmetrictest.IgnoreMetricDataPointsOrder(),
47-
pmetrictest.IgnoreTimestamp()))
47+
pmetrictest.IgnoreTimestamp(),
48+
pmetrictest.IgnoreMetricsOrder()))
4849
}
4950

50-
func TestScraperWithConnectionsAsSum(t *testing.T) {
51+
func TestScraperWithConnectionsAsGauge(t *testing.T) {
5152
nginxMock := newMockServer(t)
5253
cfg := createDefaultConfig().(*Config)
5354
cfg.Endpoint = nginxMock.URL + "/status"
5455
require.NoError(t, component.ValidateConfig(cfg))
5556

56-
require.NoError(t, featuregate.GlobalRegistry().Set(connectionsAsSum, true))
57+
require.NoError(t, featuregate.GlobalRegistry().Set(connectionsAsSum, false))
5758
defer func() {
58-
require.NoError(t, featuregate.GlobalRegistry().Set(connectionsAsSum, false))
59+
require.NoError(t, featuregate.GlobalRegistry().Set(connectionsAsSum, true))
5960
}()
6061

6162
scraper := newNginxScraper(receivertest.NewNopCreateSettings(), cfg)
@@ -66,14 +67,15 @@ func TestScraperWithConnectionsAsSum(t *testing.T) {
6667
actualMetrics, err := scraper.scrape(context.Background())
6768
require.NoError(t, err)
6869

69-
expectedFile := filepath.Join("testdata", "scraper", "expected_with_connections_as_sum.yaml")
70+
expectedFile := filepath.Join("testdata", "scraper", "expected_with_connections_as_gauge.yaml")
7071
expectedMetrics, err := golden.ReadMetrics(expectedFile)
7172
require.NoError(t, err)
7273

73-
require.NoError(t, pmetrictest.CompareMetrics(expectedMetrics, actualMetrics, pmetrictest.IgnoreStartTimestamp(),
74-
pmetrictest.IgnoreMetricDataPointsOrder(),
74+
require.NoError(t, pmetrictest.CompareMetrics(expectedMetrics, actualMetrics,
75+
pmetrictest.IgnoreStartTimestamp(),
7576
pmetrictest.IgnoreMetricDataPointsOrder(),
76-
pmetrictest.IgnoreTimestamp(), pmetrictest.IgnoreMetricsOrder()))
77+
pmetrictest.IgnoreTimestamp(),
78+
pmetrictest.IgnoreMetricsOrder()))
7779
}
7880

7981
func TestScraperError(t *testing.T) {

receiver/nginxreceiver/testdata/integration/expected.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ resourceMetrics:
1212
isMonotonic: true
1313
unit: connections
1414
- description: The current number of nginx connections by state
15-
gauge:
15+
sum:
16+
aggregationTemporality: 2
1617
dataPoints:
1718
- asInt: "1"
1819
attributes:
@@ -38,6 +39,7 @@ resourceMetrics:
3839
value:
3940
stringValue: waiting
4041
timeUnixNano: "1643729289485220000"
42+
isMonotonic: false
4143
name: nginx.connections_current
4244
unit: connections
4345
- description: The total number of handled connections. Generally, the parameter value is the same as nginx.connections_accepted unless some resource limits have been reached (for example, the worker_connections limit).

receiver/nginxreceiver/testdata/scraper/expected.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ resourceMetrics:
1212
isMonotonic: true
1313
unit: connections
1414
- description: The current number of nginx connections by state
15-
gauge:
15+
name: nginx.connections_current
16+
sum:
17+
aggregationTemporality: 2
1618
dataPoints:
1719
- asInt: "291"
1820
attributes:
@@ -38,7 +40,6 @@ resourceMetrics:
3840
value:
3941
stringValue: writing
4042
timeUnixNano: "1638471548185885000"
41-
name: nginx.connections_current
4243
unit: connections
4344
- description: The total number of handled connections. Generally, the parameter value is the same as nginx.connections_accepted unless some resource limits have been reached (for example, the worker_connections limit).
4445
name: nginx.connections_handled

receiver/nginxreceiver/testdata/scraper/expected_with_connections_as_sum.yaml renamed to receiver/nginxreceiver/testdata/scraper/expected_with_connections_as_gauge.yaml

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ resourceMetrics:
1212
isMonotonic: true
1313
unit: connections
1414
- description: The current number of nginx connections by state
15-
name: nginx.connections_current
16-
sum:
17-
aggregationTemporality: 2
15+
gauge:
1816
dataPoints:
1917
- asInt: "291"
2018
attributes:
@@ -40,6 +38,7 @@ resourceMetrics:
4038
value:
4139
stringValue: writing
4240
timeUnixNano: "1638471548185885000"
41+
name: nginx.connections_current
4342
unit: connections
4443
- description: The total number of handled connections. Generally, the parameter value is the same as nginx.connections_accepted unless some resource limits have been reached (for example, the worker_connections limit).
4544
name: nginx.connections_handled

0 commit comments

Comments
 (0)