-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add SignalFx Receiver Add a receiver supporting SignalFx metrics. * Run go mod tidy from top and signalfxreceiver * Few nits * Handle ENUM metrics * Add enpoint to config test * PR Feedback * Fix sapmexporter go.mod rebase * PR feedback
- Loading branch information
Paulo Janotti
authored
Dec 16, 2019
1 parent
b96fcb0
commit b5057f5
Showing
13 changed files
with
2,337 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include ../../Makefile.Common |
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,22 @@ | ||
// Copyright 2019, 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. | ||
|
||
package signalfxreceiver | ||
|
||
import "github.com/open-telemetry/opentelemetry-collector/config/configmodels" | ||
|
||
// Config defines configuration for the SignalFx receiver. | ||
type Config struct { | ||
configmodels.ReceiverSettings `mapstructure:",squash"` | ||
} |
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,54 @@ | ||
// Copyright 2019, 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. | ||
|
||
package signalfxreceiver | ||
|
||
import ( | ||
"path" | ||
"testing" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector/config" | ||
"github.com/open-telemetry/opentelemetry-collector/config/configmodels" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestLoadConfig(t *testing.T) { | ||
factories, err := config.ExampleComponents() | ||
assert.Nil(t, err) | ||
|
||
factory := &Factory{} | ||
factories.Receivers[typeStr] = factory | ||
cfg, err := config.LoadConfigFile( | ||
t, path.Join(".", "testdata", "config.yaml"), factories, | ||
) | ||
|
||
require.NoError(t, err) | ||
require.NotNil(t, cfg) | ||
|
||
assert.Equal(t, len(cfg.Receivers), 2) | ||
|
||
r0 := cfg.Receivers["signalfx"] | ||
assert.Equal(t, r0, factory.CreateDefaultConfig()) | ||
|
||
r1 := cfg.Receivers["signalfx/allsettings"].(*Config) | ||
assert.Equal(t, r1, | ||
&Config{ | ||
ReceiverSettings: configmodels.ReceiverSettings{ | ||
TypeVal: typeStr, | ||
NameVal: "signalfx/allsettings", | ||
Endpoint: "localhost:8080", | ||
}, | ||
}) | ||
} |
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,17 @@ | ||
// Copyright 2019, 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. | ||
|
||
// Package signalfxreceiver implements a receiver that can be used by the | ||
// OpenTelemetry collector to receive data in the SignalFx supported formats. | ||
package signalfxreceiver |
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,80 @@ | ||
// Copyright 2019, 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. | ||
|
||
package signalfxreceiver | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector/config/configerror" | ||
"github.com/open-telemetry/opentelemetry-collector/config/configmodels" | ||
"github.com/open-telemetry/opentelemetry-collector/consumer" | ||
"github.com/open-telemetry/opentelemetry-collector/receiver" | ||
"go.uber.org/zap" | ||
) | ||
|
||
// This file implements factory for SignalFx receiver. | ||
|
||
const ( | ||
// The value of "type" key in configuration. | ||
typeStr = "signalfx" | ||
) | ||
|
||
// Factory is the factory for SignalFx receiver. | ||
type Factory struct { | ||
} | ||
|
||
var _ receiver.Factory = (*Factory)(nil) | ||
|
||
// Type gets the type of the Receiver config created by this factory. | ||
func (f *Factory) Type() string { | ||
return typeStr | ||
} | ||
|
||
// CustomUnmarshaler returns nil because we don't need custom unmarshaling for this config. | ||
func (f *Factory) CustomUnmarshaler() receiver.CustomUnmarshaler { | ||
return nil | ||
} | ||
|
||
// CreateDefaultConfig creates the default configuration for Jaeger receiver. | ||
func (f *Factory) CreateDefaultConfig() configmodels.Receiver { | ||
return &Config{ | ||
ReceiverSettings: configmodels.ReceiverSettings{ | ||
TypeVal: typeStr, | ||
NameVal: typeStr, | ||
}, | ||
} | ||
} | ||
|
||
// CreateTraceReceiver creates a trace receiver based on provided config. | ||
func (f *Factory) CreateTraceReceiver( | ||
ctx context.Context, | ||
logger *zap.Logger, | ||
cfg configmodels.Receiver, | ||
consumer consumer.TraceConsumer, | ||
) (receiver.TraceReceiver, error) { | ||
|
||
return nil, configerror.ErrDataTypeIsNotSupported | ||
} | ||
|
||
// CreateMetricsReceiver creates a metrics receiver based on provided config. | ||
func (f *Factory) CreateMetricsReceiver( | ||
logger *zap.Logger, | ||
cfg configmodels.Receiver, | ||
consumer consumer.MetricsConsumer, | ||
) (receiver.MetricsReceiver, error) { | ||
|
||
rCfg := cfg.(*Config) | ||
return New(logger, *rCfg, consumer) | ||
} |
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,61 @@ | ||
// Copyright 2019, 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. | ||
|
||
package signalfxreceiver | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector/config/configcheck" | ||
"github.com/open-telemetry/opentelemetry-collector/config/configerror" | ||
"github.com/open-telemetry/opentelemetry-collector/consumer" | ||
"github.com/open-telemetry/opentelemetry-collector/consumer/consumerdata" | ||
"github.com/stretchr/testify/assert" | ||
"go.uber.org/zap" | ||
) | ||
|
||
func TestCreateDefaultConfig(t *testing.T) { | ||
factory := &Factory{} | ||
cfg := factory.CreateDefaultConfig() | ||
assert.NotNil(t, cfg, "failed to create default config") | ||
assert.NoError(t, configcheck.ValidateConfig(cfg)) | ||
} | ||
|
||
type mockMetricsConsumer struct { | ||
} | ||
|
||
var _ (consumer.MetricsConsumer) = (*mockMetricsConsumer)(nil) | ||
|
||
func (m *mockMetricsConsumer) ConsumeMetricsData(ctx context.Context, md consumerdata.MetricsData) error { | ||
return nil | ||
} | ||
|
||
func TestCreateReceiver(t *testing.T) { | ||
factory := &Factory{} | ||
cfg := factory.CreateDefaultConfig().(*Config) | ||
cfg.Endpoint = "localhost:0" // Endpoint is required, not going to be used here. | ||
|
||
tReceiver, err := factory.CreateMetricsReceiver(zap.NewNop(), cfg, &mockMetricsConsumer{}) | ||
assert.Nil(t, err, "receiver creation failed") | ||
assert.NotNil(t, tReceiver, "receiver creation failed") | ||
|
||
tReceiver, err = factory.CreateMetricsReceiver(zap.NewNop(), cfg, &mockMetricsConsumer{}) | ||
assert.Nil(t, err, "receiver creation failed") | ||
assert.NotNil(t, tReceiver, "receiver creation failed") | ||
|
||
mReceiver, err := factory.CreateTraceReceiver(context.Background(), zap.NewNop(), cfg, nil) | ||
assert.Equal(t, err, configerror.ErrDataTypeIsNotSupported) | ||
assert.Nil(t, mReceiver) | ||
} |
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,15 @@ | ||
module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/signalfxreceiver | ||
|
||
go 1.12 | ||
|
||
require ( | ||
github.com/census-instrumentation/opencensus-proto v0.2.1 | ||
github.com/golang/protobuf v1.3.2 | ||
github.com/gorilla/mux v1.7.3 | ||
github.com/open-telemetry/opentelemetry-collector v0.2.1-0.20191209163440-5d463fe48816 | ||
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter v0.0.0-20191211173639-c78990cbbb53 | ||
github.com/signalfx/com_signalfx_metrics_protobuf v0.0.0-20190530013331-054be550cb49 | ||
github.com/stretchr/testify v1.4.0 | ||
go.opencensus.io v0.22.1 | ||
go.uber.org/zap v1.13.0 | ||
) |
Oops, something went wrong.