-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: impl otel metrics exporter and config
Signed-off-by: Mark Phelps <[email protected]>
- Loading branch information
1 parent
6a5e10d
commit 66f1aa3
Showing
7 changed files
with
165 additions
and
31 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
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,38 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/spf13/viper" | ||
) | ||
|
||
var ( | ||
_ defaulter = (*MetricsConfig)(nil) | ||
) | ||
|
||
type MetricsExporter string | ||
|
||
const ( | ||
MetricsPrometheus MetricsExporter = "prometheus" | ||
MetricsOTLP MetricsExporter = "otlp" | ||
) | ||
|
||
type MetricsConfig struct { | ||
Enabled bool `json:"enabled" mapstructure:"enabled" yaml:"enabled"` | ||
Exporter MetricsExporter `json:"exporter,omitempty" mapstructure:"exporter" yaml:"exporter,omitempty"` | ||
OTLP *OTLPConfig `json:"otlp,omitempty" mapstructure:"otlp" yaml:"otlp,omitempty"` | ||
} | ||
|
||
type OTLPConfig struct { | ||
Endpoint string `json:"endpoint,omitempty" mapstructure:"endpoint" yaml:"endpoint,omitempty"` | ||
} | ||
|
||
func (c *MetricsConfig) setDefaults(v *viper.Viper) error { | ||
v.SetDefault("metrics", map[string]interface{}{ | ||
"enabled": true, | ||
"exporter": MetricsPrometheus, | ||
"otlp": map[string]interface{}{ | ||
"endpoint": "localhost:4317", | ||
}, | ||
}) | ||
|
||
return nil | ||
} |
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