Skip to content

Commit

Permalink
[receiver/memcached] Migrate memcached scraper to the new metrics bu…
Browse files Browse the repository at this point in the history
…ilder (#9329)

The v2 generated metrics are scoped to "otelcol/memcachedreceiver" instead of "otelcol/memcached". If this is a breaking change, let me know how we should handle it.
  • Loading branch information
TylerHelmuth authored Apr 20, 2022
1 parent e13ed6d commit b18bf1a
Show file tree
Hide file tree
Showing 8 changed files with 925 additions and 380 deletions.
5 changes: 5 additions & 0 deletions receiver/memcachedreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (

"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/receiver/scraperhelper"

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

type Config struct {
Expand All @@ -27,4 +29,7 @@ type Config struct {

// Timeout for the memcache stats request
Timeout time.Duration `mapstructure:"timeout"`

// Metrics allows customizing scraped metrics representation.
Metrics metadata.MetricsSettings `mapstructure:"metrics"`
}
2 changes: 1 addition & 1 deletion receiver/memcachedreceiver/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
//go:build !windows
// +build !windows

//go:generate mdatagen metadata.yaml
//go:generate mdatagen --experimental-gen metadata.yaml

package memcachedreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/memcachedreceiver"
9 changes: 8 additions & 1 deletion receiver/memcachedreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ These are the metrics available for this scraper.
| **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> |

**Highlighted metrics** are emitted by default.
**Highlighted metrics** are emitted by default. Other metrics are optional and not emitted by default.
Any metric can be enabled or disabled with the following scraper configuration:

```yaml
metrics:
<metric_name>:
enabled: <true|false>
```
## Metric attributes
Expand Down
5 changes: 3 additions & 2 deletions receiver/memcachedreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

package memcachedreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/memcachedreceiver"

//go:generate mdatagen metadata.yaml

import (
"context"
"time"
Expand All @@ -25,6 +23,8 @@ import (
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/receiver/scraperhelper"

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

const (
Expand All @@ -49,6 +49,7 @@ func createDefaultConfig() config.Receiver {
NetAddr: confignet.NetAddr{
Endpoint: "localhost:11211",
},
Metrics: metadata.DefaultMetricsSettings(),
}
}

Expand Down
290 changes: 0 additions & 290 deletions receiver/memcachedreceiver/internal/metadata/generated_metrics.go

This file was deleted.

Loading

0 comments on commit b18bf1a

Please sign in to comment.