When attempting to enable the metric exporter, a "http nil handler" error is reported. Additionally, the app name is not correctly set when the exporter works fine (Similar to issue 453).
These issues come from that the exporter module's init function being executed before the main function.
During the exporter initialization, the HttpAddr and HttpPath in MetricExporterConfig remain empty. As a result, the exporter variable will always be newEmptyExporter, and app variable is always assigned the default value unknown_go_service' leading to incorrect label values.
Issue Description
Type: bug report
Describe what happened
When attempting to enable the metric exporter, a "http nil handler" error is reported. Additionally, the app name is not correctly set when the exporter works fine (Similar to issue 453).
These issues come from that the exporter module's init function being executed before the main function.
During the exporter initialization, the
HttpAddr
andHttpPath
inMetricExporterConfig
remain empty. As a result, the exporter variable will always benewEmptyExporter
, andapp
variable is always assigned the default valueunknown_go_service'
leading to incorrect label values.I recommend to add init steps in initCoreComponents. Just let the two variable to be correctly set when the
initCoreComponents
executes.Describe what you expected to happen
Metric exporter works correctly.
How to reproduce it (as minimally and precisely as possible)
example/flow/qps/qps_limit_example.go
, add the following exporter config:go run example/flow/qps/qps_limit_example.go
unknown_go_service
:Add the same config as above in
example/flow/qps/qps_limit_example.go
.Modify
exporter/metric/exporter.go
as follows to prevent the nil http handler error:Run the example with
go run example/flow/qps/qps_limit_example.go
Tell us your environment
macos
Anything else we need to know?