Skip to content

Commit

Permalink
[receiver/dockerstats] use generated status header (#22767)
Browse files Browse the repository at this point in the history
This PR updates the component to generate the status table using mdatagen.

Linked issue: #21213

Signed-off-by: Alex Boten <aboten@lightstep.com>
  • Loading branch information
Alex Boten committed May 25, 2023
1 parent a74f8e5 commit fbd9a99
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 26 deletions.
21 changes: 11 additions & 10 deletions receiver/dockerstatsreceiver/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# Docker Stats Receiver

| Status | |
| ------------------------ |-------------------------------|
| Stability | [alpha] |
| Supported pipeline types | metrics |
| Distributions | [contrib], [observiq], [sumo] |
<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [alpha]: metrics |
| Distributions | [contrib], [observiq], [sumo] |

[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
[observiq]: https://github.com/observIQ/observiq-otel-collector
[sumo]: https://github.com/SumoLogic/sumologic-otel-collector
<!-- end autogenerated section -->

The Docker Stats receiver queries the local Docker daemon's container stats API for
all desired running containers on a configured interval. These stats are for container
Expand Down Expand Up @@ -64,11 +70,6 @@ receivers:
The full list of settings exposed for this receiver are documented [here](./config.go)
with detailed sample configurations [here](./testdata/config.yaml).

[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
[observiq]: https://github.com/observIQ/observiq-otel-collector
[sumo]: https://github.com/SumoLogic/sumologic-otel-collector

### Migrating from ScraperV1 to ScraperV2

*Note: These changes are now in effect and ScraperV1 have been removed as of v0.71.*
Expand Down
4 changes: 2 additions & 2 deletions receiver/dockerstatsreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ func TestLoadConfig(t *testing.T) {
expected component.Config
}{
{
id: component.NewIDWithName(typeStr, ""),
id: component.NewIDWithName(metadata.Type, ""),
expected: createDefaultConfig(),
},
{
id: component.NewIDWithName(typeStr, "allsettings"),
id: component.NewIDWithName(metadata.Type, "allsettings"),
expected: &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 2 * time.Second,
Expand Down
2 changes: 1 addition & 1 deletion receiver/dockerstatsreceiver/documentation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.)

# dockerstatsreceiver
# docker_stats

## Default Metrics

Expand Down
13 changes: 4 additions & 9 deletions receiver/dockerstatsreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/dockerstatsreceiver/internal/metadata"
)

const (
typeStr = "docker_stats"
stability = component.StabilityLevelAlpha
)

var _ = featuregate.GlobalRegistry().MustRegister(
"receiver.dockerstats.useScraperV2",
featuregate.StageStable,
Expand All @@ -31,13 +26,13 @@ var _ = featuregate.GlobalRegistry().MustRegister(

func NewFactory() rcvr.Factory {
return rcvr.NewFactory(
typeStr,
metadata.Type,
createDefaultConfig,
rcvr.WithMetrics(createMetricsReceiver, stability))
rcvr.WithMetrics(createMetricsReceiver, metadata.MetricsStability))
}

func createDefaultConfig() component.Config {
scs := scraperhelper.NewDefaultScraperControllerSettings(typeStr)
scs := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
scs.CollectionInterval = 10 * time.Second
return &Config{
ScraperControllerSettings: scs,
Expand All @@ -57,7 +52,7 @@ func createMetricsReceiver(
dockerConfig := config.(*Config)
dsr := newReceiver(params, dockerConfig)

scrp, err := scraperhelper.NewScraper(typeStr, dsr.scrapeV2, scraperhelper.WithStart(dsr.start))
scrp, err := scraperhelper.NewScraper(metadata.Type, dsr.scrapeV2, scraperhelper.WithStart(dsr.start))
if err != nil {
return nil, err
}
Expand Down

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

12 changes: 12 additions & 0 deletions receiver/dockerstatsreceiver/internal/metadata/generated_status.go

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

8 changes: 7 additions & 1 deletion receiver/dockerstatsreceiver/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
type: dockerstatsreceiver
type: docker_stats

status:
class: receiver
stability:
alpha: [metrics]
distributions: [contrib, observiq, sumo]

sem_conv_version: 1.6.1

Expand Down

0 comments on commit fbd9a99

Please sign in to comment.