Skip to content

Commit

Permalink
ref: add metrics prometheus exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
kenriortega committed Nov 14, 2021
1 parent 1dbcc79 commit 641becd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
9 changes: 0 additions & 9 deletions pkg/otelify/otelify.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"context"
"log"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"google.golang.org/grpc"

"go.opentelemetry.io/otel"
Expand All @@ -17,13 +15,6 @@ import (
semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
)

var MetricRequestLatencyProxy = promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: "ngonx",
Name: "request_latency_seconds",
Help: "Request Latency",
Buckets: prometheus.ExponentialBuckets(.0001, 2, 50),
})

// Initializes an OTLP exporter, and configures the corresponding trace and
// metric providers.
func InitProvider(name, version, namEnv, endpoint string) func() {
Expand Down
24 changes: 24 additions & 0 deletions pkg/otelify/prometheus.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package otelify

import (
"fmt"
"log"
"net/http"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

var MetricRequestLatencyProxy = promauto.NewHistogram(prometheus.HistogramOpts{
Namespace: "ngonx",
Name: "request_latency_seconds",
Help: "Request Latency",
Buckets: prometheus.ExponentialBuckets(.0001, 2, 50),
})

func ExposeMetricServer(configPort int) {
http.Handle("/metrics", promhttp.Handler())
port := fmt.Sprintf(":%d", configPort)
log.Fatal(http.ListenAndServe(port, nil))
}

0 comments on commit 641becd

Please sign in to comment.