Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
balazs92117 authored Jan 24, 2024
2 parents 8fafef6 + 74245fd commit 7196cb0
Show file tree
Hide file tree
Showing 34 changed files with 4,060 additions and 313 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@ internal API changes are not present.
Main (unreleased)
-----------------

### Breaking changes

- Prohibit the configuration of services within modules. (@wildum)

### Features

- A new `discovery.process` component for discovering Linux OS processes on the current host. (@korniltsev)

- A new `pyroscope.java` component for profiling Java processes using async-profiler. (@korniltsev)

- A new `otelcol.processor.resourcedetection` component which inserts resource attributes
to OTLP telemetry based on the host on which Grafana Agent is running. (@ptodev)

### Enhancements

- Include line numbers in profiles produced by `pyrsocope.java` component. (@korniltsev)
Expand Down
1 change: 1 addition & 0 deletions component/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import (
_ "github.com/grafana/agent/component/otelcol/processor/k8sattributes" // Import otelcol.processor.k8sattributes
_ "github.com/grafana/agent/component/otelcol/processor/memorylimiter" // Import otelcol.processor.memory_limiter
_ "github.com/grafana/agent/component/otelcol/processor/probabilistic_sampler" // Import otelcol.processor.probabilistic_sampler
_ "github.com/grafana/agent/component/otelcol/processor/resourcedetection" // Import otelcol.processor.resourcedetection
_ "github.com/grafana/agent/component/otelcol/processor/span" // Import otelcol.processor.span
_ "github.com/grafana/agent/component/otelcol/processor/tail_sampling" // Import otelcol.processor.tail_sampling
_ "github.com/grafana/agent/component/otelcol/processor/transform" // Import otelcol.processor.transform
Expand Down
35 changes: 35 additions & 0 deletions component/otelcol/config_k8s.go
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 component/otelcol/processor/processortest/compare_signals.go
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 component/otelcol/processor/processortest/compare_signals_test.go
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)
}
Loading

0 comments on commit 7196cb0

Please sign in to comment.