-
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.
[cmd/mdatagen] Pull new changes from contrib
- Loading branch information
Showing
53 changed files
with
1,250 additions
and
185 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,27 @@ | ||
# 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: cmd/mdatagen | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Generate the lifecycle tests for components by default. | ||
|
||
# One or more tracking issues or pull requests related to the change | ||
issues: [9683] | ||
|
||
# (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: | | ||
It's encouraged to have lifecycle tests for all components enadled, but they can be disabled if needed | ||
in metadata.yaml with `skip_lifecycle: true` and `skip_shutdown: true` under `tests` section. | ||
# 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 was deleted.
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
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 samplereceiver |
2 changes: 1 addition & 1 deletion
2
cmd/mdatagen/documentation.md → .../internal/samplereceiver/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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.) | ||
|
||
# file | ||
# sample | ||
|
||
## Default Metrics | ||
|
||
|
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,43 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package samplereceiver | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/consumer" | ||
"go.opentelemetry.io/collector/receiver" | ||
|
||
"go.opentelemetry.io/collector/cmd/mdatagen/internal/samplereceiver/internal/metadata" | ||
) | ||
|
||
// NewFactory returns a receiver.Factory for sample receiver. | ||
func NewFactory() receiver.Factory { | ||
return receiver.NewFactory( | ||
metadata.Type, | ||
func() component.Config { return &struct{}{} }, | ||
receiver.WithTraces(createTraces, metadata.TracesStability), | ||
receiver.WithMetrics(createMetrics, metadata.MetricsStability), | ||
receiver.WithLogs(createLogs, metadata.LogsStability)) | ||
} | ||
|
||
func createTraces(context.Context, receiver.CreateSettings, component.Config, consumer.Traces) (receiver.Traces, error) { | ||
return nopInstance, nil | ||
} | ||
|
||
func createMetrics(context.Context, receiver.CreateSettings, component.Config, consumer.Metrics) (receiver.Metrics, error) { | ||
return nopInstance, nil | ||
} | ||
|
||
func createLogs(context.Context, receiver.CreateSettings, component.Config, consumer.Logs) (receiver.Logs, error) { | ||
return nopInstance, nil | ||
} | ||
|
||
var nopInstance = &nopReceiver{} | ||
|
||
type nopReceiver struct { | ||
component.StartFunc | ||
component.ShutdownFunc | ||
} |
76 changes: 76 additions & 0 deletions
76
cmd/mdatagen/internal/samplereceiver/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.
6 changes: 3 additions & 3 deletions
6
...gen/internal/metadata/generated_config.go → ...ver/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.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...en/internal/metadata/generated_metrics.go → ...er/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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
...gen/internal/metadata/generated_status.go → ...ver/internal/metadata/generated_status.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
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,21 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package samplereceiver | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"go.opentelemetry.io/collector/receiver/receivertest" | ||
|
||
"go.opentelemetry.io/collector/cmd/mdatagen/internal/samplereceiver/internal/metadata" | ||
) | ||
|
||
// TestGeneratedMetrics verifies that the internal/metadata API is generated correctly. | ||
func TestGeneratedMetrics(t *testing.T) { | ||
mb := metadata.NewMetricsBuilder(metadata.DefaultMetricsBuilderConfig(), receivertest.NewNopCreateSettings()) | ||
m := mb.Emit() | ||
require.Equal(t, 0, m.ResourceMetrics().Len()) | ||
} |
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
Oops, something went wrong.