-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Cloud Foundry metrics receiver #1 - config, factory, docs #4626
Cloud Foundry metrics receiver #1 - config, factory, docs #4626
Conversation
f5c47d1
to
5c269e6
Compare
Updated current PR to be the first stage PR of adding a new component by removing concrete implementation of everything except factory and config, and removing from |
Please identify couple of people who will maintain this component and add them to the CODEOWNERS |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
f21b7b3
to
2780141
Compare
Code owners present, rebased. |
This PR was marked stale due to lack of activity. It will be closed in 7 days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job. I added some minor comments which should be easy to address.
Can you edit the description of this PR to define what this PR contains?
Can you please create an issue e.g. named Cloud Foundry metrics receiver
? We could use it and use it to track the cloudfoundryreceiver
implementation status. From https://github.com/open-telemetry/opentelemetry-collector/blob/main/CONTRIBUTING.md#before-you-start:
If you would like to work on something that is not listed as an issue [...], then create an issue and describe your proposal. It is best to do this in advance so that maintainers can decide if the proposal is a good fit for this repository. This will help avoid situations when you spend significant time on something that maintainers may decide this repo is not the right place for.
## Configuration | ||
|
||
The receiver takes the following configuration options: | ||
* `rlp_gateway_url` - URL of the RLP gateway, required, typically `https://log-stream.<cf-system-domain>` | ||
* `rlp_gateway_skip_tls_verify` - whether to skip TLS verify for the RLP Gateway endpoint, default `false` | ||
* `rlp_gateway_shard_id` - metrics are load balanced among receivers that use the same shard ID, therefore this must | ||
only be set if there are multiple receivers which must both receive all the metrics instead of them being balanced | ||
between them. Default value is `opentelemetry` | ||
* `uaa_url` - URL of the UAA provider, required, typically `https://uaa.<cf-system-domain>` | ||
* `uaa_skip_tls_verify` - whether to skip TLS verify for the UAA endpoint, default `false` | ||
* `uaa_username` - name of the UAA user (required grant types/authorities described above) | ||
* `uaa_username` - password of the UAA user | ||
* `http_timeout` - HTTP socket timeout used for RLP Gateway, default `10s` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you format it to make it more readable? It should be easy to find if an option is required and what is its default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please resolve
The following is an example sequence of commands to create the UAA user using the `uaac` command line utility: | ||
* `uaac target https://uaa.<cf-system-domain>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: markdownlint
wants to have a blank line between a paragraph and a list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the same comment applies to other places in the README.md
|
||
_, err := url.Parse(value) | ||
if err != nil { | ||
return fmt.Errorf("failed to parse %s value %s as url: %v", name, value, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to pass the value. See https://play.golang.org/p/XcW50z01QNf
return fmt.Errorf("failed to parse %s value %s as url: %v", name, value, err) | |
return fmt.Errorf("parse %s as URL: %v", name, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please resolve
|
||
func TestLoadConfig(t *testing.T) { | ||
factories, err := componenttest.NopFactories() | ||
assert.Nil(t, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.Nil(t, err) | |
require.NoError(t, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please resolve
"go.opentelemetry.io/collector/config/configtest" | ||
) | ||
|
||
func TestLoadConfig(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest adding a TODO for the next PR: add negative tests e.g. in TestFailedLoadConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please resolve
require.NoError(t, err) | ||
require.NotNil(t, cfg) | ||
|
||
assert.Equal(t, len(cfg.Receivers), 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about changing this line to:
assert.Equal(t, len(cfg.Receivers), 2) | |
require.Len(t, cfg.Receivers, 2) |
so that it does not panic later if the length would be 0 or 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please resolve
assert.Equal(t, len(cfg.Receivers), 2) | ||
|
||
r0 := cfg.Receivers[config.NewID(typeStr)] | ||
assert.Equal(t, r0, factory.CreateDefaultConfig()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected is first, actual is second.
assert.Equal(t, r0, factory.CreateDefaultConfig()) | |
assert.Equal(t, factory.CreateDefaultConfig(), r0) |
See: https://pkg.go.dev/github.com/stretchr/[email protected]/assert#Equal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please resolve
assert.Equal(t, r1, | ||
&Config{ | ||
ReceiverSettings: config.NewReceiverSettings(config.NewIDWithName(typeStr, "one")), | ||
RLPGatewayURL: "https://log-stream.sys.example.internal", | ||
RLPGatewaySkipTLSVerify: true, | ||
RLPGatewayShardID: "otel-test", | ||
UAAUrl: "https://uaa.sys.example.internal", | ||
UAASkipTLSVerify: true, | ||
UAAUsername: "admin", | ||
UAAPassword: "test", | ||
HTTPTimeout: time.Second * 20, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expected is first, actual is second.
See: https://pkg.go.dev/github.com/stretchr/[email protected]/assert#Equal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please resolve
func TestCreateDefaultConfig(t *testing.T) { | ||
factory := NewFactory() | ||
cfg := factory.CreateDefaultConfig() | ||
assert.NotNil(t, cfg, "failed to create default config") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it not be require
? Does the next line make any sense if this one fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please resolve
For me, it makes a lot of sense, because:
|
Added an additional sentence to description that explains what this PR includes and what it does not.
Issue created, edited PR description to link to the issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
### Attributes | ||
|
||
All the metrics have the following attributes: | ||
* `origin` - origin name as documented by Cloud Foundry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is origin both an attribute and also prepended to the metric name? (I don't know if this is desirable or no, just double checking that the docs are correct).
* `origin` - origin name as documented by Cloud Foundry | ||
* `source` - for applications, the GUID of the application, otherwise equal to `origin` | ||
|
||
For CF/TAS deployed in BOSH, the following attributes are also present, using their canonical BOSH meanings: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: it may be useful to link abbreviations to their definitions somewhere. I don't know what TAS or BOSH and being able to quickly find out can help maintaining the component in the future.
RLPGatewaySkipTLSVerify bool `mapstructure:"rlp_gateway_skip_tls_verify"` | ||
RLPGatewayShardID string `mapstructure:"rlp_gateway_shard_id"` | ||
UAAUrl string `mapstructure:"uaa_url"` | ||
UAASkipTLSVerify bool `mapstructure:"uaa_skip_tls_verify"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using the generic TLSClientSetting
(if this receiver is capable of supporting the settings). Otherwise it would be still good to use the same names for settings (e.g. insecure_skip_verify
).
RLPGatewayURL string `mapstructure:"rlp_gateway_url"` | ||
RLPGatewaySkipTLSVerify bool `mapstructure:"rlp_gateway_skip_tls_verify"` | ||
RLPGatewayShardID string `mapstructure:"rlp_gateway_shard_id"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be nicer to make rtl
a section with subkeys?
UAAUrl string `mapstructure:"uaa_url"` | ||
UAASkipTLSVerify bool `mapstructure:"uaa_skip_tls_verify"` | ||
UAAUsername string `mapstructure:"uaa_username"` | ||
UAAPassword string `mapstructure:"uaa_password"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be nicer to make uaa
a section with subkeys?
UAASkipTLSVerify bool `mapstructure:"uaa_skip_tls_verify"` | ||
UAAUsername string `mapstructure:"uaa_username"` | ||
UAAPassword string `mapstructure:"uaa_password"` | ||
HTTPTimeout time.Duration `mapstructure:"http_timeout"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using HTTPClientSettings
which already includes timeout setting.
I am going to merge this now since the component is not enabled yet. Please address the comments I left in the future PRs. |
Adds implementation to the Cloud Foundry receiver skeleton merged in #4626 . **Link to tracking Issue:** #5320 **Testing:** Some implementation parts have been unit tested, the rest will be added as integration tests, in a separate PR which tests against a local HTTP server which will respond with prerecorded responses (recorded from running it against Tanzu Application Service). **Documentation:** Configuration was updated in documentation to reflect using `HTTPClientSettings` instead of custom fields.
Description: Adds a Cloud Foundry metric receiver which reads metrics from Cloud Foundry Reverse Log Proxy Gateway. More details available in the
README.md
.make gotidy
seems to have made plenty of subtle changes togo.sum
files, not sure if this is normal. This PR contains the overall structure, documentation, implementation for config and factory, but does NOT contain the implementation of the receiver and does not enable the component, as that will come in separate PRs later.Link to tracking Issue: #5320
Testing: Unit tests. Manual testing was performed against Tanzu Application Service (TAS) versions 2.7, 2.8 and 2.11. Considered adding an integration test with mocked HTTP servers acting as endpoints where the HTTP server would provide a constant response (prerecorded from the real TAS traffic), but not sure if mocks would make more sense.
Documentation:
README.md
anddoc.go
for the new receiver module were added.