-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com> chore: update to latest version of otel Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
- Loading branch information
Showing
11 changed files
with
655 additions
and
413 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,28 @@ | ||
package metrics | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"strings" | ||
|
||
"k8s.io/klog/v2" | ||
) | ||
|
||
var ( | ||
metricsBackend = flag.String("metrics-backend", "Prometheus", "Backend used for metrics") | ||
prometheusPort = flag.Int("prometheus-port", 8898, "Prometheus port for metrics backend") | ||
) | ||
|
||
const prometheusExporter = "prometheus" | ||
|
||
func InitMetricsExporter() error { | ||
mb := strings.ToLower(*metricsBackend) | ||
klog.Infof("metrics backend: %s", mb) | ||
switch mb { | ||
// Prometheus is the only exporter for now | ||
case prometheusExporter: | ||
return initPrometheusExporter() | ||
default: | ||
return fmt.Errorf("unsupported metrics backend %v", *metricsBackend) | ||
} | ||
} |
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,24 @@ | ||
package metrics | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
"go.opentelemetry.io/otel/exporters/metric/prometheus" | ||
) | ||
|
||
func initPrometheusExporter() error { | ||
pusher, err := prometheus.InstallNewPipeline(prometheus.Config{ | ||
DefaultHistogramBoundaries: []float64{ | ||
0.1, 0.2, 0.3, 0.4, 0.5, 1, 1.5, 2, 2.5, 3.0, 5.0, 10.0, 15.0, 30.0, | ||
}}) | ||
if err != nil { | ||
return err | ||
} | ||
http.HandleFunc("/", pusher.ServeHTTP) | ||
go func() { | ||
_ = http.ListenAndServe(fmt.Sprintf(":%v", *prometheusPort), nil) | ||
}() | ||
|
||
return err | ||
} |
Oops, something went wrong.