forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore] [cmd/mdatagen] Move sample-metadata.yaml to a separate package (
open-telemetry#31503) Create a separate internal sample receiver to generate and validate code with mdatagen, including lifecycle tests.
- Loading branch information
1 parent
26cacc0
commit eda1132
Showing
21 changed files
with
184 additions
and
31 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
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
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" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/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 | ||
} |
87 changes: 87 additions & 0 deletions
87
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,20 @@ | ||
// 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" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/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
2 changes: 1 addition & 1 deletion
2
...datagen/internal/metadata/package_test.go → cmd/mdatagen/package_test.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