collector icon indicating copy to clipboard operation
collector copied to clipboard

Stop copying hostname

Open Molter73 opened this issue 7 months ago • 1 comments

Description

The hostname for a given node is lazily loaded in the HostInfo and will outlast any other object attempting to use it. As such, we should try to avoid unnecessary copies and just call the GetHostname method of the HostInfo class.

The GetHostname function from our utilities has been turned into a static method of HostInfo so we can directly access it calling HostInfo::GetHostname(), otherwise we would need HostInfo::Instance().GetHostname() which is a bit too verbose.

Checklist

  • [x] Investigated and inspected CI test results
  • [ ] Updated documentation accordingly

Automated testing

  • [ ] Added unit tests
  • [ ] Added integration tests
  • [ ] Added regression tests

If any of these don't apply, please comment below.

Testing Performed

  • [x] Check CI logs to validate the hostname is properly being captured.

Molter73 avatar Apr 11 '25 09:04 Molter73

Codecov Report

Attention: Patch coverage is 0% with 28 lines in your changes missing coverage. Please review.

Project coverage is 27.53%. Comparing base (0d6cb4c) to head (671a36c).

:white_check_mark: All tests successful. No failed tests found.

Files with missing lines Patch % Lines
collector/lib/HostInfo.cpp 0.00% 17 Missing :warning:
collector/lib/HostInfo.h 0.00% 3 Missing :warning:
collector/lib/CollectorService.cpp 0.00% 2 Missing :warning:
collector/lib/GetStatus.h 0.00% 2 Missing :warning:
collector/lib/NetworkConnectionInfoServiceComm.cpp 0.00% 2 Missing :warning:
collector/lib/CollectorConfig.cpp 0.00% 1 Missing :warning:
collector/lib/GetStatus.cpp 0.00% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2082      +/-   ##
==========================================
+ Coverage   27.51%   27.53%   +0.01%     
==========================================
  Files          93       93              
  Lines        5727     5724       -3     
  Branches     2533     2532       -1     
==========================================
  Hits         1576     1576              
+ Misses       3484     3481       -3     
  Partials      667      667              
Flag Coverage Δ
collector-unit-tests 27.53% <0.00%> (+0.01%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Apr 11 '25 10:04 codecov-commenter