-
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.
[mdatagen] Generate documentation for components with resource attrib…
…utes only (#11242) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This PR adds support for generating `documentation.md` files for components which only define resource attributes. This was reported at #10705 and also applies at open-telemetry/opentelemetry-collector-contrib#34210. <!-- Issue number if applicable --> #### Link to tracking issue Fixes #10705 <!--Describe what testing was performed and which tests were added.--> #### Testing Tuned tests and added a sample processor component which only defines resource attributes. <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> Signed-off-by: ChrsMark <[email protected]>
- Loading branch information
Showing
17 changed files
with
762 additions
and
16 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: Generate documentation for components with resource attributes only | ||
|
||
# One or more tracking issues or pull requests related to the change | ||
issues: [10705] | ||
|
||
# (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: [] |
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
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,22 @@ | ||
# Sample Processor | ||
This processor is used for testing purposes to check the output of mdatagen. | ||
<!-- status autogenerated section --> | ||
| Status | | | ||
| ------------- |-----------| | ||
| Stability | [development]: logs | | ||
| | [beta]: traces | | ||
| | [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%3Aprocessor%2Fsample%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aopen+is%3Aissue+label%3Aprocessor%2Fsample) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector?query=is%3Aissue%20is%3Aclosed%20label%3Aprocessor%2Fsample%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aclosed+is%3Aissue+label%3Aprocessor%2Fsample) | | ||
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@some](https://www.github.com/some) | | ||
|
||
[development]: https://github.com/open-telemetry/opentelemetry-collector#development | ||
[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta | ||
[stable]: https://github.com/open-telemetry/opentelemetry-collector#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,10 @@ | ||
// 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 | ||
|
||
// Deprecated: This package is moving to https://github.com/open-telemetry/opentelemetry-collector and will eventually be removed. | ||
// Please see https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/30497 | ||
// This is a sample receiver package used to showcase how mdatagen is applied. | ||
package sampleprocessor // import "go.opentelemetry.io/collector/cmd/mdatagen/internal/sampleprocessor" |
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 @@ | ||
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.) | ||
|
||
# sample | ||
|
||
## 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,61 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package sampleprocessor // import "go.opentelemetry.io/collector/cmd/mdatagen/internal/sampleprocessor" | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/collector/cmd/mdatagen/internal/sampleprocessor/internal/metadata" | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/consumer" | ||
"go.opentelemetry.io/collector/pdata/plog" | ||
"go.opentelemetry.io/collector/pdata/pmetric" | ||
"go.opentelemetry.io/collector/pdata/ptrace" | ||
"go.opentelemetry.io/collector/processor" | ||
) | ||
|
||
// NewFactory returns a receiver.Factory for sample receiver. | ||
func NewFactory() processor.Factory { | ||
return processor.NewFactory( | ||
metadata.Type, | ||
func() component.Config { return &struct{}{} }, | ||
processor.WithTraces(createTracesProcessor, metadata.TracesStability), | ||
processor.WithMetrics(createMetricsProcessor, metadata.MetricsStability), | ||
processor.WithLogs(createLogsProcessor, metadata.LogsStability)) | ||
} | ||
|
||
func createTracesProcessor(context.Context, processor.Settings, component.Config, consumer.Traces) (processor.Traces, error) { | ||
return nopInstance, nil | ||
} | ||
|
||
func createMetricsProcessor(context.Context, processor.Settings, component.Config, consumer.Metrics) (processor.Metrics, error) { | ||
return nopInstance, nil | ||
} | ||
|
||
func createLogsProcessor(context.Context, processor.Settings, component.Config, consumer.Logs) (processor.Logs, error) { | ||
return nopInstance, nil | ||
} | ||
|
||
var nopInstance = &nopProcessor{} | ||
|
||
type nopProcessor struct { | ||
component.StartFunc | ||
component.ShutdownFunc | ||
} | ||
|
||
func (n nopProcessor) ConsumeTraces(context.Context, ptrace.Traces) error { | ||
return nil | ||
} | ||
|
||
func (n nopProcessor) ConsumeLogs(context.Context, plog.Logs) error { | ||
return nil | ||
} | ||
|
||
func (n nopProcessor) Capabilities() consumer.Capabilities { | ||
return consumer.Capabilities{MutatesData: true} | ||
} | ||
|
||
func (n nopProcessor) ConsumeMetrics(context.Context, pmetric.Metrics) error { | ||
return nil | ||
} |
151 changes: 151 additions & 0 deletions
151
cmd/mdatagen/internal/sampleprocessor/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/sampleprocessor/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.