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/discovery] Remove log_endpoints config option #4692

Merged
merged 1 commit into from
Apr 20, 2024
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 @@ -8,6 +8,7 @@
- Emit entity events for discovered endpoints with log_endpoints: true ([#4684](https://github.com/signalfx/splunk-otel-collector/pull/4684))
- Ensure active endpoints emitted as entity events periodically ([#4684](https://github.com/signalfx/splunk-otel-collector/pull/4684))
- Emit entity events only for matching receivers ([#4691](https://github.com/signalfx/splunk-otel-collector/pull/4691))
- Remove `log_endpoints` config option ([#4692](https://github.com/signalfx/splunk-otel-collector/pull/4692))

### 💡 Enhancements 💡

Expand Down
26 changes: 3 additions & 23 deletions internal/receiver/discoveryreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,9 @@ component-level log statements are similarly intercepted by a log evaluator, and
records based on the `status: statements` rules you define. The matching rules SHOULD NOT conflict with each other.
The first matching rule in the list will be used to determine the status of the receiver.

The receiver also allows you to emit entity events for all
[Endpoint](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/extension/observer/endpoints.go)
events from the specified `watch_observers`. This way you can report your environment as observed by platform-specific
observers in real time, with or without discovering receiver statuses:

```yaml
extensions:
docker_observer:
receivers:
discovery:
watch_observers: [docker_observer]
log_endpoints: true
exporters:
debug:
verbosity: detailed
service:
extensions: [docker_observer]
pipelines:
logs:
receivers: [discovery]
exporters: [debug]
```
The receiver emits entity events for
[Endpoints](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/extension/observer/endpoints.go)
discovered by the specified `watch_observers` if they match a rule for any configured receiver.

```
2024-04-17T19:53:24.285Z info LogsExporter {"kind": "exporter", "data_type": "logs", "name": "debug", "resource logs": 1, "log records": 2}
Expand Down Expand Up @@ -231,7 +212,6 @@ Flags: 0
| Name | Type | Default | Docs |
|------------------------------|---------------------------|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `watch_observers` (required) | []string | <no value> | The array of Observer extensions to receive Endpoint events from |
| `log_endpoints` | bool | false | Whether to emit all endpoint activity as entity events |
| `embed_receiver_config` | bool | false | Whether to embed a base64-encoded, minimal Receiver Creator config for the generated receiver as a reported metrics `discovery.receiver.rule` resource attribute value for status log record matches |
| `receivers` | map[string]ReceiverConfig | <no value> | The mapping of receiver names to their Receiver sub-config |

Expand Down
2 changes: 0 additions & 2 deletions internal/receiver/discoveryreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ type Config struct {
// The configured Observer extensions from which to receive Endpoint events.
// Must implement the observer.Observable interface.
WatchObservers []component.ID `mapstructure:"watch_observers"`
// Whether to emit all endpoint activity as entity events.
LogEndpoints bool `mapstructure:"log_endpoints"`
// Whether to include the receiver config as a base64-encoded "discovery.receiver.config"
// resource attribute string value. Will also contain the configured observer that
// produced the endpoint leading to receiver creation in `watch_observers`.
Expand Down
1 change: 0 additions & 1 deletion internal/receiver/discoveryreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ func TestValidConfig(t *testing.T) {
Rule: mustNewRule(`type == "container" && name matches "(?i)redis"`),
},
},
LogEndpoints: false,
EmbedReceiverConfig: true,
CorrelationTTL: 25 * time.Second,
WatchObservers: []component.ID{
Expand Down
4 changes: 2 additions & 2 deletions internal/receiver/discoveryreceiver/endpoint_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (et *endpointTracker) stop() {
}

func (et *endpointTracker) emitEntityStateEvents(observerCID component.ID, endpoints []observer.Endpoint) {
if et.config.LogEndpoints && et.pLogs != nil {
if et.pLogs != nil {
entityEvents, numFailed, err := entityStateEvents(observerCID, endpoints, time.Now())
if err != nil {
et.logger.Warn(fmt.Sprintf("failed converting %v endpoints to log records", numFailed), zap.Error(err))
Expand All @@ -125,7 +125,7 @@ func (et *endpointTracker) emitEntityStateEvents(observerCID component.ID, endpo
}

func (et *endpointTracker) emitEntityDeleteEvents(endpoints []observer.Endpoint) {
if et.config.LogEndpoints && et.pLogs != nil {
if et.pLogs != nil {
entityEvents := entityDeleteEvents(endpoints, time.Now())
if entityEvents.Len() > 0 {
et.pLogs <- entityEvents.ConvertAndMoveToLogs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ func TestUpdateEndpoints(t *testing.T) {
require.NoError(t, component.UnmarshalConfig(cm, cfg))

logger := zap.NewNop()
et := newEndpointTracker(nil, cfg, logger, make(chan plog.Logs), newCorrelationStore(logger, cfg.CorrelationTTL))
et := newEndpointTracker(nil, cfg, logger, nil, newCorrelationStore(logger, cfg.CorrelationTTL))
et.updateEndpoints(tt.endpoints, component.MustNewIDWithName("observer_type", "observer.name"))

var correlationsCount int
Expand All @@ -624,7 +624,6 @@ func TestUpdateEndpoints(t *testing.T) {
func TestEntityEmittingLifecycle(t *testing.T) {
logger := zap.NewNop()
cfg := createDefaultConfig().(*Config)
cfg.LogEndpoints = true
cfg.Receivers = map[component.ID]ReceiverEntry{
component.MustNewIDWithName("fake_receiver", ""): {
Rule: mustNewRule(`type == "port" && pod.name == "pod.name" && port == 1`),
Expand Down
1 change: 0 additions & 1 deletion internal/receiver/discoveryreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func NewFactory() receiver.Factory {

func createDefaultConfig() component.Config {
return &Config{
LogEndpoints: false,
EmbedReceiverConfig: false,
CorrelationTTL: 10 * time.Minute,
}
Expand Down
1 change: 0 additions & 1 deletion internal/receiver/discoveryreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func TestCreateDefaultConfig(t *testing.T) {
assert.NotNil(t, cfg, "failed to create default config")
assert.NoError(t, componenttest.CheckConfigStruct(cfg))
require.Equal(t, &Config{
LogEndpoints: false,
EmbedReceiverConfig: false,
CorrelationTTL: 10 * time.Minute,
}, cfg)
Expand Down
1 change: 0 additions & 1 deletion internal/receiver/discoveryreceiver/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ discovery:
watch_observers:
- an_observer
- another_observer/with_name
log_endpoints: false
embed_receiver_config: true
correlation_ttl: 25s
receivers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ extensions:

receivers:
discovery:
log_endpoints: true
receivers:
hostmetrics:
rule: type == "hostport"
Expand Down
Loading