forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[receiver/purefa] Bootstrap component (open-telemetry#14969)
- Loading branch information
Showing
16 changed files
with
824 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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 @@ | ||
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,51 @@ | ||
# Pure Storage FlashArray Receiver | ||
|
||
| Status | | | ||
| ------------------------ |---------------------| | ||
| Stability | [in-development] | | ||
| Supported pipeline types | metrics | | ||
| Distributions | [contrib] | | ||
|
||
The Pure Storage FlashArray receiver, receives metrics from Pure Storage internal services hosts. | ||
|
||
Supported pipeline types: metrics | ||
|
||
## Configuration | ||
|
||
The following settings are required: | ||
- `endpoint` (default: `http:https://172.0.0.0:9490/metrics/array`): The URL of the scraper selected endpoint | ||
|
||
Example: | ||
|
||
```yaml | ||
extensions: | ||
bearertokenauth/array01: | ||
token: "some-token" | ||
bearertokenauth/array02: | ||
token: "some-other-token" | ||
|
||
receivers: | ||
purefa: | ||
endpoint: http:https://172.0.0.0:9490/metrics/ | ||
arrays: | ||
- address: gse-array01 | ||
auth: bearertokenauth/array01 | ||
- address: gse-array02 | ||
auth: bearertokenauth/array02 | ||
hosts: | ||
- address: gse-array01 | ||
auth: bearertokenauth/array01 | ||
settings: | ||
reload_intervals: | ||
array: 10s | ||
host: 1m | ||
volume: 2m | ||
pods: 15s | ||
directories: 15s | ||
``` | ||
|
||
The full list of settings exposed for this receiver are documented [here](./config.go) | ||
with detailed sample configurations [here](./testdata/config.yaml). | ||
|
||
[in-development]: https://github.com/open-telemetry/opentelemetry-collector#in-development | ||
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib |
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,56 @@ | ||
// Copyright 2022 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:https://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 purefareceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver" | ||
|
||
import ( | ||
"time" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/config" | ||
"go.opentelemetry.io/collector/config/configauth" | ||
"go.opentelemetry.io/collector/config/confighttp" | ||
) | ||
|
||
var _ component.ReceiverConfig = (*Config)(nil) | ||
|
||
// Config relating to Array Metric Scraper. | ||
type Config struct { | ||
config.ReceiverSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct | ||
confighttp.HTTPClientSettings `mapstructure:",squash"` | ||
|
||
// Settings contains settings for the individual scrapers | ||
Settings *Settings `mapstructure:"settings"` | ||
|
||
// Arrays represents the list of arrays to query | ||
Arrays []Array `mapstructure:"arrays"` | ||
} | ||
|
||
type Array struct { | ||
Address string `mapstructure:"address"` | ||
Auth configauth.Authentication `mapstructure:"auth"` | ||
} | ||
|
||
type Settings struct { | ||
ReloadIntervals *ReloadIntervals `mapstructure:"reload_intervals"` | ||
} | ||
|
||
type ReloadIntervals struct { | ||
Array time.Duration `mapstructure:"array"` | ||
} | ||
|
||
func (c *Config) Validate() error { | ||
// TODO(dgoscn): perform config validation | ||
return nil | ||
} |
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,60 @@ | ||
// Copyright 2022 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:https://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 purefareceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver" | ||
|
||
import ( | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/config" | ||
"go.opentelemetry.io/collector/confmap/confmaptest" | ||
) | ||
|
||
func TestLoadConfig(t *testing.T) { | ||
t.Parallel() | ||
|
||
cm, err := confmaptest.LoadConf(filepath.Join("testdata", "config.yaml")) | ||
require.NoError(t, err) | ||
|
||
tests := []struct { | ||
id component.ID | ||
expected component.ReceiverConfig | ||
}{ | ||
{ | ||
id: component.NewID(typeStr), | ||
expected: &Config{ | ||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)), | ||
}, | ||
}, | ||
// TODO(dgoscn): testar with_custom_intervals | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.id.String(), func(t *testing.T) { | ||
factory := NewFactory() | ||
cfg := factory.CreateDefaultConfig() | ||
|
||
sub, err := cm.Sub(tt.id.String()) | ||
require.NoError(t, err) | ||
require.NoError(t, component.UnmarshalReceiverConfig(sub, cfg)) | ||
|
||
assert.NoError(t, component.ValidateConfig(cfg)) | ||
assert.Equal(t, tt.expected, cfg) | ||
}) | ||
} | ||
} |
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,42 @@ | ||
// Copyright 2022 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:https://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 purefareceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver" | ||
|
||
// This file implements Factory for Array scraper. | ||
import ( | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/config" | ||
"go.opentelemetry.io/collector/config/confighttp" | ||
) | ||
|
||
// NewFactory creates a factory for Pure Storage FlashArray receiver. | ||
const ( | ||
typeStr = "purefa" | ||
stability = component.StabilityLevelDevelopment | ||
) | ||
|
||
func NewFactory() component.ReceiverFactory { | ||
return component.NewReceiverFactory( | ||
typeStr, | ||
createDefaultConfig, | ||
component.WithMetricsReceiver(createMetricsReceiver, stability)) | ||
} | ||
|
||
func createDefaultConfig() component.ReceiverConfig { | ||
return &Config{ | ||
ReceiverSettings: config.NewReceiverSettings(component.NewID(typeStr)), | ||
HTTPClientSettings: confighttp.HTTPClientSettings{}, | ||
} | ||
} |
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,50 @@ | ||
// Copyright 2022 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:https://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 purefareceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver" | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/component/componenttest" | ||
) | ||
|
||
func TestTypeStr(t *testing.T) { | ||
factory := NewFactory() | ||
|
||
assert.Equal(t, "purefa", string(factory.Type())) | ||
} | ||
|
||
func TestCreateDefaultConfig(t *testing.T) { | ||
factory := NewFactory() | ||
cfg := factory.CreateDefaultConfig() | ||
assert.NotNil(t, cfg, "failed to create default config") | ||
assert.NoError(t, componenttest.CheckConfigStruct(cfg)) | ||
} | ||
|
||
func TestCreateReceiver(t *testing.T) { | ||
factory := NewFactory() | ||
cfg := factory.CreateDefaultConfig() | ||
set := componenttest.NewNopReceiverCreateSettings() | ||
mReceiver, err := factory.CreateMetricsReceiver(context.Background(), set, cfg, nil) | ||
assert.NoError(t, err, "receiver creation failed") | ||
assert.Nil(t, mReceiver, "receiver creation failed") | ||
|
||
tReceiver, err := factory.CreateTracesReceiver(context.Background(), set, cfg, nil) | ||
assert.Equal(t, err, component.ErrDataTypeIsNotSupported) | ||
assert.Nil(t, tReceiver) | ||
} |
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,49 @@ | ||
module github.com/open-telemetry/opentelemetry-collector-contrib/receiver/purefareceiver | ||
|
||
go 1.18 | ||
|
||
require ( | ||
github.com/stretchr/testify v1.8.1 | ||
go.opentelemetry.io/collector v0.66.0 | ||
go.opentelemetry.io/collector/component v0.66.0 | ||
go.opentelemetry.io/collector/consumer v0.66.0 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/felixge/httpsnoop v1.0.3 // indirect | ||
github.com/fsnotify/fsnotify v1.6.0 // indirect | ||
github.com/go-logr/logr v1.2.3 // indirect | ||
github.com/go-logr/stdr v1.2.2 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/golang/snappy v0.0.4 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/klauspost/compress v1.15.12 // indirect | ||
github.com/knadh/koanf v1.4.4 // indirect | ||
github.com/mitchellh/copystructure v1.2.0 // indirect | ||
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/mitchellh/reflectwalk v1.0.2 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/pelletier/go-toml v1.9.4 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/rs/cors v1.8.2 // indirect | ||
go.opentelemetry.io/collector/featuregate v0.65.0 // indirect | ||
go.opentelemetry.io/collector/pdata v0.66.0 // indirect | ||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.36.4 // indirect | ||
go.opentelemetry.io/otel v1.11.1 // indirect | ||
go.opentelemetry.io/otel/metric v0.33.0 // indirect | ||
go.opentelemetry.io/otel/trace v1.11.1 // indirect | ||
go.uber.org/atomic v1.10.0 // indirect | ||
go.uber.org/goleak v1.1.12 // indirect | ||
go.uber.org/multierr v1.8.0 // indirect | ||
go.uber.org/zap v1.23.0 // indirect | ||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect | ||
golang.org/x/sys v0.2.0 // indirect | ||
golang.org/x/text v0.4.0 // indirect | ||
google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc // indirect | ||
google.golang.org/grpc v1.51.0 // indirect | ||
google.golang.org/protobuf v1.28.1 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
Oops, something went wrong.