-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scraper component type support to mdatagen (#12092)
Updates #11238 Signed-off-by: Bogdan Drutu <[email protected]>
- Loading branch information
1 parent
c56efd3
commit 60b22d1
Showing
24 changed files
with
1,970 additions
and
11 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 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# 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. otlpreceiver) | ||
component: mdatagen | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Add scraper component type support to mdatagen | ||
|
||
# One or more tracking issues or pull requests related to the change | ||
issues: [12092] | ||
|
||
# (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: | ||
|
||
# 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: [api] |
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
1 change: 0 additions & 1 deletion
1
cmd/mdatagen/internal/samplereceiver/internal/metadata/generated_metrics.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,18 @@ | ||
# Sample Scraper | ||
This scraper is used for testing purposes to check the output of mdatagen. | ||
<!-- status autogenerated section --> | ||
| Status | | | ||
| ------------- |-----------| | ||
| Stability | [stable]: metrics | | ||
| Unsupported Platforms | freebsd, illumos | | ||
| Distributions | [] | | ||
| Warnings | [Any additional information that should be brought to the consumer's attention](#warnings) | | ||
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector?query=is%3Aissue%20is%3Aopen%20label%3Ascraper%2Fsample%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aopen+is%3Aissue+label%3Ascraper%2Fsample) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector?query=is%3Aissue%20is%3Aclosed%20label%3Ascraper%2Fsample%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aclosed+is%3Aissue+label%3Ascraper%2Fsample) | | ||
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@dmitryax](https://www.github.com/dmitryax) | | ||
|
||
[stable]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#stable | ||
<!-- end autogenerated section --> | ||
|
||
## Warnings | ||
|
||
This is where warnings are described. |
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,7 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Generate a test metrics builder from a sample metrics set covering all configuration options. | ||
//go:generate mdatagen metadata.yaml | ||
|
||
package samplescraper // import "go.opentelemetry.io/collector/cmd/mdatagen/internal/samplescraper" |
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,115 @@ | ||
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.) | ||
|
||
# sample | ||
|
||
## 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 | ||
``` | ||
### default.metric | ||
Monotonic cumulative sum int metric enabled by default. | ||
The metric will be become optional soon. | ||
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | | ||
| ---- | ----------- | ---------- | ----------------------- | --------- | | ||
| s | Sum | Int | Cumulative | true | | ||
#### Attributes | ||
| Name | Description | Values | | ||
| ---- | ----------- | ------ | | ||
| string_attr | Attribute with any string value. | Any Str | | ||
| state | Integer attribute with overridden name. | Any Int | | ||
| enum_attr | Attribute with a known set of string values. | Str: ``red``, ``green``, ``blue`` | | ||
| slice_attr | Attribute with a slice value. | Any Slice | | ||
| map_attr | Attribute with a map value. | Any Map | | ||
### default.metric.to_be_removed | ||
[DEPRECATED] Non-monotonic delta sum double metric enabled by default. | ||
The metric will be will be removed soon. | ||
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | | ||
| ---- | ----------- | ---------- | ----------------------- | --------- | | ||
| s | Sum | Double | Delta | false | | ||
### metric.input_type | ||
Monotonic cumulative sum int metric with string input_type enabled by default. | ||
| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic | | ||
| ---- | ----------- | ---------- | ----------------------- | --------- | | ||
| s | Sum | Int | Cumulative | true | | ||
#### Attributes | ||
| Name | Description | Values | | ||
| ---- | ----------- | ------ | | ||
| string_attr | Attribute with any string value. | Any Str | | ||
| state | Integer attribute with overridden name. | Any Int | | ||
| enum_attr | Attribute with a known set of string values. | Str: ``red``, ``green``, ``blue`` | | ||
| slice_attr | Attribute with a slice value. | Any Slice | | ||
| map_attr | Attribute with a map value. | Any Map | | ||
## Optional Metrics | ||
The following metrics are not emitted by default. Each of them can be enabled by applying the following configuration: | ||
```yaml | ||
metrics: | ||
<metric_name>: | ||
enabled: true | ||
``` | ||
### optional.metric | ||
[DEPRECATED] Gauge double metric disabled by default. | ||
| Unit | Metric Type | Value Type | | ||
| ---- | ----------- | ---------- | | ||
| 1 | Gauge | Double | | ||
#### Attributes | ||
| Name | Description | Values | | ||
| ---- | ----------- | ------ | | ||
| string_attr | Attribute with any string value. | Any Str | | ||
| boolean_attr | Attribute with a boolean value. | Any Bool | | ||
| boolean_attr2 | Another attribute with a boolean value. | Any Bool | | ||
### optional.metric.empty_unit | ||
[DEPRECATED] Gauge double metric disabled by default. | ||
| Unit | Metric Type | Value Type | | ||
| ---- | ----------- | ---------- | | ||
| | Gauge | Double | | ||
#### Attributes | ||
| Name | Description | Values | | ||
| ---- | ----------- | ------ | | ||
| string_attr | Attribute with any string value. | Any Str | | ||
| boolean_attr | Attribute with a boolean value. | Any Bool | | ||
## Resource Attributes | ||
| Name | Description | Values | Enabled | | ||
| ---- | ----------- | ------ | ------- | | ||
| map.resource.attr | Resource attribute with a map value. | Any Map | true | | ||
| optional.resource.attr | Explicitly disabled ResourceAttribute. | Any Str | false | | ||
| slice.resource.attr | Resource attribute with a slice value. | Any Slice | true | | ||
| string.enum.resource.attr | Resource attribute with a known set of string values. | Str: ``one``, ``two`` | true | | ||
| string.resource.attr | Resource attribute with any string value. | Any Str | true | | ||
| string.resource.attr_disable_warning | Resource attribute with any string value. | Any Str | true | | ||
| string.resource.attr_remove_warning | Resource attribute with any string value. | Any Str | false | | ||
| string.resource.attr_to_be_removed | Resource attribute with any string value. | Any Str | true | |
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,27 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package samplescraper // import "go.opentelemetry.io/collector/cmd/mdatagen/internal/samplescraper" | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/collector/cmd/mdatagen/internal/samplescraper/internal/metadata" | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/pdata/pmetric" | ||
"go.opentelemetry.io/collector/scraper" | ||
) | ||
|
||
// NewFactory returns a receiver.Factory for sample receiver. | ||
func NewFactory() scraper.Factory { | ||
return scraper.NewFactory( | ||
metadata.Type, | ||
func() component.Config { return &struct{}{} }, | ||
scraper.WithMetrics(createMetrics, metadata.MetricsStability)) | ||
} | ||
|
||
func createMetrics(context.Context, scraper.Settings, component.Config) (scraper.Metrics, error) { | ||
return scraper.NewMetrics(func(context.Context) (pmetric.Metrics, error) { | ||
return pmetric.NewMetrics(), nil | ||
}) | ||
} |
70 changes: 70 additions & 0 deletions
70
cmd/mdatagen/internal/samplescraper/generated_component_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
cmd/mdatagen/internal/samplescraper/generated_package_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.