Skip to content

Commit

Permalink
[discovery] Remove redundant discovery.receiver.rule attribute (#5403)
Browse files Browse the repository at this point in the history
Do not report discovery.receiver.rule resource attribute with entities and metrics. It's not being used.
  • Loading branch information
dmitryax authored Sep 24, 2024
1 parent 3b991b1 commit fff641c
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 12 deletions.
6 changes: 3 additions & 3 deletions internal/receiver/discoveryreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Body: Empty()
Attributes:
-> otel.entity.id: Map({"discovery.endpoint.id":"k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)"})
-> otel.entity.event.type: Str(entity_state)
-> otel.entity.attributes: Map({"discovery.event.type":"metric.match","discovery.message":"Mysql receiver is working!","discovery.observer.id":"k8s_observer","discovery.receiver.rule":"type == \"port\" and port != 33060 and pod.name matches \"(?i)mysql\"","discovery.receiver.type":"mysql","discovery.status":"successful","k8s.namespace.name":"default","k8s.pod.name":"mysql-0","k8s.pod.uid":"05c6a212-730c-4295-8dd6-0c460c892034","metric.name":"mysql.locks","mysql.instance.endpoint":"192.168.161.105:3306"})
-> otel.entity.attributes: Map({"discovery.event.type":"metric.match","discovery.message":"Mysql receiver is working!","discovery.observer.id":"k8s_observer","discovery.receiver.type":"mysql","discovery.status":"successful","k8s.namespace.name":"default","k8s.pod.name":"mysql-0","k8s.pod.uid":"05c6a212-730c-4295-8dd6-0c460c892034","metric.name":"mysql.locks","mysql.instance.endpoint":"192.168.161.105:3306"})
Trace ID:
Span ID:
Flags: 0
Expand All @@ -166,7 +166,7 @@ Body: Empty()
Attributes:
-> otel.entity.id: Map({"discovery.endpoint.id":"k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)"})
-> otel.entity.event.type: Str(entity_state)
-> otel.entity.attributes: Map({"caller":"[email protected]/scraper.go:82","discovery.event.type":"statement.match","discovery.message":"Make sure your user credentials are correctly specified using the `--set splunk.discovery.receivers.mysql.config.username=\"\u003cusername\u003e\"` and `--set splunk.discovery.receivers.mysql.config.password=\"\u003cpassword\u003e\"` command or the `SPLUNK_DISCOVERY_RECEIVERS_mysql_CONFIG_username=\"\u003cusername\u003e\"` and `SPLUNK_DISCOVERY_RECEIVERS_mysql_CONFIG_password=\"\u003cpassword\u003e\"` environment variables. (evaluated \"{\\\"error\\\":\\\"Error 1045 (28000): Access denied for user 'root'@'192.168.174.232' (using password: YES)\\\",\\\"kind\\\":\\\"receiver\\\",\\\"message\\\":\\\"Failed to fetch InnoDB stats\\\"}\")","discovery.observer.id":"k8s_observer","discovery.receiver.name":"","discovery.receiver.rule":"type == \"port\" and port != 33060 and pod.name matches \"(?i)mysql\"","discovery.receiver.type":"mysql","discovery.status":"partial","error":"Error 1045 (28000): Access denied for user 'root'@'192.168.174.232' (using password: YES)","kind":"receiver","name":"mysql//receiver_creator/discovery/logs{endpoint=\"192.168.161.105:3306\"}/k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)","stacktrace":"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver.(*mySQLScraper).scrape\n\tgithub.com/open-telemetry/opentelemetry-collector-contrib/receiver/[email protected]/scraper.go:82\ngo.opentelemetry.io/collector/receiver/scraperhelper.ScrapeFunc.Scrape\n\tgo.opentelemetry.io/collector/[email protected]/scraperhelper/scraper.go:20\ngo.opentelemetry.io/collector/receiver/scraperhelper.(*controller).scrapeMetricsAndReport\n\tgo.opentelemetry.io/collector/[email protected]/scraperhelper/scrapercontroller.go:194\ngo.opentelemetry.io/collector/receiver/scraperhelper.(*controller).startScraping.func1\n\tgo.opentelemetry.io/collector/[email protected]/scraperhelper/scrapercontroller.go:169"})
-> otel.entity.attributes: Map({"caller":"[email protected]/scraper.go:82","discovery.event.type":"statement.match","discovery.message":"Make sure your user credentials are correctly specified using the `--set splunk.discovery.receivers.mysql.config.username=\"\u003cusername\u003e\"` and `--set splunk.discovery.receivers.mysql.config.password=\"\u003cpassword\u003e\"` command or the `SPLUNK_DISCOVERY_RECEIVERS_mysql_CONFIG_username=\"\u003cusername\u003e\"` and `SPLUNK_DISCOVERY_RECEIVERS_mysql_CONFIG_password=\"\u003cpassword\u003e\"` environment variables. (evaluated \"{\\\"error\\\":\\\"Error 1045 (28000): Access denied for user 'root'@'192.168.174.232' (using password: YES)\\\",\\\"kind\\\":\\\"receiver\\\",\\\"message\\\":\\\"Failed to fetch InnoDB stats\\\"}\")","discovery.observer.id":"k8s_observer","discovery.receiver.name":"","discovery.receiver.type":"mysql","discovery.status":"partial","error":"Error 1045 (28000): Access denied for user 'root'@'192.168.174.232' (using password: YES)","kind":"receiver","name":"mysql//receiver_creator/discovery/logs{endpoint=\"192.168.161.105:3306\"}/k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)","stacktrace":"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver.(*mySQLScraper).scrape\n\tgithub.com/open-telemetry/opentelemetry-collector-contrib/receiver/[email protected]/scraper.go:82\ngo.opentelemetry.io/collector/receiver/scraperhelper.ScrapeFunc.Scrape\n\tgo.opentelemetry.io/collector/[email protected]/scraperhelper/scraper.go:20\ngo.opentelemetry.io/collector/receiver/scraperhelper.(*controller).scrapeMetricsAndReport\n\tgo.opentelemetry.io/collector/[email protected]/scraperhelper/scrapercontroller.go:194\ngo.opentelemetry.io/collector/receiver/scraperhelper.(*controller).startScraping.func1\n\tgo.opentelemetry.io/collector/[email protected]/scraperhelper/scrapercontroller.go:169"})
Trace ID:
Span ID:
Flags: 0
Expand All @@ -192,7 +192,7 @@ Body: Empty()
Attributes:
-> otel.entity.id: Map({"discovery.endpoint.id":"k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)"})
-> otel.entity.event.type: Str(entity_state)
-> otel.entity.attributes: Map({"caller":"[email protected]/observerhandler.go:96","discovery.event.type":"statement.match","discovery.message":"The container cannot be reached by the Collector. The container is refusing MySQL connections. (evaluated \"{\\\"endpoint\\\":\\\"192.168.161.105:3306\\\",\\\"endpoint_id\\\":\\\"k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)\\\",\\\"kind\\\":\\\"receiver\\\",\\\"message\\\":\\\"starting receiver\\\"}\")","discovery.observer.id":"k8s_observer","discovery.receiver.name":"","discovery.receiver.rule":"type == \"port\" and port != 33060 and pod.name matches \"(?i)mysql\"","discovery.receiver.type":"mysql","discovery.status":"failed","endpoint":"192.168.161.105:3306","endpoint_id":"k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)","kind":"receiver","name":"mysql"})
-> otel.entity.attributes: Map({"caller":"[email protected]/observerhandler.go:96","discovery.event.type":"statement.match","discovery.message":"The container cannot be reached by the Collector. The container is refusing MySQL connections. (evaluated \"{\\\"endpoint\\\":\\\"192.168.161.105:3306\\\",\\\"endpoint_id\\\":\\\"k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)\\\",\\\"kind\\\":\\\"receiver\\\",\\\"message\\\":\\\"starting receiver\\\"}\")","discovery.observer.id":"k8s_observer","discovery.receiver.name":"","discovery.receiver.type":"mysql","discovery.status":"failed","endpoint":"192.168.161.105:3306","endpoint_id":"k8s_observer/05c6a212-730c-4295-8dd6-0c460c892034/mysql(3306)","kind":"receiver","name":"mysql"})
Trace ID:
Span ID:
Flags: 0
Expand Down
1 change: 0 additions & 1 deletion internal/receiver/discoveryreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ func (cfg *Config) receiverCreatorReceiversConfig() map[string]any {
}
resourceAttributes[discovery.ReceiverNameAttr] = receiverID.Name()
resourceAttributes[discovery.ReceiverTypeAttr] = receiverID.Type().String()
resourceAttributes[receiverRuleAttr] = rEntry.Rule.String()
resourceAttributes[discovery.EndpointIDAttr] = "`id`"

rEntryMap := map[string]any{}
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 @@ -163,7 +163,6 @@ func TestReceiverCreatorFactoryAndConfig(t *testing.T) {
"resource_attributes": map[string]string{
"discovery.endpoint.id": "`id`",
"discovery.receiver.name": "redis",
"discovery.receiver.rule": `type == "container" && name matches "(?i)redis"`,
"discovery.receiver.type": "smartagent",
"receiver_attribute": "receiver_attribute_value",
},
Expand Down
1 change: 0 additions & 1 deletion internal/receiver/discoveryreceiver/metric_evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func (m *metricsConsumer) evaluateMetrics(md pmetric.Metrics) {
})
m.correlateResourceAttributes(m.config, attrs, corr)

attrs[receiverRuleAttr] = rEntry.Rule.String()
attrs[discovery.MessageAttr] = match.Message
attrs[discovery.StatusAttr] = string(match.Status)
m.correlations.UpdateAttrs(endpointID, attrs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ func TestMetricEvaluation(t *testing.T) {
require.Equal(t, map[string]string{
"discovery.observer.id": "an_observer/observer.name",
"discovery.receiver.name": "receiver.name",
"discovery.receiver.rule": "a.rule",
"discovery.receiver.type": "a_receiver",
"discovery.status": string(status),
"discovery.message": "desired body content",
Expand Down
1 change: 0 additions & 1 deletion internal/receiver/discoveryreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
const (
observerNameAttr = "discovery.observer.name"
observerTypeAttr = "discovery.observer.type"
receiverRuleAttr = "discovery.receiver.rule"
matchedLogAttr = "discovery.matched_log"
)

Expand Down
1 change: 0 additions & 1 deletion internal/receiver/discoveryreceiver/statement_evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ func (se *statementEvaluator) evaluateStatement(statement *statussources.Stateme
attrs[discovery.ReceiverTypeAttr] = receiverID.Type().String()
attrs[discovery.ReceiverNameAttr] = receiverID.Name()
attrs[discovery.MessageAttr] = statement.Message
attrs[receiverRuleAttr] = rEntry.Rule.String()
attrs[discovery.MessageAttr] = match.Message

// set original message as "discovery.matched_log" attribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func TestStatementEvaluation(t *testing.T) {
require.Equal(t, map[string]string{
"discovery.observer.id": "an_observer/observer.name",
"discovery.receiver.name": "receiver.name",
"discovery.receiver.rule": `type == "container"`,
"discovery.receiver.type": "a_receiver",
"discovery.status": string(status),
"discovery.message": "desired body content",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ resource_logs:
discovery.endpoint.id: (host_observer)[::]-8888-TCP-1
discovery.observer.id: host_observer
discovery.receiver.config: cmVjZWl2ZXJzOgogIHByb21ldGhldXNfc2ltcGxlOgogICAgY29uZmlnOiB7fQogICAgcmVzb3VyY2VfYXR0cmlidXRlczoKICAgICAgb25lLmtleTogb25lLnZhbHVlCiAgICAgIHR3by5rZXk6IHR3by52YWx1ZQogICAgcnVsZTogdHlwZSA9PSAiaG9zdHBvcnQiIGFuZCBjb21tYW5kIGNvbnRhaW5zICJvdGVsY29sIgp3YXRjaF9vYnNlcnZlcnM6Ci0gaG9zdF9vYnNlcnZlcgo=
discovery.receiver.rule: type == "hostport" and command contains "otelcol"
discovery.receiver.type: prometheus_simple
http.scheme: http
net.host.port: "8888"
Expand Down Expand Up @@ -46,7 +45,6 @@ resource_logs:
discovery.observer.id: host_observer
discovery.receiver.config: cmVjZWl2ZXJzOgogIHByb21ldGhldXNfc2ltcGxlOgogICAgY29uZmlnOiB7fQogICAgcmVzb3VyY2VfYXR0cmlidXRlczoKICAgICAgb25lLmtleTogb25lLnZhbHVlCiAgICAgIHR3by5rZXk6IHR3by52YWx1ZQogICAgcnVsZTogdHlwZSA9PSAiaG9zdHBvcnQiIGFuZCBjb21tYW5kIGNvbnRhaW5zICJvdGVsY29sIgp3YXRjaF9vYnNlcnZlcnM6Ci0gaG9zdF9vYnNlcnZlcgo=
discovery.receiver.name: ""
discovery.receiver.rule: type == "hostport" and command contains "otelcol"
discovery.receiver.type: prometheus_simple
discovery.status: failed
discovery.message: (strict) Port appears to not be serving prometheus metrics
Expand Down

0 comments on commit fff641c

Please sign in to comment.