Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/zookeeperreceiver] emit metrics without direction attribute #12772

Merged
merged 6 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion receiver/zookeeperreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,48 @@ receivers:
collection_interval: 20s
```

## Metrics

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

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
(https://github.com/open-telemetry/opentelemetry-specification/pull/2617):

- `zookeeper.packet.count` will become:
- `zookeeper.packet.received.count`
- `zookeeper.packet.sent.count`

The following feature gates control the transition process:

- **receiver.zookeeperreceiver.emitMetricsWithoutDirectionAttribute**: controls if the new metrics without `direction` attribute are emitted by the receiver.
- **receiver.zookeeperreceiver.emitMetricsWithDirectionAttribute**: controls if the deprecated metrics with `direction` attribute are emitted by the receiver.

##### Transition schedule:

1. v0.57.0, July 2022:

- The new metrics are available for all scrapers, but disabled by default, they can be enabled with the feature gates.
- The old metrics with `direction` attribute are deprecated with a warning.
- `receiver.zookeeperreceiver.emitMetricsWithDirectionAttribute` is enabled by default.
- `receiver.zookeeperreceiver.emitMetricsWithoutDirectionAttribute` is disabled by default.

2. v0.58.0, August 2022:

- The new metrics are enabled by default, deprecated metrics disabled, they can be enabled with the feature gates.
- `receiver.zookeeperreceiver.emitMetricsWithDirectionAttribute` is disabled by default.
- `receiver.zookeeperreceiver.emitMetricsWithoutDirectionAttribute` is enabled by default.

3. v0.60.0, September 2022:

- The feature gates are removed.
- The new metrics without `direction` attribute are always emitted.
- The deprecated metrics with `direction` attribute are no longer available.

[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
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
2 changes: 2 additions & 0 deletions receiver/zookeeperreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ These are the metrics available for this scraper.
| **zookeeper.latency.max** | Maximum time in milliseconds for requests to be processed. | ms | Gauge(Int) | <ul> </ul> |
| **zookeeper.latency.min** | Minimum time in milliseconds for requests to be processed. | ms | Gauge(Int) | <ul> </ul> |
| **zookeeper.packet.count** | The number of ZooKeeper packets received or sent by a server. | {packets} | Sum(Int) | <ul> <li>direction</li> </ul> |
| **zookeeper.packet.received.count** | The number of ZooKeeper packets received by a server. | {packets} | Sum(Int) | <ul> </ul> |
| **zookeeper.packet.sent.count** | The number of ZooKeeper packets sent by a server. | {packets} | Sum(Int) | <ul> </ul> |
| **zookeeper.request.active** | Number of currently executing requests. | {requests} | Sum(Int) | <ul> </ul> |
| **zookeeper.sync.pending** | The number of pending syncs from the followers. Only exposed by the leader. | {syncs} | Sum(Int) | <ul> </ul> |
| **zookeeper.watch.count** | Number of watches placed on Z-Nodes on a ZooKeeper server. | {watches} | Sum(Int) | <ul> </ul> |
Expand Down
126 changes: 126 additions & 0 deletions receiver/zookeeperreceiver/internal/metadata/generated_metrics_v2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions receiver/zookeeperreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ 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.
Expand All @@ -127,6 +128,24 @@ 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.
Expand Down
25 changes: 20 additions & 5 deletions receiver/zookeeperreceiver/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ const (
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) *metricCreator {
func newMetricCreator(mb *metadata.MetricsBuilder, emitMetricsWithDirectionAttribute, emitMetricsWithoutDirectionAttribute bool) *metricCreator {
return &metricCreator{
computedMetricStore: make(map[string]int64),
mb: mb,
computedMetricStore: make(map[string]int64),
mb: mb,
emitMetricsWithDirectionAttribute: emitMetricsWithDirectionAttribute,
emitMetricsWithoutDirectionAttribute: emitMetricsWithoutDirectionAttribute,
}
}

Expand Down Expand Up @@ -101,11 +106,21 @@ func (m *metricCreator) recordDataPointsFunc(metric string) func(ts pcommon.Time
return m.mb.RecordZookeeperFsyncExceededThresholdCountDataPoint
case packetsReceivedMetricKey:
return func(ts pcommon.Timestamp, val int64) {
m.mb.RecordZookeeperPacketCountDataPoint(ts, val, metadata.AttributeDirectionReceived)
if m.emitMetricsWithDirectionAttribute {
m.mb.RecordZookeeperPacketCountDataPoint(ts, val, metadata.AttributeDirectionReceived)
}
if m.emitMetricsWithoutDirectionAttribute {
m.mb.RecordZookeeperPacketReceivedCountDataPoint(ts, val)
}
}
case packetsSentMetricKey:
return func(ts pcommon.Timestamp, val int64) {
m.mb.RecordZookeeperPacketCountDataPoint(ts, val, metadata.AttributeDirectionSent)
if m.emitMetricsWithDirectionAttribute {
m.mb.RecordZookeeperPacketCountDataPoint(ts, val, metadata.AttributeDirectionSent)
}
if m.emitMetricsWithoutDirectionAttribute {
m.mb.RecordZookeeperPacketSentCountDataPoint(ts, val)
}
}
}

Expand Down
Loading