Skip to content

[receiver/lightprometheus] Change configurable resource_attribute names #6257

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

Merged
merged 4 commits into from
May 28, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Unreleased

### 🛑 Breaking changes 🛑

- (Splunk) `receiver/lightprometheus`: Change the names of configurable `resource_attributes` to match semantic conventions. ([#6257](https://github.com/signalfx/splunk-otel-collector/pull/6257))
The following resource attributes have been renamed:
- `net.host.name` -> `server.address`
- `net.host.port` -> `server.port`
- `http.scheme` -> `url.scheme`

### 💡 Enhancements 💡

- (Splunk) `deployments/nomad`: Add official support for `v1.9.7` ([#6248](https://github.com/signalfx/splunk-otel-collector/pull/6248))
Expand Down
6 changes: 3 additions & 3 deletions internal/receiver/lightprometheusreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ The following settings can be optionally configured:
- `enabled`: (default: true)
- `service.instance.id`:
- `enabled`: (default: true)
- `net.host.name`:
- `server.address`:
- `enabled`: (default: false)
- `net.host.port`:
- `server.port`:
- `enabled`: (default: false)
- `http.scheme`:
- `url.scheme`:
- `enabled`: (default: false)
- [HTTP Client Configuration options](https://github.com/open-telemetry/opentelemetry-collector/tree/main/config/confighttp#client-configuration)

Expand Down
12 changes: 6 additions & 6 deletions internal/receiver/lightprometheusreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ func createDefaultConfig() component.Config {
ResourceAttributes: ResourceAttributesConfig{
ServiceInstanceID: ResourceAttributeConfig{Enabled: true},
ServiceName: ResourceAttributeConfig{Enabled: true},
NetHostName: ResourceAttributeConfig{Enabled: false},
NetHostPort: ResourceAttributeConfig{Enabled: false},
HTTPScheme: ResourceAttributeConfig{Enabled: false},
ServerAddress: ResourceAttributeConfig{Enabled: false},
ServerPort: ResourceAttributeConfig{Enabled: false},
URLScheme: ResourceAttributeConfig{Enabled: false},
},
}
}
Expand All @@ -50,9 +50,9 @@ type ResourceAttributeConfig struct {
type ResourceAttributesConfig struct {
ServiceName ResourceAttributeConfig `mapstructure:"service.name"`
ServiceInstanceID ResourceAttributeConfig `mapstructure:"service.instance.id"`
NetHostName ResourceAttributeConfig `mapstructure:"net.host.name"`
NetHostPort ResourceAttributeConfig `mapstructure:"net.host.port"`
HTTPScheme ResourceAttributeConfig `mapstructure:"http.scheme"`
ServerAddress ResourceAttributeConfig `mapstructure:"server.address"`
ServerPort ResourceAttributeConfig `mapstructure:"server.port"`
URLScheme ResourceAttributeConfig `mapstructure:"url.scheme"`
}

type Config struct {
Expand Down
6 changes: 3 additions & 3 deletions internal/receiver/lightprometheusreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ func TestValidConfig(t *testing.T) {
ResourceAttributes: ResourceAttributesConfig{
ServiceInstanceID: ResourceAttributeConfig{Enabled: false},
ServiceName: ResourceAttributeConfig{Enabled: false},
NetHostName: ResourceAttributeConfig{Enabled: true},
NetHostPort: ResourceAttributeConfig{Enabled: false},
HTTPScheme: ResourceAttributeConfig{Enabled: false},
ServerAddress: ResourceAttributeConfig{Enabled: true},
ServerPort: ResourceAttributeConfig{Enabled: false},
URLScheme: ResourceAttributeConfig{Enabled: false},
},
}
expectedCfg.ClientConfig.Endpoint = "http://localhost:9090/metrics"
Expand Down
6 changes: 3 additions & 3 deletions internal/receiver/lightprometheusreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ func (s *scraper) fetchPrometheusMetrics(fetch fetcher) (pmetric.Metrics, error)
if s.cfg.ResourceAttributes.ServiceName.Enabled {
res.Attributes().PutStr(conventions.AttributeServiceName, s.name)
}
if s.cfg.ResourceAttributes.NetHostName.Enabled {
if s.cfg.ResourceAttributes.ServerAddress.Enabled {
res.Attributes().PutStr(conventions.AttributeNetHostName, u.Host)
}
if s.cfg.ResourceAttributes.ServiceInstanceID.Enabled {
res.Attributes().PutStr(conventions.AttributeServiceInstanceID, u.Host)
}
if s.cfg.ResourceAttributes.NetHostPort.Enabled {
if s.cfg.ResourceAttributes.ServerPort.Enabled {
res.Attributes().PutStr(conventions.AttributeNetHostPort, u.Port())
}
if s.cfg.ResourceAttributes.HTTPScheme.Enabled {
if s.cfg.ResourceAttributes.URLScheme.Enabled {
res.Attributes().PutStr(conventions.AttributeHTTPScheme, u.Scheme)
}
s.convertMetricFamilies(metricFamilies, rm)
Expand Down
6 changes: 3 additions & 3 deletions internal/receiver/lightprometheusreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ func TestScraper(t *testing.T) {
cfg: func() *Config {
cfg := createDefaultConfig().(*Config)
cfg.ResourceAttributes.ServiceName.Enabled = true
cfg.ResourceAttributes.HTTPScheme.Enabled = true
cfg.ResourceAttributes.NetHostPort.Enabled = true
cfg.ResourceAttributes.NetHostName.Enabled = true
cfg.ResourceAttributes.URLScheme.Enabled = true
cfg.ResourceAttributes.ServerPort.Enabled = true
cfg.ResourceAttributes.ServerAddress.Enabled = true
return cfg
}(),
expectedResourceAttributes: map[string]any{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ lightprometheus:
enabled: false
service.instance.id:
enabled: false
net.host.name:
server.address:
enabled: true
Loading