Skip to content

Commit

Permalink
[mdatagen] support adding warnings to status table (#20242)
Browse files Browse the repository at this point in the history
This change allows components to specify warnings in metadata.yaml.

---------

Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
Alex Boten authored Mar 21, 2023
1 parent 5046503 commit d645ec2
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 15 deletions.
16 changes: 16 additions & 0 deletions .chloggen/codeboten_mdatagen-warning.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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: mdatagen

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Warnings can now be specified in metadata.yaml to be included in the generated status table.

# One or more tracking issues related to the change
issues: [20242]

# (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:
16 changes: 16 additions & 0 deletions cmd/mdatagen/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func Test_inlineReplace(t *testing.T) {
markdown string
outputFile string
componentType string
warnings []string
}{
{
name: "readme with empty status",
Expand Down Expand Up @@ -152,6 +153,20 @@ Some info about a component
`,
outputFile: "readme_without_status.md",
},
{
name: "component with warnings",
markdown: `# Some component
<!-- status autogenerated section -->
<!-- end autogenerated section -->
Some info about a component
### warnings
Some warning there.
`,
outputFile: "readme_with_warnings.md",
warnings: []string{"warning1"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -161,6 +176,7 @@ Some info about a component
Pipelines: []string{"metrics"},
Distributions: []string{"contrib"},
Type: tt.componentType,
Warnings: tt.warnings,
},
}
tmpdir := t.TempDir()
Expand Down
1 change: 1 addition & 0 deletions cmd/mdatagen/statusdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ type Status struct {
Pipelines []string `mapstructure:"pipelines"`
Distributions []string `mapstructure:"distributions"`
Type string `mapstructure:"type"`
Warnings []string `mapstructure:"warnings"`
}
5 changes: 4 additions & 1 deletion cmd/mdatagen/templates/readme.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
| Supported pipeline types | {{ stringsJoin .Status.Pipelines "," }} |
{{- end }}
| Distributions | [{{ stringsJoin .Status.Distributions "], [" }}] |
{{- if .Status.Warnings }}
| Warnings | [{{ stringsJoin .Status.Warnings ", " }}](#warnings) |
{{- end }}

[{{ .Status.Stability }}]: https://github.com/open-telemetry/opentelemetry-collector#{{ .Status.Stability }}
{{- range .Status.Distributions }}
[{{.}}]: {{ distroURL . }}
{{- end}}
{{- end }}
{{- end }}
<!-- end autogenerated section -->
17 changes: 17 additions & 0 deletions cmd/mdatagen/testdata/readme_with_warnings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Some component

<!-- status autogenerated section -->
| Status | |
| ------------------------ |-----------|
| Stability | [beta] |
| Supported pipeline types | metrics |
| Distributions | [contrib] |
| Warnings | [warning1](#warnings) |

[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
<!-- end autogenerated section -->

Some info about a component
### warnings
Some warning there.
19 changes: 10 additions & 9 deletions processor/transformprocessor/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Transform Processor

| Status | |
|--------------------------|------------------------------------------------------------------------------------|
| Stability | [alpha] |
| Supported pipeline types | traces, metrics, logs |
| Distributions | [contrib] |
<!-- status autogenerated section -->
| Status | |
| ------------------------ |-----------|
| Stability | [alpha] |
| Supported pipeline types | traces,metrics,logs |
| Distributions | [contrib] |
| Warnings | [Unsound Transformations, Identity Conflict, Orphaned Telemetry, Other](#warnings) |

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

The transform processor modifies telemetry based on configuration using the [OpenTelemetry Transformation Language](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl).

For each signal type, the processor takes a list of statements associated to a [Context type](#contexts) and executes the statements against the incoming telemetry in the order specified in the config.
Expand Down Expand Up @@ -254,6 +258,3 @@ The transform processor's implementation of the [OpenTelemetry Transformation La
- Although the OTTL allows the `set` function to be used with `metric.data_type`, its implementation in the transform processor is NOOP. To modify a data type you must use a function specific to that purpose.
- [Identity Conflict](https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/standard-warnings.md#identity-conflict): Transformation of metrics have the potential to affect the identity of a metric leading to an Identity Crisis. Be especially cautious when transforming metric name and when reducing/changing existing attributes. Adding new attributes is safe.
- [Orphaned Telemetry](https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/standard-warnings.md#orphaned-telemetry): The processor allows you to modify `span_id`, `trace_id`, and `parent_span_id` for traces and `span_id`, and `trace_id` logs. Modifying these fields could lead to orphaned spans or logs.

[alpha]: https://github.com/open-telemetry/opentelemetry-collector#alpha
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
2 changes: 2 additions & 0 deletions processor/transformprocessor/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:generate mdatagen metadata.yaml

// Package transformprocessor contains the logic to execute telemetry transform based
// on the OpenTelemetry Transformation Language.
package transformprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor"
10 changes: 5 additions & 5 deletions processor/transformprocessor/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor/internal/common"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor/internal/logs"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor/internal/metadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor/internal/metrics"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/transformprocessor/internal/traces"
)

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

var processorCapabilities = consumer.Capabilities{MutatesData: true}
Expand All @@ -41,9 +41,9 @@ func NewFactory() processor.Factory {
return processor.NewFactory(
typeStr,
createDefaultConfig,
processor.WithLogs(createLogsProcessor, stability),
processor.WithTraces(createTracesProcessor, stability),
processor.WithMetrics(createMetricsProcessor, stability),
processor.WithLogs(createLogsProcessor, metadata.Stability),
processor.WithTraces(createTracesProcessor, metadata.Stability),
processor.WithMetrics(createMetricsProcessor, metadata.Stability),
)
}

Expand Down

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

8 changes: 8 additions & 0 deletions processor/transformprocessor/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: transform

status:
type: processor
stability: alpha
pipelines: [traces, metrics, logs]
distributions: [contrib]
warnings: [Unsound Transformations, Identity Conflict, Orphaned Telemetry, Other]

0 comments on commit d645ec2

Please sign in to comment.