diff --git a/.chloggen/rm-direction-zookeeper.yaml b/.chloggen/rm-direction-zookeeper.yaml new file mode 100755 index 000000000000..c50218888e2a --- /dev/null +++ b/.chloggen/rm-direction-zookeeper.yaml @@ -0,0 +1,16 @@ +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: zookeeperreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: "removing direction feature gate" + +# One or more tracking issues related to the change +issues: [14962] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/receiver/zookeeperreceiver/README.md b/receiver/zookeeperreceiver/README.md index 3890d3f507e9..501e5c5c2ad9 100644 --- a/receiver/zookeeperreceiver/README.md +++ b/receiver/zookeeperreceiver/README.md @@ -27,17 +27,5 @@ receivers: Details about the metrics produced by this receiver can be found in [metadata.yaml](./metadata.yaml) with further documentation in [documentation.md](./documentation.md) -### Feature gate configurations - -#### Transition from metrics with "direction" attribute - -The proposal to change metrics from being reported with a `direction` attribute has been reverted in the specification. As a result, the -following feature gates will be removed in v0.62.0: - -- **receiver.zookeeperreceiver.emitMetricsWithoutDirectionAttribute** -- **receiver.zookeeperreceiver.emitMetricsWithDirectionAttribute** - -For additional information, see https://github.com/open-telemetry/opentelemetry-specification/issues/2726. - [in development]: https://github.com/open-telemetry/opentelemetry-collector#in-development [contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib diff --git a/receiver/zookeeperreceiver/documentation.md b/receiver/zookeeperreceiver/documentation.md index 51061040a7c6..6d23c2cf59dd 100644 --- a/receiver/zookeeperreceiver/documentation.md +++ b/receiver/zookeeperreceiver/documentation.md @@ -19,8 +19,6 @@ These are the metrics available for this scraper. | **zookeeper.latency.max** | Maximum time in milliseconds for requests to be processed. | ms | Gauge(Int) | | | **zookeeper.latency.min** | Minimum time in milliseconds for requests to be processed. | ms | Gauge(Int) | | | **zookeeper.packet.count** | The number of ZooKeeper packets received or sent by a server. | {packets} | Sum(Int) | | -| **zookeeper.packet.received.count** | The number of ZooKeeper packets received by a server. | {packets} | Sum(Int) | | -| **zookeeper.packet.sent.count** | The number of ZooKeeper packets sent by a server. | {packets} | Sum(Int) | | | **zookeeper.request.active** | Number of currently executing requests. | {requests} | Sum(Int) | | | **zookeeper.sync.pending** | The number of pending syncs from the followers. Only exposed by the leader. | {syncs} | Sum(Int) | | | **zookeeper.watch.count** | Number of watches placed on Z-Nodes on a ZooKeeper server. | {watches} | Sum(Int) | | diff --git a/receiver/zookeeperreceiver/internal/metadata/generated_metrics.go b/receiver/zookeeperreceiver/internal/metadata/generated_metrics.go index 56695743a13c..a9b770c593b1 100644 --- a/receiver/zookeeperreceiver/internal/metadata/generated_metrics.go +++ b/receiver/zookeeperreceiver/internal/metadata/generated_metrics.go @@ -28,8 +28,6 @@ type MetricsSettings struct { ZookeeperLatencyMax MetricSettings `mapstructure:"zookeeper.latency.max"` ZookeeperLatencyMin MetricSettings `mapstructure:"zookeeper.latency.min"` ZookeeperPacketCount MetricSettings `mapstructure:"zookeeper.packet.count"` - ZookeeperPacketReceivedCount MetricSettings `mapstructure:"zookeeper.packet.received.count"` - ZookeeperPacketSentCount MetricSettings `mapstructure:"zookeeper.packet.sent.count"` ZookeeperRequestActive MetricSettings `mapstructure:"zookeeper.request.active"` ZookeeperSyncPending MetricSettings `mapstructure:"zookeeper.sync.pending"` ZookeeperWatchCount MetricSettings `mapstructure:"zookeeper.watch.count"` @@ -71,12 +69,6 @@ func DefaultMetricsSettings() MetricsSettings { ZookeeperPacketCount: MetricSettings{ Enabled: true, }, - ZookeeperPacketReceivedCount: MetricSettings{ - Enabled: true, - }, - ZookeeperPacketSentCount: MetricSettings{ - Enabled: true, - }, ZookeeperRequestActive: MetricSettings{ Enabled: true, }, @@ -701,108 +693,6 @@ func newMetricZookeeperPacketCount(settings MetricSettings) metricZookeeperPacke return m } -type metricZookeeperPacketReceivedCount struct { - data pmetric.Metric // data buffer for generated metric. - settings MetricSettings // metric settings provided by user. - capacity int // max observed number of data points added to the metric. -} - -// init fills zookeeper.packet.received.count metric with initial data. -func (m *metricZookeeperPacketReceivedCount) init() { - m.data.SetName("zookeeper.packet.received.count") - m.data.SetDescription("The number of ZooKeeper packets received by a server.") - m.data.SetUnit("{packets}") - m.data.SetEmptySum() - m.data.Sum().SetIsMonotonic(true) - m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) -} - -func (m *metricZookeeperPacketReceivedCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { - if !m.settings.Enabled { - return - } - dp := m.data.Sum().DataPoints().AppendEmpty() - dp.SetStartTimestamp(start) - dp.SetTimestamp(ts) - dp.SetIntValue(val) -} - -// updateCapacity saves max length of data point slices that will be used for the slice capacity. -func (m *metricZookeeperPacketReceivedCount) updateCapacity() { - if m.data.Sum().DataPoints().Len() > m.capacity { - m.capacity = m.data.Sum().DataPoints().Len() - } -} - -// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. -func (m *metricZookeeperPacketReceivedCount) emit(metrics pmetric.MetricSlice) { - if m.settings.Enabled && m.data.Sum().DataPoints().Len() > 0 { - m.updateCapacity() - m.data.MoveTo(metrics.AppendEmpty()) - m.init() - } -} - -func newMetricZookeeperPacketReceivedCount(settings MetricSettings) metricZookeeperPacketReceivedCount { - m := metricZookeeperPacketReceivedCount{settings: settings} - if settings.Enabled { - m.data = pmetric.NewMetric() - m.init() - } - return m -} - -type metricZookeeperPacketSentCount struct { - data pmetric.Metric // data buffer for generated metric. - settings MetricSettings // metric settings provided by user. - capacity int // max observed number of data points added to the metric. -} - -// init fills zookeeper.packet.sent.count metric with initial data. -func (m *metricZookeeperPacketSentCount) init() { - m.data.SetName("zookeeper.packet.sent.count") - m.data.SetDescription("The number of ZooKeeper packets sent by a server.") - m.data.SetUnit("{packets}") - m.data.SetEmptySum() - m.data.Sum().SetIsMonotonic(true) - m.data.Sum().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) -} - -func (m *metricZookeeperPacketSentCount) recordDataPoint(start pcommon.Timestamp, ts pcommon.Timestamp, val int64) { - if !m.settings.Enabled { - return - } - dp := m.data.Sum().DataPoints().AppendEmpty() - dp.SetStartTimestamp(start) - dp.SetTimestamp(ts) - dp.SetIntValue(val) -} - -// updateCapacity saves max length of data point slices that will be used for the slice capacity. -func (m *metricZookeeperPacketSentCount) updateCapacity() { - if m.data.Sum().DataPoints().Len() > m.capacity { - m.capacity = m.data.Sum().DataPoints().Len() - } -} - -// emit appends recorded metric data to a metrics slice and prepares it for recording another set of data points. -func (m *metricZookeeperPacketSentCount) emit(metrics pmetric.MetricSlice) { - if m.settings.Enabled && m.data.Sum().DataPoints().Len() > 0 { - m.updateCapacity() - m.data.MoveTo(metrics.AppendEmpty()) - m.init() - } -} - -func newMetricZookeeperPacketSentCount(settings MetricSettings) metricZookeeperPacketSentCount { - m := metricZookeeperPacketSentCount{settings: settings} - if settings.Enabled { - m.data = pmetric.NewMetric() - m.init() - } - return m -} - type metricZookeeperRequestActive struct { data pmetric.Metric // data buffer for generated metric. settings MetricSettings // metric settings provided by user. @@ -1026,8 +916,6 @@ type MetricsBuilder struct { metricZookeeperLatencyMax metricZookeeperLatencyMax metricZookeeperLatencyMin metricZookeeperLatencyMin metricZookeeperPacketCount metricZookeeperPacketCount - metricZookeeperPacketReceivedCount metricZookeeperPacketReceivedCount - metricZookeeperPacketSentCount metricZookeeperPacketSentCount metricZookeeperRequestActive metricZookeeperRequestActive metricZookeeperSyncPending metricZookeeperSyncPending metricZookeeperWatchCount metricZookeeperWatchCount @@ -1060,8 +948,6 @@ func NewMetricsBuilder(settings MetricsSettings, buildInfo component.BuildInfo, metricZookeeperLatencyMax: newMetricZookeeperLatencyMax(settings.ZookeeperLatencyMax), metricZookeeperLatencyMin: newMetricZookeeperLatencyMin(settings.ZookeeperLatencyMin), metricZookeeperPacketCount: newMetricZookeeperPacketCount(settings.ZookeeperPacketCount), - metricZookeeperPacketReceivedCount: newMetricZookeeperPacketReceivedCount(settings.ZookeeperPacketReceivedCount), - metricZookeeperPacketSentCount: newMetricZookeeperPacketSentCount(settings.ZookeeperPacketSentCount), metricZookeeperRequestActive: newMetricZookeeperRequestActive(settings.ZookeeperRequestActive), metricZookeeperSyncPending: newMetricZookeeperSyncPending(settings.ZookeeperSyncPending), metricZookeeperWatchCount: newMetricZookeeperWatchCount(settings.ZookeeperWatchCount), @@ -1143,8 +1029,6 @@ func (mb *MetricsBuilder) EmitForResource(rmo ...ResourceMetricsOption) { mb.metricZookeeperLatencyMax.emit(ils.Metrics()) mb.metricZookeeperLatencyMin.emit(ils.Metrics()) mb.metricZookeeperPacketCount.emit(ils.Metrics()) - mb.metricZookeeperPacketReceivedCount.emit(ils.Metrics()) - mb.metricZookeeperPacketSentCount.emit(ils.Metrics()) mb.metricZookeeperRequestActive.emit(ils.Metrics()) mb.metricZookeeperSyncPending.emit(ils.Metrics()) mb.metricZookeeperWatchCount.emit(ils.Metrics()) @@ -1223,16 +1107,6 @@ func (mb *MetricsBuilder) RecordZookeeperPacketCountDataPoint(ts pcommon.Timesta mb.metricZookeeperPacketCount.recordDataPoint(mb.startTime, ts, val, directionAttributeValue.String()) } -// RecordZookeeperPacketReceivedCountDataPoint adds a data point to zookeeper.packet.received.count metric. -func (mb *MetricsBuilder) RecordZookeeperPacketReceivedCountDataPoint(ts pcommon.Timestamp, val int64) { - mb.metricZookeeperPacketReceivedCount.recordDataPoint(mb.startTime, ts, val) -} - -// RecordZookeeperPacketSentCountDataPoint adds a data point to zookeeper.packet.sent.count metric. -func (mb *MetricsBuilder) RecordZookeeperPacketSentCountDataPoint(ts pcommon.Timestamp, val int64) { - mb.metricZookeeperPacketSentCount.recordDataPoint(mb.startTime, ts, val) -} - // RecordZookeeperRequestActiveDataPoint adds a data point to zookeeper.request.active metric. func (mb *MetricsBuilder) RecordZookeeperRequestActiveDataPoint(ts pcommon.Timestamp, val int64) { mb.metricZookeeperRequestActive.recordDataPoint(mb.startTime, ts, val) diff --git a/receiver/zookeeperreceiver/metadata.yaml b/receiver/zookeeperreceiver/metadata.yaml index e343c51240d0..3778c6614287 100644 --- a/receiver/zookeeperreceiver/metadata.yaml +++ b/receiver/zookeeperreceiver/metadata.yaml @@ -118,7 +118,6 @@ metrics: unit: "{file_descriptors}" gauge: value_type: int - # produced when receiver.zookeeperreceiver.emitMetricsWithDirectionAttribute feature gate is enabled zookeeper.packet.count: enabled: true description: The number of ZooKeeper packets received or sent by a server. @@ -128,24 +127,6 @@ metrics: value_type: int monotonic: true aggregation: cumulative - # produced when receiver.zookeeperreceiver.emitMetricsWithoutDirectionAttribute feature gate is enabled - zookeeper.packet.sent.count: - enabled: true - description: The number of ZooKeeper packets sent by a server. - unit: "{packets}" - sum: - value_type: int - monotonic: true - aggregation: cumulative - # produced when receiver.zookeeperreceiver.emitMetricsWithoutDirectionAttribute feature gate is enabled - zookeeper.packet.received.count: - enabled: true - description: The number of ZooKeeper packets received by a server. - unit: "{packets}" - sum: - value_type: int - monotonic: true - aggregation: cumulative zookeeper.fsync.exceeded_threshold.count: enabled: true description: Number of times fsync duration has exceeded warning threshold. diff --git a/receiver/zookeeperreceiver/metrics.go b/receiver/zookeeperreceiver/metrics.go index 4759f990ebe1..5d8e41b9cfa1 100644 --- a/receiver/zookeeperreceiver/metrics.go +++ b/receiver/zookeeperreceiver/metrics.go @@ -54,16 +54,12 @@ type metricCreator struct { computedMetricStore map[string]int64 mb *metadata.MetricsBuilder // Temporary feature gates while transitioning to metrics without a direction attribute - emitMetricsWithDirectionAttribute bool - emitMetricsWithoutDirectionAttribute bool } -func newMetricCreator(mb *metadata.MetricsBuilder, emitMetricsWithDirectionAttribute, emitMetricsWithoutDirectionAttribute bool) *metricCreator { +func newMetricCreator(mb *metadata.MetricsBuilder) *metricCreator { return &metricCreator{ - computedMetricStore: make(map[string]int64), - mb: mb, - emitMetricsWithDirectionAttribute: emitMetricsWithDirectionAttribute, - emitMetricsWithoutDirectionAttribute: emitMetricsWithoutDirectionAttribute, + computedMetricStore: make(map[string]int64), + mb: mb, } } @@ -106,21 +102,11 @@ func (m *metricCreator) recordDataPointsFunc(metric string) func(ts pcommon.Time return m.mb.RecordZookeeperFsyncExceededThresholdCountDataPoint case packetsReceivedMetricKey: return func(ts pcommon.Timestamp, val int64) { - if m.emitMetricsWithDirectionAttribute { - m.mb.RecordZookeeperPacketCountDataPoint(ts, val, metadata.AttributeDirectionReceived) - } - if m.emitMetricsWithoutDirectionAttribute { - m.mb.RecordZookeeperPacketReceivedCountDataPoint(ts, val) - } + m.mb.RecordZookeeperPacketCountDataPoint(ts, val, metadata.AttributeDirectionReceived) } case packetsSentMetricKey: return func(ts pcommon.Timestamp, val int64) { - if m.emitMetricsWithDirectionAttribute { - m.mb.RecordZookeeperPacketCountDataPoint(ts, val, metadata.AttributeDirectionSent) - } - if m.emitMetricsWithoutDirectionAttribute { - m.mb.RecordZookeeperPacketSentCountDataPoint(ts, val) - } + m.mb.RecordZookeeperPacketCountDataPoint(ts, val, metadata.AttributeDirectionSent) } } diff --git a/receiver/zookeeperreceiver/scraper.go b/receiver/zookeeperreceiver/scraper.go index ce1038d491b8..618477ce24a4 100644 --- a/receiver/zookeeperreceiver/scraper.go +++ b/receiver/zookeeperreceiver/scraper.go @@ -25,7 +25,6 @@ import ( "time" "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/featuregate" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/pmetric" "go.uber.org/zap" @@ -36,38 +35,9 @@ import ( var zookeeperFormatRE = regexp.MustCompile(`(^zk_\w+)\s+([\w\.\-]+)`) const ( - mntrCommand = "mntr" - emitMetricsWithDirectionAttributeFeatureGateID = "receiver.zookeeperreceiver.emitMetricsWithDirectionAttribute" - emitMetricsWithoutDirectionAttributeFeatureGateID = "receiver.zookeeperreceiver.emitMetricsWithoutDirectionAttribute" + mntrCommand = "mntr" ) -var ( - emitMetricsWithDirectionAttributeFeatureGate = featuregate.Gate{ - ID: emitMetricsWithDirectionAttributeFeatureGateID, - Enabled: true, - Description: "Some zookeeper metrics reported are transitioning from being reported with a direction " + - "attribute to being reported with the direction included in the metric name to adhere to the " + - "OpenTelemetry specification. This feature gate controls emitting the old metrics with the direction " + - "attribute. For more details, see: " + - "https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/zookeeperreceiver/README.md#feature-gate-configurations", - } - - emitMetricsWithoutDirectionAttributeFeatureGate = featuregate.Gate{ - ID: emitMetricsWithoutDirectionAttributeFeatureGateID, - Enabled: false, - Description: "Some zookeeper metrics reported are transitioning from being reported with a direction " + - "attribute to being reported with the direction included in the metric name to adhere to the " + - "OpenTelemetry specification. This feature gate controls emitting the new metrics without the direction " + - "attribute. For more details, see: " + - "https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/zookeeperreceiver/README.md#feature-gate-configurations", - } -) - -func init() { - featuregate.GetRegistry().MustRegister(emitMetricsWithDirectionAttributeFeatureGate) - featuregate.GetRegistry().MustRegister(emitMetricsWithoutDirectionAttributeFeatureGate) -} - type zookeeperMetricsScraper struct { logger *zap.Logger config *Config @@ -78,22 +48,12 @@ type zookeeperMetricsScraper struct { closeConnection func(net.Conn) error setConnectionDeadline func(net.Conn, time.Time) error sendCmd func(net.Conn, string) (*bufio.Scanner, error) - - // Feature gates while transitioning to metrics without a direction attribute - emitMetricsWithDirectionAttribute bool - emitMetricsWithoutDirectionAttribute bool } func (z *zookeeperMetricsScraper) Name() string { return typeStr } -func logDeprecatedFeatureGateForDirection(log *zap.Logger, gate featuregate.Gate) { - log.Warn("WARNING: The " + gate.ID + " feature gate is deprecated and will be removed in the next release. The change to remove " + - "the direction attribute has been reverted in the specification. See https://github.com/open-telemetry/opentelemetry-specification/issues/2726 " + - "for additional details.") -} - func newZookeeperMetricsScraper(settings component.ReceiverCreateSettings, config *Config) (*zookeeperMetricsScraper, error) { _, _, err := net.SplitHostPort(config.TCPAddr.Endpoint) if err != nil { @@ -105,22 +65,12 @@ func newZookeeperMetricsScraper(settings component.ReceiverCreateSettings, confi } z := &zookeeperMetricsScraper{ - logger: settings.Logger, - config: config, - mb: metadata.NewMetricsBuilder(config.Metrics, settings.BuildInfo), - closeConnection: closeConnection, - setConnectionDeadline: setConnectionDeadline, - sendCmd: sendCmd, - emitMetricsWithDirectionAttribute: featuregate.GetRegistry().IsEnabled(emitMetricsWithDirectionAttributeFeatureGateID), - emitMetricsWithoutDirectionAttribute: featuregate.GetRegistry().IsEnabled(emitMetricsWithoutDirectionAttributeFeatureGateID), - } - - if !z.emitMetricsWithDirectionAttribute { - logDeprecatedFeatureGateForDirection(z.logger, emitMetricsWithDirectionAttributeFeatureGate) - } - - if z.emitMetricsWithoutDirectionAttribute { - logDeprecatedFeatureGateForDirection(z.logger, emitMetricsWithoutDirectionAttributeFeatureGate) + logger: settings.Logger, + config: config, + mb: metadata.NewMetricsBuilder(config.Metrics, settings.BuildInfo), + closeConnection: closeConnection, + setConnectionDeadline: setConnectionDeadline, + sendCmd: sendCmd, } return z, nil @@ -172,7 +122,7 @@ func (z *zookeeperMetricsScraper) getResourceMetrics(conn net.Conn) (pmetric.Met return pmetric.NewMetrics(), err } - creator := newMetricCreator(z.mb, z.emitMetricsWithDirectionAttribute, z.emitMetricsWithoutDirectionAttribute) + creator := newMetricCreator(z.mb) now := pcommon.NewTimestampFromTime(time.Now()) resourceOpts := make([]metadata.ResourceMetricsOption, 0, 2) for scanner.Scan() { diff --git a/receiver/zookeeperreceiver/scraper_test.go b/receiver/zookeeperreceiver/scraper_test.go index abba0ad1db7e..639055bf138f 100644 --- a/receiver/zookeeperreceiver/scraper_test.go +++ b/receiver/zookeeperreceiver/scraper_test.go @@ -28,7 +28,6 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component/componenttest" - "go.opentelemetry.io/collector/featuregate" "go.opentelemetry.io/collector/pdata/pmetric" "go.uber.org/zap" "go.uber.org/zap/zapcore" @@ -50,40 +49,19 @@ func TestZookeeperMetricsScraperScrape(t *testing.T) { t.Skip("skipping flaky test on windows, see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/10171") } - // additional temporary log messages expected while transitioning to metrics without a direction attribute - expectedLogsWithDirectionAttribute := []logMsg{ - { - msg: "WARNING: The " + emitMetricsWithDirectionAttributeFeatureGate.ID + " feature gate is deprecated and will be removed in the next release. The change to remove " + - "the direction attribute has been reverted in the specification. See https://github.com/open-telemetry/opentelemetry-specification/issues/2726 " + - "for additional details.", - level: zapcore.WarnLevel, - }, - } - - expectedLogsWithoutDirectionAttribute := []logMsg{ - { - msg: "WARNING: The " + emitMetricsWithoutDirectionAttributeFeatureGate.ID + " feature gate is deprecated and will be removed in the next release. The change to remove " + - "the direction attribute has been reverted in the specification. See https://github.com/open-telemetry/opentelemetry-specification/issues/2726 " + - "for additional details.", - level: zapcore.WarnLevel, - }, - } - tests := []struct { - name string - expectedMetricsFilename string - expectedResourceAttributes map[string]string - metricsSettings func() metadata.MetricsSettings - mockedZKOutputSourceFilename string - mockZKConnectionErr bool - expectedLogs []logMsg - expectedNumResourceMetrics int - setConnectionDeadline func(net.Conn, time.Time) error - closeConnection func(net.Conn) error - sendCmd func(net.Conn, string) (*bufio.Scanner, error) - wantErr bool - emitMetricsWithDirectionAttribute bool - emitMetricsWithoutDirectionAttribute bool + name string + expectedMetricsFilename string + expectedResourceAttributes map[string]string + metricsSettings func() metadata.MetricsSettings + mockedZKOutputSourceFilename string + mockZKConnectionErr bool + expectedLogs []logMsg + expectedNumResourceMetrics int + setConnectionDeadline func(net.Conn, time.Time) error + closeConnection func(net.Conn) error + sendCmd func(net.Conn, string) (*bufio.Scanner, error) + wantErr bool }{ { name: "Test correctness with v3.4.14", @@ -99,27 +77,7 @@ func TestZookeeperMetricsScraperScrape(t *testing.T) { level: zapcore.DebugLevel, }, }, - expectedNumResourceMetrics: 1, - emitMetricsWithDirectionAttribute: true, - emitMetricsWithoutDirectionAttribute: false, - }, - { - name: "Test correctness with v3.4.14 without direction attribute", - mockedZKOutputSourceFilename: "mntr-3.4.14", - expectedMetricsFilename: "correctness-v3.4.14-without-direction", - expectedResourceAttributes: map[string]string{ - "server.state": "standalone", - "zk.version": "3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf", - }, - expectedLogs: []logMsg{ - { - msg: "metric computation failed", - level: zapcore.DebugLevel, - }, - }, - expectedNumResourceMetrics: 1, - emitMetricsWithDirectionAttribute: false, - emitMetricsWithoutDirectionAttribute: true, + expectedNumResourceMetrics: 1, }, { name: "Test correctness with v3.5.5", @@ -129,21 +87,7 @@ func TestZookeeperMetricsScraperScrape(t *testing.T) { "server.state": "leader", "zk.version": "3.5.5-390fe37ea45dee01bf87dc1c042b5e3dcce88653", }, - expectedNumResourceMetrics: 1, - emitMetricsWithDirectionAttribute: true, - emitMetricsWithoutDirectionAttribute: false, - }, - { - name: "Test correctness with v3.5.5 without direction attribute", - mockedZKOutputSourceFilename: "mntr-3.5.5", - expectedMetricsFilename: "correctness-v3.5.5-without-direction", - expectedResourceAttributes: map[string]string{ - "server.state": "leader", - "zk.version": "3.5.5-390fe37ea45dee01bf87dc1c042b5e3dcce88653", - }, - expectedNumResourceMetrics: 1, - emitMetricsWithDirectionAttribute: false, - emitMetricsWithoutDirectionAttribute: true, + expectedNumResourceMetrics: 1, }, { name: "Arbitrary connection error", @@ -208,8 +152,6 @@ func TestZookeeperMetricsScraperScrape(t *testing.T) { setConnectionDeadline: func(conn net.Conn, t time.Time) error { return errors.New("") }, - emitMetricsWithDirectionAttribute: true, - emitMetricsWithoutDirectionAttribute: false, }, { name: "Error closing connection", @@ -233,8 +175,6 @@ func TestZookeeperMetricsScraperScrape(t *testing.T) { closeConnection: func(conn net.Conn) error { return errors.New("") }, - emitMetricsWithDirectionAttribute: true, - emitMetricsWithoutDirectionAttribute: false, }, { name: "Failed to send command", @@ -268,9 +208,7 @@ func TestZookeeperMetricsScraperScrape(t *testing.T) { level: zapcore.DebugLevel, }, }, - expectedNumResourceMetrics: 1, - emitMetricsWithDirectionAttribute: true, - emitMetricsWithoutDirectionAttribute: false, + expectedNumResourceMetrics: 1, }, } for _, tt := range tests { @@ -288,8 +226,6 @@ func TestZookeeperMetricsScraperScrape(t *testing.T) { cfg.Metrics = tt.metricsSettings() } - require.NoError(t, featuregate.GetRegistry().Apply(map[string]bool{emitMetricsWithDirectionAttributeFeatureGate.ID: tt.emitMetricsWithDirectionAttribute})) - require.NoError(t, featuregate.GetRegistry().Apply(map[string]bool{emitMetricsWithoutDirectionAttributeFeatureGate.ID: tt.emitMetricsWithoutDirectionAttribute})) core, observedLogs := observer.New(zap.DebugLevel) settings := componenttest.NewNopReceiverCreateSettings() settings.Logger = zap.New(core) @@ -314,20 +250,8 @@ func TestZookeeperMetricsScraperScrape(t *testing.T) { actualMetrics, err := z.scrape(ctx) require.NoError(t, z.shutdown(ctx)) - var expectedLogs []logMsg - - if !tt.emitMetricsWithDirectionAttribute { - expectedLogs = append(expectedLogs, expectedLogsWithDirectionAttribute...) - } - - if tt.emitMetricsWithoutDirectionAttribute { - expectedLogs = append(expectedLogs, expectedLogsWithoutDirectionAttribute...) - } - - expectedLogs = append(expectedLogs, tt.expectedLogs...) - - require.Equal(t, len(expectedLogs), observedLogs.Len()) - for i, log := range expectedLogs { + require.Equal(t, len(tt.expectedLogs), observedLogs.Len()) + for i, log := range tt.expectedLogs { require.Equal(t, log.msg, observedLogs.All()[i].Message) require.Equal(t, log.level, observedLogs.All()[i].Level) } diff --git a/receiver/zookeeperreceiver/testdata/scraper/correctness-v3.4.14-without-direction.json b/receiver/zookeeperreceiver/testdata/scraper/correctness-v3.4.14-without-direction.json deleted file mode 100644 index 6774cdf4a347..000000000000 --- a/receiver/zookeeperreceiver/testdata/scraper/correctness-v3.4.14-without-direction.json +++ /dev/null @@ -1,242 +0,0 @@ -{ - "resourceMetrics": [ - { - "scopeMetrics": [ - { - "scope": { - "name": "otelcol/zookeeperreceiver", - "version": "latest" - }, - "metrics": [ - { - "description": "Number of active clients connected to a ZooKeeper server.", - "name": "zookeeper.connection.active", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "1", - "startTimeUnixNano": "1642685966444471000", - "timeUnixNano": "1642685966444739000" - } - ] - }, - "unit": "{connections}" - }, - { - "description": "Number of ephemeral nodes that a ZooKeeper server has in its data tree.", - "name": "zookeeper.data_tree.ephemeral_node.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966444471000", - "timeUnixNano": "1642685966444739000" - } - ] - }, - "unit": "{nodes}" - }, - { - "description": "Size of data in bytes that a ZooKeeper server has in its data tree.", - "name": "zookeeper.data_tree.size", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "27", - "startTimeUnixNano": "1642685966444471000", - "timeUnixNano": "1642685966444739000" - } - ] - }, - "unit": "By" - }, - { - "description": "Maximum number of file descriptors that a ZooKeeper server can open.", - "gauge": { - "dataPoints": [ - { - "asInt": "1048576", - "startTimeUnixNano": "1642685966444471000", - "timeUnixNano": "1642685966444739000" - } - ] - }, - "name": "zookeeper.file_descriptor.limit", - "unit": "{file_descriptors}" - }, - { - "description": "Number of file descriptors that a ZooKeeper server has open.", - "name": "zookeeper.file_descriptor.open", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "26", - "startTimeUnixNano": "1642685966444471000", - "timeUnixNano": "1642685966444739000" - } - ] - }, - "unit": "{file_descriptors}" - }, - { - "description": "Number of times fsync duration has exceeded warning threshold.", - "name": "zookeeper.fsync.exceeded_threshold.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966444471000", - "timeUnixNano": "1642685966444739000" - } - ], - "isMonotonic": true - }, - "unit": "{events}" - }, - { - "description": "Average time in milliseconds for requests to be processed.", - "gauge": { - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966444471000", - "timeUnixNano": "1642685966444739000" - } - ] - }, - "name": "zookeeper.latency.avg", - "unit": "ms" - }, - { - "description": "Maximum time in milliseconds for requests to be processed.", - "gauge": { - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966444471000", - "timeUnixNano": "1642685966444739000" - } - ] - }, - "name": "zookeeper.latency.max", - "unit": "ms" - }, - { - "description": "Minimum time in milliseconds for requests to be processed.", - "gauge": { - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966444471000", - "timeUnixNano": "1642685966444739000" - } - ] - }, - "name": "zookeeper.latency.min", - "unit": "ms" - }, - { - "description": "The number of ZooKeeper packets received by a server.", - "name": "zookeeper.packet.received.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "1", - - "startTimeUnixNano": "1642685966444471000", - "timeUnixNano": "1642685966444739000" - } - ], - "isMonotonic": true - }, - "unit": "{packets}" - }, - { - "description": "The number of ZooKeeper packets sent by a server.", - "name": "zookeeper.packet.sent.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966444471000", - "timeUnixNano": "1642685966444739000" - } - ], - "isMonotonic": true - }, - "unit": "{packets}" - }, - { - "description": "Number of currently executing requests.", - "name": "zookeeper.request.active", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966444471000", - "timeUnixNano": "1642685966444739000" - } - ] - }, - "unit": "{requests}" - }, - { - "description": "Number of watches placed on Z-Nodes on a ZooKeeper server.", - "name": "zookeeper.watch.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966444471000", - "timeUnixNano": "1642685966444739000" - } - ] - }, - "unit": "{watches}" - }, - { - "description": "Number of z-nodes that a ZooKeeper server has in its data tree.", - "name": "zookeeper.znode.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "4", - "startTimeUnixNano": "1642685966444471000", - "timeUnixNano": "1642685966444739000" - } - ] - }, - "unit": "{znodes}" - } - ] - } - ], - "resource": { - "attributes": [ - { - "key": "zk.version", - "value": { - "stringValue": "3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf" - } - }, - { - "key": "server.state", - "value": { - "stringValue": "standalone" - } - } - ] - } - } - ] -} diff --git a/receiver/zookeeperreceiver/testdata/scraper/correctness-v3.5.5-without-direction.json b/receiver/zookeeperreceiver/testdata/scraper/correctness-v3.5.5-without-direction.json deleted file mode 100644 index 3a8b0f927d5d..000000000000 --- a/receiver/zookeeperreceiver/testdata/scraper/correctness-v3.5.5-without-direction.json +++ /dev/null @@ -1,276 +0,0 @@ -{ - "resourceMetrics": [ - { - "scopeMetrics": [ - { - "scope": { - "name": "otelcol/zookeeperreceiver", - "version": "latest" - }, - "metrics": [ - { - "description": "Number of active clients connected to a ZooKeeper server.", - "name": "zookeeper.connection.active", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "1", - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ] - }, - "unit": "{connections}" - }, - { - "description": "Number of ephemeral nodes that a ZooKeeper server has in its data tree.", - "name": "zookeeper.data_tree.ephemeral_node.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ] - }, - "unit": "{nodes}" - }, - { - "description": "Size of data in bytes that a ZooKeeper server has in its data tree.", - "name": "zookeeper.data_tree.size", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "107", - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ] - }, - "unit": "By" - }, - { - "description": "Maximum number of file descriptors that a ZooKeeper server can open.", - "gauge": { - "dataPoints": [ - { - "asInt": "1048576", - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ] - }, - "name": "zookeeper.file_descriptor.limit", - "unit": "{file_descriptors}" - }, - { - "description": "Number of file descriptors that a ZooKeeper server has open.", - "name": "zookeeper.file_descriptor.open", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "54", - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ] - }, - "unit": "{file_descriptors}" - }, - { - "description": "The number of followers. Only exposed by the leader.", - "name": "zookeeper.follower.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "1", - "attributes": [ - { - "key": "state", - "value": { - "stringValue": "synced" - } - } - ], - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - }, - { - "asInt": "1", - "attributes": [ - { - "key": "state", - "value": { - "stringValue": "unsynced" - } - } - ], - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ] - }, - "unit": "{followers}" - }, - { - "description": "Average time in milliseconds for requests to be processed.", - "gauge": { - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ] - }, - "name": "zookeeper.latency.avg", - "unit": "ms" - }, - { - "description": "Maximum time in milliseconds for requests to be processed.", - "gauge": { - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ] - }, - "name": "zookeeper.latency.max", - "unit": "ms" - }, - { - "description": "Minimum time in milliseconds for requests to be processed.", - "gauge": { - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ] - }, - "name": "zookeeper.latency.min", - "unit": "ms" - }, - { - "description": "The number of ZooKeeper packets received by a server.", - "name": "zookeeper.packet.received.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "1", - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ], - "isMonotonic": true - }, - "unit": "{packets}" - }, - { - "description": "The number of ZooKeeper packets sent by a server.", - "name": "zookeeper.packet.sent.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ], - "isMonotonic": true - }, - "unit": "{packets}" - }, - { - "description": "Number of currently executing requests.", - "name": "zookeeper.request.active", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ] - }, - "unit": "{requests}" - }, - { - "description": "The number of pending syncs from the followers. Only exposed by the leader.", - "name": "zookeeper.sync.pending", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ] - }, - "unit": "{syncs}" - }, - { - "description": "Number of watches placed on Z-Nodes on a ZooKeeper server.", - "name": "zookeeper.watch.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "0", - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ] - }, - "unit": "{watches}" - }, - { - "description": "Number of z-nodes that a ZooKeeper server has in its data tree.", - "name": "zookeeper.znode.count", - "sum": { - "aggregationTemporality": "AGGREGATION_TEMPORALITY_CUMULATIVE", - "dataPoints": [ - { - "asInt": "5", - "startTimeUnixNano": "1642685966447704000", - "timeUnixNano": "1642685966447860000" - } - ] - }, - "unit": "{znodes}" - } - ] - } - ], - "resource": { - "attributes": [ - { - "key": "zk.version", - "value": { - "stringValue": "3.5.5-390fe37ea45dee01bf87dc1c042b5e3dcce88653" - } - }, - { - "key": "server.state", - "value": { - "stringValue": "leader" - } - } - ] - } - } - ] -}