-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
4,060 additions
and
313 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package otelcol | ||
|
||
import "fmt" | ||
|
||
const ( | ||
KubernetesAPIConfig_AuthType_None = "none" | ||
KubernetesAPIConfig_AuthType_ServiceAccount = "serviceAccount" | ||
KubernetesAPIConfig_AuthType_KubeConfig = "kubeConfig" | ||
KubernetesAPIConfig_AuthType_TLS = "tls" | ||
) | ||
|
||
// KubernetesAPIConfig contains options relevant to connecting to the K8s API | ||
type KubernetesAPIConfig struct { | ||
// How to authenticate to the K8s API server. This can be one of `none` | ||
// (for no auth), `serviceAccount` (to use the standard service account | ||
// token provided to the agent pod), or `kubeConfig` to use credentials | ||
// from `~/.kube/config`. | ||
AuthType string `river:"auth_type,attr,optional"` | ||
|
||
// When using auth_type `kubeConfig`, override the current context. | ||
Context string `river:"context,attr,optional"` | ||
} | ||
|
||
// Validate returns an error if the config is invalid. | ||
func (c *KubernetesAPIConfig) Validate() error { | ||
switch c.AuthType { | ||
case KubernetesAPIConfig_AuthType_None, | ||
KubernetesAPIConfig_AuthType_ServiceAccount, | ||
KubernetesAPIConfig_AuthType_KubeConfig, | ||
KubernetesAPIConfig_AuthType_TLS: | ||
return nil | ||
default: | ||
return fmt.Errorf("invalid auth_type %q", c.AuthType) | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
component/otelcol/processor/processortest/compare_signals.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package processortest | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/plogtest" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/pmetrictest" | ||
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest/ptracetest" | ||
"github.com/stretchr/testify/require" | ||
"go.opentelemetry.io/collector/pdata/plog" | ||
"go.opentelemetry.io/collector/pdata/pmetric" | ||
"go.opentelemetry.io/collector/pdata/ptrace" | ||
) | ||
|
||
func CompareMetrics(t *testing.T, expected, actual pmetric.Metrics) { | ||
err := pmetrictest.CompareMetrics( | ||
expected, | ||
actual, | ||
pmetrictest.IgnoreResourceMetricsOrder(), | ||
pmetrictest.IgnoreMetricDataPointsOrder(), | ||
pmetrictest.IgnoreMetricsOrder(), | ||
pmetrictest.IgnoreScopeMetricsOrder(), | ||
pmetrictest.IgnoreSummaryDataPointValueAtQuantileSliceOrder(), | ||
pmetrictest.IgnoreTimestamp(), | ||
pmetrictest.IgnoreStartTimestamp(), | ||
) | ||
require.NoError(t, err) | ||
} | ||
|
||
func CompareLogs(t *testing.T, expected, actual plog.Logs) { | ||
err := plogtest.CompareLogs( | ||
expected, | ||
actual, | ||
) | ||
require.NoError(t, err) | ||
} | ||
|
||
func CompareTraces(t *testing.T, expected, actual ptrace.Traces) { | ||
err := ptracetest.CompareTraces( | ||
expected, | ||
actual, | ||
ptracetest.IgnoreResourceSpansOrder(), | ||
ptracetest.IgnoreScopeSpansOrder(), | ||
) | ||
require.NoError(t, err) | ||
} |
36 changes: 36 additions & 0 deletions
36
component/otelcol/processor/processortest/compare_signals_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package processortest | ||
|
||
import ( | ||
"testing" | ||
|
||
"go.opentelemetry.io/collector/pdata/pmetric" | ||
"go.opentelemetry.io/collector/pdata/ptrace" | ||
) | ||
|
||
func Test_ScopeMetricsOrder(t *testing.T) { | ||
metric1 := pmetric.NewMetrics() | ||
metric1_res := metric1.ResourceMetrics().AppendEmpty() | ||
metric1_res.ScopeMetrics().AppendEmpty().Scope().SetName("scope1") | ||
metric1_res.ScopeMetrics().AppendEmpty().Scope().SetName("scope2") | ||
|
||
metric2 := pmetric.NewMetrics() | ||
metric2_res := metric2.ResourceMetrics().AppendEmpty() | ||
metric2_res.ScopeMetrics().AppendEmpty().Scope().SetName("scope2") | ||
metric2_res.ScopeMetrics().AppendEmpty().Scope().SetName("scope1") | ||
|
||
CompareMetrics(t, metric1, metric2) | ||
} | ||
|
||
func Test_ScopeSpansAttributesOrder(t *testing.T) { | ||
trace1 := ptrace.NewTraces() | ||
trace1_span_attr := trace1.ResourceSpans().AppendEmpty().ScopeSpans().AppendEmpty().Scope().Attributes() | ||
trace1_span_attr.PutStr("key1", "val1") | ||
trace1_span_attr.PutStr("key2", "val2") | ||
|
||
trace2 := ptrace.NewTraces() | ||
trace2_span_attr := trace2.ResourceSpans().AppendEmpty().ScopeSpans().AppendEmpty().Scope().Attributes() | ||
trace2_span_attr.PutStr("key2", "val2") | ||
trace2_span_attr.PutStr("key1", "val1") | ||
|
||
CompareTraces(t, trace1, trace2) | ||
} |
Oops, something went wrong.