-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hive: Fix printing of hook function names
We need to have special handling for printing the start and stop hook names if the hook is not the "Hook" struct. To keep things simple just print the type name + method instead of going via FuncForPC. This makes sure we show reasonable output for polymorphic structs as well (which would not have file+line or the type params if FuncForPC was used). Log output before: level=info msg="Start hook executed" duration="1.853µs" function="node.newLocalNodeStore.func1 (local_node_store.go:80)" subsys=hive level=info msg="Start hook executed" duration="5.681µs" function="hive.Hook.Start-fm (<autogenerated>:1)" subsys=hive Log output after: level=info msg="Start hook executed" duration=992ns function="node.newLocalNodeStore.func1 (local_node_store.go:80)" subsys=hive level=info msg="Start hook executed" duration="4.939µs" function="*resource.resource[*k8s.io/api/core/v1.Node].Start" subsys=hive Signed-off-by: Jussi Maki <jussi@isovalent.com>
- Loading branch information
Showing
3 changed files
with
84 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Authors of Cilium | ||
|
||
package cell | ||
|
||
// PLACEHOLDERS. These would be in pkg/metrics. | ||
type Metric struct { | ||
Meta MetricMeta | ||
// some prometheus thing here | ||
} | ||
type MetricMeta struct { | ||
Enabled bool | ||
Description string | ||
} | ||
|
||
type metricsOut struct { | ||
Out | ||
Metrics []*Metric `group:"metrics,flatten"` | ||
} | ||
|
||
func Metrics[Cfg Flagger](ctor func(Cfg) []*Metric) Cell { | ||
// Wrap the constructor to provide the metrics in a | ||
// value group. | ||
return Provide(func(cfg Cfg) (out metricsOut) { | ||
out.Metrics = ctor(cfg) | ||
return | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters