Skip to content

[receiver/memcached] removing direction feature gate #14964

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

Merged
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
16 changes: 16 additions & 0 deletions .chloggen/rm-direction-memcached.yaml
Original file line number Diff line number Diff line change
@@ -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: memcachedreceiver

# 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: [14964]

# (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:
12 changes: 0 additions & 12 deletions receiver/memcachedreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,5 @@ with detailed sample configurations [here](./testdata/config.yaml).

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.memcachedreceiver.emitMetricsWithoutDirectionAttribute**
- **receiver.memcachedreceiver.emitMetricsWithDirectionAttribute**

For additional information, see https://github.com/open-telemetry/opentelemetry-specification/issues/2726.

[beta]:https://github.com/open-telemetry/opentelemetry-collector#beta
[contrib]:https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
2 changes: 0 additions & 2 deletions receiver/memcachedreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ These are the metrics available for this scraper.
| **memcached.current_items** | Number of items currently stored in the cache. | {items} | Sum(Int) | <ul> </ul> |
| **memcached.evictions** | Cache item evictions. | {evictions} | Sum(Int) | <ul> </ul> |
| **memcached.network** | Bytes transferred over the network. | by | Sum(Int) | <ul> <li>direction</li> </ul> |
| **memcached.network.received** | Bytes received over the network. | by | Sum(Int) | <ul> </ul> |
| **memcached.network.sent** | Bytes sent over the network. | by | Sum(Int) | <ul> </ul> |
| **memcached.operation_hit_ratio** | Hit ratio for operations, expressed as a percentage value between 0.0 and 100.0. | % | Gauge(Double) | <ul> <li>operation</li> </ul> |
| **memcached.operations** | Operation counts. | {operations} | Sum(Int) | <ul> <li>type</li> <li>operation</li> </ul> |
| **memcached.threads** | Number of threads used by the memcached instance. | {threads} | Sum(Int) | <ul> </ul> |
Expand Down
16 changes: 0 additions & 16 deletions receiver/memcachedreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ import (
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/receiver/scraperhelper"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/memcachedreceiver/internal/metadata"
)
Expand Down Expand Up @@ -59,12 +57,6 @@ func createDefaultConfig() config.Receiver {
}
}

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 createMetricsReceiver(
_ context.Context,
params component.ReceiverCreateSettings,
Expand All @@ -75,14 +67,6 @@ func createMetricsReceiver(

ms := newMemcachedScraper(params, cfg)

if !ms.emitMetricsWithDirectionAttribute {
logDeprecatedFeatureGateForDirection(ms.logger, emitMetricsWithDirectionAttributeFeatureGate)
}

if ms.emitMetricsWithoutDirectionAttribute {
logDeprecatedFeatureGateForDirection(ms.logger, emitMetricsWithoutDirectionAttributeFeatureGate)
}

scraper, err := scraperhelper.NewScraper(typeStr, ms.scrape)
if err != nil {
return nil, err
Expand Down
126 changes: 0 additions & 126 deletions receiver/memcachedreceiver/internal/metadata/generated_metrics.go

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

21 changes: 0 additions & 21 deletions receiver/memcachedreceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ metrics:
monotonic: true
aggregation: cumulative
attributes: []
# produced when receiver.memcachedreceiver.emitMetricsWithDirectionAttribute feature gate is enabled
memcached.network:
enabled: true
description: Bytes transferred over the network.
Expand All @@ -93,26 +92,6 @@ metrics:
monotonic: true
aggregation: cumulative
attributes: [direction]
# produced when receiver.memcachedreceiver.emitMetricsWithoutDirectionAttribute feature gate is enabled
memcached.network.sent:
enabled: true
description: Bytes sent over the network.
unit: by
sum:
value_type: int
monotonic: true
aggregation: cumulative
attributes: []
# produced when receiver.memcachedreceiver.emitMetricsWithoutDirectionAttribute feature gate is enabled
memcached.network.received:
enabled: true
description: Bytes received over the network.
unit: by
sum:
value_type: int
monotonic: true
aggregation: cumulative
attributes: []
memcached.operations:
enabled: true
description: Operation counts.
Expand Down
67 changes: 10 additions & 57 deletions receiver/memcachedreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,66 +20,29 @@ 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"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/memcachedreceiver/internal/metadata"
)

const (
emitMetricsWithDirectionAttributeFeatureGateID = "receiver.memcached.emitMetricsWithDirectionAttribute"
emitMetricsWithoutDirectionAttributeFeatureGateID = "receiver.memcached.emitMetricsWithoutDirectionAttribute"
)

var (
emitMetricsWithDirectionAttributeFeatureGate = featuregate.Gate{
ID: emitMetricsWithDirectionAttributeFeatureGateID,
Enabled: true,
Description: "Some memcached 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/memcachedreceiver/README.md#feature-gate-configurations",
}

emitMetricsWithoutDirectionAttributeFeatureGate = featuregate.Gate{
ID: emitMetricsWithoutDirectionAttributeFeatureGateID,
Enabled: false,
Description: "Some memcached 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/memcachedreceiver/README.md#feature-gate-configurations",
}
)

func init() {
featuregate.GetRegistry().MustRegister(emitMetricsWithDirectionAttributeFeatureGate)
featuregate.GetRegistry().MustRegister(emitMetricsWithoutDirectionAttributeFeatureGate)
}

type memcachedScraper struct {
logger *zap.Logger
config *Config
mb *metadata.MetricsBuilder
newClient newMemcachedClientFunc
emitMetricsWithDirectionAttribute bool
emitMetricsWithoutDirectionAttribute bool
logger *zap.Logger
config *Config
mb *metadata.MetricsBuilder
newClient newMemcachedClientFunc
}

func newMemcachedScraper(
settings component.ReceiverCreateSettings,
config *Config,
) memcachedScraper {
return memcachedScraper{
logger: settings.Logger,
config: config,
newClient: newMemcachedClient,
mb: metadata.NewMetricsBuilder(config.Metrics, settings.BuildInfo),
emitMetricsWithDirectionAttribute: featuregate.GetRegistry().IsEnabled(emitMetricsWithDirectionAttributeFeatureGateID),
emitMetricsWithoutDirectionAttribute: featuregate.GetRegistry().IsEnabled(emitMetricsWithoutDirectionAttributeFeatureGateID),
logger: settings.Logger,
config: config,
newClient: newMemcachedClient,
mb: metadata.NewMetricsBuilder(config.Metrics, settings.BuildInfo),
}
}

Expand Down Expand Up @@ -147,21 +110,11 @@ func (r *memcachedScraper) scrape(_ context.Context) (pmetric.Metrics, error) {
}
case "bytes_read":
if parsedV, ok := r.parseInt(k, v); ok {
if r.emitMetricsWithDirectionAttribute {
r.mb.RecordMemcachedNetworkDataPoint(now, parsedV, metadata.AttributeDirectionReceived)
}
if r.emitMetricsWithoutDirectionAttribute {
r.mb.RecordMemcachedNetworkReceivedDataPoint(now, parsedV)
}
r.mb.RecordMemcachedNetworkDataPoint(now, parsedV, metadata.AttributeDirectionReceived)
}
case "bytes_written":
if parsedV, ok := r.parseInt(k, v); ok {
if r.emitMetricsWithDirectionAttribute {
r.mb.RecordMemcachedNetworkDataPoint(now, parsedV, metadata.AttributeDirectionSent)
}
if r.emitMetricsWithoutDirectionAttribute {
r.mb.RecordMemcachedNetworkSentDataPoint(now, parsedV)
}
r.mb.RecordMemcachedNetworkDataPoint(now, parsedV, metadata.AttributeDirectionSent)
}
case "get_hits":
if parsedV, ok := r.parseInt(k, v); ok {
Expand Down
Loading