-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from SimonRichardson/metrics
#20 The following starts to expose the events of a worker, so that we can better observe the changes of a juju instance. The only one that seems relevant at the moment, is how many times a start is done, but this can easily be expanded at a later date. I chose RecordStart to be explicit, rather than picking Record with a state. Although changing that in the future should be really easy.
- Loading branch information
Showing
4 changed files
with
44 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2021 Canonical Ltd. | ||
// Licensed under the LGPLv3, see LICENCE file for details. | ||
|
||
package dependency | ||
|
||
// Metrics defines a type for recording the worker life cycle in the dependency | ||
// engine. | ||
type Metrics interface { | ||
RecordStart(name string) | ||
} | ||
|
||
// noopMetrics gives a metric that doesn't do anything. | ||
type noopMetric struct{} | ||
|
||
func (noopMetric) RecordStart(name string) {} | ||
|
||
// DefaultMetrics returns a metrics implementation that performs no operations, | ||
// but can be used for scenarios where metrics output isn't required. | ||
func DefaultMetrics() Metrics { | ||
return noopMetric{} | ||
} |
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