Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] use metadata.yaml in k8sattributes processor #21399

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions processor/k8sattributesprocessor/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Kubernetes Attributes Processor
<!-- status autogenerated section -->
| Status | |
| ------------- |-----------|
| Stability | [beta]: logs, metrics, traces |
| Distributions | [contrib] |

| Status | |
|--------------------------|-----------------------|
| Stability | [beta] |
| Supported pipeline types | logs, metrics, traces |
| Distributions | [contrib] |
[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 -->

Kubernetes attributes processor allow automatic setting of spans, metrics and logs resource attributes with k8s metadata.

Expand Down Expand Up @@ -252,6 +255,3 @@ The processor does not support detecting containers from the same pods when runn
as a sidecar. While this can be done, we think it is simpler to just use the kubernetes
downward API to inject environment variables into the pods and directly use their values
as tags.

[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
7 changes: 4 additions & 3 deletions processor/k8sattributesprocessor/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor/internal/kube"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor/internal/metadata"
)

func TestLoadConfig(t *testing.T) {
Expand All @@ -35,14 +36,14 @@ func TestLoadConfig(t *testing.T) {
expected component.Config
}{
{
id: component.NewID(typeStr),
id: component.NewID(metadata.Type),
expected: &Config{
APIConfig: k8sconfig.APIConfig{AuthType: k8sconfig.AuthTypeServiceAccount},
Exclude: ExcludeConfig{Pods: []ExcludePodConfig{{Name: "jaeger-agent"}, {Name: "jaeger-collector"}}},
},
},
{
id: component.NewIDWithName(typeStr, "2"),
id: component.NewIDWithName(metadata.Type, "2"),
expected: &Config{
APIConfig: k8sconfig.APIConfig{AuthType: k8sconfig.AuthTypeKubeConfig},
Passthrough: false,
Expand Down Expand Up @@ -113,7 +114,7 @@ func TestLoadConfig(t *testing.T) {
},
},
{
id: component.NewIDWithName(typeStr, "3"),
id: component.NewIDWithName(metadata.Type, "3"),
expected: &Config{
APIConfig: k8sconfig.APIConfig{AuthType: k8sconfig.AuthTypeKubeConfig},
Passthrough: false,
Expand Down
17 changes: 17 additions & 0 deletions processor/k8sattributesprocessor/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:generate mdatagen metadata.yaml

package k8sattributesprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor"
16 changes: 5 additions & 11 deletions processor/k8sattributesprocessor/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ import (

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor/internal/kube"
)

const (
// The value of "type" key in configuration.
typeStr = "k8sattributes"
// The stability level of the processor.
stability = component.StabilityLevelBeta
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/k8sattributesprocessor/internal/metadata"
)

var kubeClientProvider = kube.ClientProvider(nil)
Expand All @@ -41,11 +35,11 @@ var defaultExcludes = ExcludeConfig{Pods: []ExcludePodConfig{{Name: "jaeger-agen
// NewFactory returns a new factory for the k8s processor.
func NewFactory() processor.Factory {
return processor.NewFactory(
typeStr,
metadata.Type,
createDefaultConfig,
processor.WithTraces(createTracesProcessor, stability),
processor.WithMetrics(createMetricsProcessor, stability),
processor.WithLogs(createLogsProcessor, stability),
processor.WithTraces(createTracesProcessor, metadata.TracesStability),
processor.WithMetrics(createMetricsProcessor, metadata.MetricsStability),
processor.WithLogs(createLogsProcessor, metadata.LogsStability),
)
}

Expand Down

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

7 changes: 7 additions & 0 deletions processor/k8sattributesprocessor/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type: k8sattributes

status:
class: processor
stability:
beta: [logs, metrics, traces]
distributions: [contrib]
Loading