Skip to content

Commit

Permalink
Emit SSH endpoint resource attribute (open-telemetry#24441)
Browse files Browse the repository at this point in the history
  • Loading branch information
DewaldDeJager committed Jul 30, 2023
1 parent 19f2a53 commit bc0378b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
- `filelogreceiver`: Fix issue where files were deduplicated unnecessarily (#24235)
- `processor/tailsamplingprocessor`: Fix data race when accessing spans during policies evaluation (#24283)
- `zipkintranslator`: Stop dropping error tags from Zipkin spans. The old code removes all errors from those spans, rendering them useless if an actual error happened. In addition, no longer delete error tags if they contain useful information. (#16530)
- `sshcheckreceiver`: Add the SSH endpoint as a resource attribute (#24441)

## v0.81.0

Expand Down
5 changes: 4 additions & 1 deletion receiver/sshcheckreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type sshcheckScraper struct {
*configssh.Client
*Config
settings component.TelemetrySettings
rb *metadata.ResourceBuilder
mb *metadata.MetricsBuilder
}

Expand Down Expand Up @@ -124,13 +125,15 @@ func (s *sshcheckScraper) scrape(ctx context.Context) (_ pmetric.Metrics, err er
}
}

return s.mb.Emit(), nil
s.rb.SetSSHEndpoint(s.Config.SSHClientSettings.Endpoint)
return s.mb.Emit(metadata.WithResource(s.rb.Emit())), nil
}

func newScraper(conf *Config, settings receiver.CreateSettings) *sshcheckScraper {
return &sshcheckScraper{
Config: conf,
settings: settings.TelemetrySettings,
rb: metadata.NewResourceBuilder(conf.MetricsBuilderConfig.ResourceAttributes),
mb: metadata.NewMetricsBuilder(conf.MetricsBuilderConfig, settings),
}
}
Expand Down
2 changes: 1 addition & 1 deletion receiver/sshcheckreceiver/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ receivers:
endpoint: notdefault:1313
username: notdefault_password
password: notdefault_password
keyfile: notdefault/path/keyfile
key_file: notdefault/path/keyfile
collection_interval: 13m
known_hosts: path/to/collector_known_hosts
ignore_host_key: false
Expand Down

0 comments on commit bc0378b

Please sign in to comment.