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

[receiver/cloudfoundry] Enable component #7060

Merged
merged 5 commits into from
Jan 12, 2022
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## 💡 Enhancements 💡

- `cloudfoundryreceiver`: Enable Cloud Foundry client (#7060)
- `elasticsearchexporter`: add elasticsearchexporter to the components exporter list (#6002)
- `datadogexporter`: Add http.status_code tag to trace stats (#6889)
- `tanzuobservabilityexporter`: Support delta histograms (#6897)
Expand Down
9 changes: 6 additions & 3 deletions cmd/configschema/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib v0.42.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/resourcetotelemetry v0.42.0
github.com/stretchr/testify v1.7.0
go.uber.org/multierr v1.7.0
go.opentelemetry.io/collector v0.42.0
go.opentelemetry.io/collector/model v0.42.0
go.uber.org/multierr v1.7.0
golang.org/x/mod v0.5.1
)

require go.uber.org/multierr v1.7.0

require (
bitbucket.org/atlassian/go-asap/v2 v2.6.0 // indirect
cloud.google.com/go v0.100.2 // indirect
Expand All @@ -24,6 +22,9 @@ require (
cloud.google.com/go/spanner v1.29.0 // indirect
cloud.google.com/go/trace v1.0.0 // indirect
code.cloudfoundry.org/clock v1.0.0 // indirect
code.cloudfoundry.org/go-diodes v0.0.0-20211115184647-b584dd5df32c // indirect
code.cloudfoundry.org/go-loggregator v7.4.0+incompatible // indirect
code.cloudfoundry.org/rfc5424 v0.0.0-20201103192249-000122071b78 // indirect
contrib.go.opencensus.io/exporter/stackdriver v0.13.10 // indirect
github.com/Azure/azure-sdk-for-go v55.2.0+incompatible // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
Expand Down Expand Up @@ -66,6 +67,7 @@ require (
github.com/checkpoint-restore/go-criu/v5 v5.0.0 // indirect
github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect
github.com/cilium/ebpf v0.6.2 // indirect
github.com/cloudfoundry-incubator/uaago v0.0.0-20190307164349-8136b7bbe76e // indirect
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4 // indirect
github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490 // indirect
github.com/containerd/console v1.0.2 // indirect
Expand Down Expand Up @@ -284,6 +286,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsecscontainermetricsreceiver v0.42.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsxrayreceiver v0.42.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/carbonreceiver v0.42.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/cloudfoundryreceiver v0.42.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/collectdreceiver v0.42.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/dockerstatsreceiver v0.42.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/dotnetdiagnosticsreceiver v0.42.0 // indirect
Expand Down
13 changes: 12 additions & 1 deletion cmd/configschema/go.sum

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

5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsecscontainermetricsreceiver v0.42.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsxrayreceiver v0.42.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/carbonreceiver v0.42.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/cloudfoundryreceiver v0.42.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/collectdreceiver v0.42.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/dockerstatsreceiver v0.42.0
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/dotnetdiagnosticsreceiver v0.42.0
Expand Down Expand Up @@ -124,6 +125,9 @@ require (
cloud.google.com/go/spanner v1.29.0 // indirect
cloud.google.com/go/trace v1.0.0 // indirect
code.cloudfoundry.org/clock v1.0.0 // indirect
code.cloudfoundry.org/go-diodes v0.0.0-20211115184647-b584dd5df32c // indirect
code.cloudfoundry.org/go-loggregator v7.4.0+incompatible // indirect
code.cloudfoundry.org/rfc5424 v0.0.0-20201103192249-000122071b78 // indirect
contrib.go.opencensus.io/exporter/prometheus v0.4.0 // indirect
contrib.go.opencensus.io/exporter/stackdriver v0.13.10 // indirect
github.com/Azure/azure-sdk-for-go v55.2.0+incompatible // indirect
Expand Down Expand Up @@ -167,6 +171,7 @@ require (
github.com/checkpoint-restore/go-criu/v5 v5.0.0 // indirect
github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect
github.com/cilium/ebpf v0.6.2 // indirect
github.com/cloudfoundry-incubator/uaago v0.0.0-20190307164349-8136b7bbe76e // indirect
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4 // indirect
github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490 // indirect
github.com/containerd/console v1.0.2 // indirect
Expand Down
11 changes: 10 additions & 1 deletion go.sum

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

2 changes: 2 additions & 0 deletions internal/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsecscontainermetricsreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awsxrayreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/carbonreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/cloudfoundryreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/collectdreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/dockerstatsreceiver"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/dotnetdiagnosticsreceiver"
Expand Down Expand Up @@ -163,6 +164,7 @@ func Components() (component.Factories, error) {
awsecscontainermetricsreceiver.NewFactory(),
awsxrayreceiver.NewFactory(),
carbonreceiver.NewFactory(),
cloudfoundryreceiver.NewFactory(),
collectdreceiver.NewFactory(),
dockerstatsreceiver.NewFactory(),
dotnetdiagnosticsreceiver.NewFactory(),
Expand Down
4 changes: 4 additions & 0 deletions internal/components/receivers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ func TestDefaultReceivers(t *testing.T) {
},
skipLifecyle: true, // Panics after test have completed, requires a wait group
},
{
receiver: "cloudfoundry",
skipLifecyle: true, // Requires UAA (auth) endpoint to run
},
{
receiver: "collectd",
},
Expand Down
50 changes: 49 additions & 1 deletion receiver/cloudfoundryreceiver/receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,52 @@

package cloudfoundryreceiver

// TODO: integration test to be added in next PR
import (
"context"
"testing"

"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/consumer/consumertest"
)

// Test to make sure a new receiver can be created properly, started and shutdown with the default config
func TestDefaultValidReceiver(t *testing.T) {
crobert-1 marked this conversation as resolved.
Show resolved Hide resolved
factory := NewFactory()
cfg := factory.CreateDefaultConfig().(*Config)
params := componenttest.NewNopReceiverCreateSettings()

receiver, err := newCloudFoundryReceiver(
params,
*cfg,
consumertest.NewNop(),
)

require.NoError(t, err)
require.NotNil(t, receiver, "receiver creation failed")

// Test start
ctx := context.Background()
err = receiver.Start(ctx, componenttest.NewNopHost())
require.NoError(t, err)

// Test shutdown
err = receiver.Shutdown(ctx)
require.NoError(t, err)
}

// Test to make sure start fails with invalid consumer
func TestInvalidConsumer(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig().(*Config)
params := componenttest.NewNopReceiverCreateSettings()

receiver, err := newCloudFoundryReceiver(
params,
*cfg,
nil,
)

require.EqualError(t, err, "nil nextConsumer")
require.Nil(t, receiver, "receiver creation failed")
}
82 changes: 81 additions & 1 deletion receiver/cloudfoundryreceiver/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,84 @@

package cloudfoundryreceiver

// TODO: integration test to be added in next PR
import (
"context"
"testing"

"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component/componenttest"
"go.uber.org/zap"
)

// Ensure stream create works as expected
func TestValidStream(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig().(*Config)

uaa, err := newUAATokenProvider(
zap.NewNop(),
cfg.UAA.LimitedHTTPClientSettings,
cfg.UAA.Username,
cfg.UAA.Password)

require.NoError(t, err)
require.NotNil(t, uaa)

streamFactory, streamErr := newEnvelopeStreamFactory(
zap.NewNop(),
uaa,
cfg.RLPGateway.HTTPClientSettings,
componenttest.NewNopHost())

require.NoError(t, streamErr)
require.NotNil(t, streamFactory)

innerCtx, cancel := context.WithCancel(context.Background())

envelopeStream, createErr := streamFactory.CreateStream(
innerCtx,
cfg.RLPGateway.ShardID)

require.NoError(t, createErr)
require.NotNil(t, envelopeStream)

cancel()
}

// Ensure stream create fails when it should
func TestInvalidStream(t *testing.T) {

factory := NewFactory()
cfg := factory.CreateDefaultConfig().(*Config)

uaa, err := newUAATokenProvider(
zap.NewNop(),
cfg.UAA.LimitedHTTPClientSettings,
cfg.UAA.Username,
cfg.UAA.Password)

require.NoError(t, err)
require.NotNil(t, uaa)

// Stream create should fail if given empty shard ID
streamFactory, streamErr := newEnvelopeStreamFactory(
zap.NewNop(),
uaa,
cfg.RLPGateway.HTTPClientSettings,
componenttest.NewNopHost())

require.NoError(t, streamErr)
require.NotNil(t, streamFactory)

innerCtx, cancel := context.WithCancel(context.Background())

invalidShardID := ""
envelopeStream, createErr := streamFactory.CreateStream(
innerCtx,
invalidShardID)

require.EqualError(t, createErr, "shardID cannot be empty")
require.Nil(t, envelopeStream)

cancel()
}
49 changes: 48 additions & 1 deletion receiver/cloudfoundryreceiver/uaa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,51 @@

package cloudfoundryreceiver

// TODO: integration test to be added in next PR
import (
"testing"

"github.com/stretchr/testify/require"
"go.uber.org/zap"
)

// Make sure we can authenticate with valid credentials
func TestValidAuthentication(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig().(*Config)

uaa, err := newUAATokenProvider(
zap.NewNop(),
cfg.UAA.LimitedHTTPClientSettings,
cfg.UAA.Username,
cfg.UAA.Password)

require.NoError(t, err)
require.NotNil(t, uaa)

// No username or password should still succeed
uaa, err = newUAATokenProvider(
zap.NewNop(),
cfg.UAA.LimitedHTTPClientSettings,
"",
"")

require.NoError(t, err)
require.NotNil(t, uaa)
}

// Make sure authentication fails with empty URL endpoint
func TestInvalidAuthentication(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig().(*Config)

cfg.UAA.LimitedHTTPClientSettings.Endpoint = ""

uaa, err := newUAATokenProvider(
zap.NewNop(),
cfg.UAA.LimitedHTTPClientSettings,
cfg.UAA.Username,
cfg.UAA.Password)

require.EqualError(t, err, "client: missing url")
require.Nil(t, uaa)
}