-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34c776f
commit b182d27
Showing
20 changed files
with
716 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: hostmetricsreceiver | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Add an uptime scraper in the hostmetrics receiver | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [31627] | ||
|
||
# (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: | ||
|
||
# If your change doesn't affect end users or the exported elements of any package, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
# Optional: The change log or logs in which this entry should be included. | ||
# e.g. '[user]' or '[user, api]' | ||
# Include 'user' if the change is relevant to end users. | ||
# Include 'api' if there is a change to a library API. | ||
# Default: '[user]' | ||
change_logs: [user] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ receivers: | |
network: | ||
paging: | ||
processes: | ||
uptime: | ||
|
||
exporters: | ||
debug: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
receiver/hostmetricsreceiver/internal/scraper/uptimescraper/config.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package uptimescraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/uptimescraper" | ||
|
||
import ( | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/uptimescraper/internal/metadata" | ||
) | ||
|
||
// Config relating to Uptime Metric Scraper. | ||
type Config struct { | ||
// MetricsBuilderConfig allows to customize scraped metrics/attributes representation. | ||
metadata.MetricsBuilderConfig `mapstructure:",squash"` | ||
internal.ScraperConfig | ||
} |
6 changes: 6 additions & 0 deletions
6
receiver/hostmetricsreceiver/internal/scraper/uptimescraper/doc.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:generate mdatagen metadata.yaml | ||
|
||
package uptimescraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/uptimescraper" |
23 changes: 23 additions & 0 deletions
23
receiver/hostmetricsreceiver/internal/scraper/uptimescraper/documentation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.) | ||
|
||
# hostmetricsreceiver/uptime | ||
|
||
**Parent Component:** hostmetrics | ||
|
||
## Default Metrics | ||
|
||
The following metrics are emitted by default. Each of them can be disabled by applying the following configuration: | ||
|
||
```yaml | ||
metrics: | ||
<metric_name>: | ||
enabled: false | ||
``` | ||
### system.uptime | ||
The time the system has been running | ||
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | | ||
| ---- | ----------- | ---------- | ----------------------- | --------- | | ||
| s | Sum | Double | Cumulative | false | |
54 changes: 54 additions & 0 deletions
54
receiver/hostmetricsreceiver/internal/scraper/uptimescraper/factory.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package uptimescraper // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/uptimescraper" | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"runtime" | ||
|
||
"go.opentelemetry.io/collector/receiver" | ||
"go.opentelemetry.io/collector/receiver/scraperhelper" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal" | ||
hostmeta "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/metadata" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/uptimescraper/internal/metadata" | ||
) | ||
|
||
// This file implements Factory for Uptime scraper. | ||
|
||
const ( | ||
// TypeStr the value of "type" key in configuration. | ||
TypeStr = "uptime" | ||
) | ||
|
||
// Factory is the Factory for scraper. | ||
type Factory struct { | ||
} | ||
|
||
// CreateDefaultConfig creates the default configuration for the Scraper. | ||
func (f *Factory) CreateDefaultConfig() internal.Config { | ||
return &Config{ | ||
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(), | ||
} | ||
} | ||
|
||
// CreateMetricsScraper creates a resource scraper based on provided config. | ||
func (f *Factory) CreateMetricsScraper( | ||
ctx context.Context, | ||
settings receiver.Settings, | ||
cfg internal.Config, | ||
) (scraperhelper.Scraper, error) { | ||
if runtime.GOOS != "linux" && runtime.GOOS != "windows" && runtime.GOOS != "darwin" { | ||
return nil, errors.New("uptime scraper only available on Linux, Windows, or MacOS") | ||
} | ||
|
||
uptimeScraper := newUptimeScraper(ctx, settings, cfg.(*Config)) | ||
|
||
return scraperhelper.NewScraper( | ||
hostmeta.Type, | ||
uptimeScraper.scrape, | ||
scraperhelper.WithStart(uptimeScraper.start), | ||
) | ||
} |
50 changes: 50 additions & 0 deletions
50
.../hostmetricsreceiver/internal/scraper/uptimescraper/internal/metadata/generated_config.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
...metricsreceiver/internal/scraper/uptimescraper/internal/metadata/generated_config_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.