You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by jo...@apache.org on 2020/09/27 14:21:26 UTC
[dubbo-samples] 15/26: add metric samples
This is an automated email from the ASF dual-hosted git repository.
joezou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git
commit 34ad2892e16eb743296a1bfd5291e8858a22aeb3
Author: Joe Zou <yi...@gmail.com>
AuthorDate: Tue Aug 25 23:19:04 2020 +0800
add metric samples
---
golang/go.mod | 1 +
golang/metric/dubbo/go-server/app/server.go | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/golang/go.mod b/golang/go.mod
index ebb5988..0c76454 100644
--- a/golang/go.mod
+++ b/golang/go.mod
@@ -10,6 +10,7 @@ require (
github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5
github.com/openzipkin/zipkin-go v0.2.2
github.com/pkg/errors v0.9.1
+ github.com/prometheus/client_golang v1.1.0
github.com/uber/jaeger-client-go v2.22.1+incompatible
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
google.golang.org/grpc v1.23.0
diff --git a/golang/metric/dubbo/go-server/app/server.go b/golang/metric/dubbo/go-server/app/server.go
index 911a0eb..b47cf2e 100755
--- a/golang/metric/dubbo/go-server/app/server.go
+++ b/golang/metric/dubbo/go-server/app/server.go
@@ -18,7 +18,10 @@
package main
import (
+ "flag"
"fmt"
+
+ "net/http"
"os"
"os/signal"
"syscall"
@@ -26,6 +29,10 @@ import (
)
import (
+ "github.com/prometheus/client_golang/prometheus/promhttp"
+)
+
+import (
hessian "github.com/apache/dubbo-go-hessian2"
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/config"
@@ -50,6 +57,11 @@ var (
// export APP_LOG_CONF_FILE="xxx"
func main() {
+ var addr = flag.String("listen-address", ":8080", "The address to listen on for HTTP requests.")
+ flag.Parse()
+ http.Handle("/metrics", promhttp.Handler())
+ go http.ListenAndServe(*addr, nil)
+
hessian.RegisterPOJO(&User{})
config.Load()
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org