zqr10159 opened a new pull request, #29:
URL: https://github.com/apache/hertzbeat-collector-go/pull/29

   This pull request introduces support for HTTP and HTTPS protocol collectors, 
enhances parameter replacement logic for metrics collection, and refactors the 
handling of HTTP protocol configuration. The changes improve flexibility and 
correctness in protocol handling, especially for HTTP(S) jobs, and ensure that 
configuration parameters are properly injected and replaced throughout the 
metrics collection process.
   
   ### Protocol Collector Registration
   
   * Added registration of HTTP and HTTPS protocol collectors in the `strategy` 
factory, enabling the system to collect metrics using these protocols. 
(`internal/collector/basic/init.go`) 
[[1]](diffhunk://#diff-758eae41723f0bab0839183d29735058547682fe41433609dae4e563dd273468R24)
 
[[2]](diffhunk://#diff-758eae41723f0bab0839183d29735058547682fe41433609dae4e563dd273468R43-L45)
   
   ### Metrics Collection and Parameter Replacement
   
   * Refactored the metrics collection flow to populate and merge configuration 
parameters from jobs into metrics, and applied centralized parameter 
replacement for all protocols using the new `Replacer.ReplaceMetricsParams` 
method. This ensures that placeholders in configuration are properly replaced 
before collection. 
(`internal/collector/common/collect/dispatch/metrics_collector.go`) 
[[1]](diffhunk://#diff-140e3d622aa113c6a5443cee5a1bdeadf2735fd13faafde7511126f0e043a390R523-R549)
 
[[2]](diffhunk://#diff-140e3d622aa113c6a5443cee5a1bdeadf2735fd13faafde7511126f0e043a390L553-R562)
   * Improved parameter replacement logic to handle nil values gracefully and 
avoid unwanted literal values in configuration. 
(`internal/collector/common/collect/dispatch/metrics_collector.go`)
   
   ### HTTP Protocol Configuration
   
   * Refactored the `HTTPProtocol` struct to support a more flexible 
authorization configuration, replacing simple username/password fields with a 
nested `Authorization` struct and adding support for timeout and SSL as 
strings. (`internal/collector/common/types/job/metrics_types.go`)
   * Implemented deep copy logic for the new HTTP protocol configuration in job 
cloning to ensure correct duplication of headers, params, and authorization 
details. (`internal/collector/common/types/job/metrics_types.go`)
   
   ### Parameter Replacement Logic Refactoring
   
   * Replaced the legacy `replaceMetricsParams` with an exported 
`ReplaceMetricsParams` method in `Replacer`, which now supports parameter 
replacement for JDBC, SSH, and HTTP protocols, including nested fields and 
headers/params/authorization for HTTP. 
(`internal/util/param/param_replacer.go`) 
[[1]](diffhunk://#diff-6433f1b940691e91587ab59c9c3e2b58683ca866bd87c1ee5c7dfc15d3886da7L89-R89)
 
[[2]](diffhunk://#diff-6433f1b940691e91587ab59c9c3e2b58683ca866bd87c1ee5c7dfc15d3886da7L129-R150)
 
[[3]](diffhunk://#diff-6433f1b940691e91587ab59c9c3e2b58683ca866bd87c1ee5c7dfc15d3886da7L205-R207)
   * Added a specialized `replaceHTTPParams` method to handle parameter 
replacement in HTTP protocol configurations, including nested maps and 
authorization fields. (`internal/util/param/param_replacer.go`)
   
   ### Code Comments and Documentation
   
   * Updated and clarified comments throughout the metrics collector and 
parameter replacer code to better document supported formats and logic, aiding 
maintainability and understanding for future development. 
(`internal/collector/common/collect/dispatch/metrics_collector.go`, 
`internal/util/param/param_replacer.go`) 
[[1]](diffhunk://#diff-140e3d622aa113c6a5443cee5a1bdeadf2735fd13faafde7511126f0e043a390L221-L226)
 
[[2]](diffhunk://#diff-140e3d622aa113c6a5443cee5a1bdeadf2735fd13faafde7511126f0e043a390L316-L320)
 
[[3]](diffhunk://#diff-140e3d622aa113c6a5443cee5a1bdeadf2735fd13faafde7511126f0e043a390L393-L394)
 
[[4]](diffhunk://#diff-140e3d622aa113c6a5443cee5a1bdeadf2735fd13faafde7511126f0e043a390L429-L432)
 
[[5]](diffhunk://#diff-140e3d622aa113c6a5443cee5a1bdeadf2735fd13faafde7511126f0e043a390L487)
 
[[6]](diffhunk://#diff-140e3d622aa113c6a5443cee5a1bdeadf2735fd13faafde7511126f0e043a390R523-R549)
 
[[7]](diffhunk://#diff-6433f1b940691e91587ab59c9c3e2b58683ca866bd87c1ee5c7dfc15d3886da7L129-R150
 ) 
[[8]](diffhunk://#diff-6433f1b940691e91587ab59c9c3e2b58683ca866bd87c1ee5c7dfc15d3886da7L205-R207)
 
[[9]](diffhunk://#diff-6433f1b940691e91587ab59c9c3e2b58683ca866bd87c1ee5c7dfc15d3886da7L214-L218)
 
[[10]](diffhunk://#diff-6433f1b940691e91587ab59c9c3e2b58683ca866bd87c1ee5c7dfc15d3886da7L227-L235)
 
[[11]](diffhunk://#diff-6433f1b940691e91587ab59c9c3e2b58683ca866bd87c1ee5c7dfc15d3886da7L252-L286)
 
[[12]](diffhunk://#diff-6433f1b940691e91587ab59c9c3e2b58683ca866bd87c1ee5c7dfc15d3886da7L296-L298)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to