提交 45939d7f 编写于 作者: Y Your Name

修改初始化sql

上级 e03fea14
......@@ -3,12 +3,14 @@ package application
import (
"bytes"
"errors"
"github.com/eolinker/goku-api-gateway/diting"
goku_labels "github.com/eolinker/goku-api-gateway/goku-labels"
"github.com/eolinker/goku-api-gateway/node/monitor"
"io"
"net/http"
"net/url"
"github.com/eolinker/goku-api-gateway/diting"
goku_labels "github.com/eolinker/goku-api-gateway/goku-labels"
"github.com/eolinker/goku-api-gateway/node/monitor"
// "fmt"
"time"
)
......@@ -99,16 +101,16 @@ func (r *Request) Send() (*http.Response, error) {
if err != nil {
return nil, err
}
start:=time.Now()
start := time.Now()
defer func() {
delay:= time.Since(start)
labels:= make(diting.Labels)
delay := time.Since(start)
labels := make(diting.Labels)
labels[goku_labels.Proto] = req.Proto
labels[goku_labels.Host] = req.Host
labels[goku_labels.Path] = req.URL.Path
labels[goku_labels.Method] = req.Method
monitor.ProxyMonitor.Observe(float64( delay.Milliseconds()),labels)
monitor.ProxyMonitor.Observe(float64(delay/time.Millisecond), labels)
}()
req.Header.Set("Accept-Encoding", "gzip")
req.Header = parseHeaders(r.headers)
......
......@@ -2,13 +2,14 @@ package gateway
import (
"fmt"
"github.com/eolinker/goku-api-gateway/diting"
goku_labels "github.com/eolinker/goku-api-gateway/goku-labels"
"github.com/eolinker/goku-api-gateway/node/monitor"
"net/http"
"strconv"
"time"
"github.com/eolinker/goku-api-gateway/diting"
goku_labels "github.com/eolinker/goku-api-gateway/goku-labels"
"github.com/eolinker/goku-api-gateway/node/monitor"
log "github.com/eolinker/goku-api-gateway/goku-log"
access_log "github.com/eolinker/goku-api-gateway/goku-node/access-log"
"github.com/eolinker/goku-api-gateway/goku-node/common"
......@@ -53,7 +54,7 @@ func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
n, status := ctx.Finish()
delay:= time.Since(timeStart)
delay := time.Since(timeStart)
ctx.LogFields[fields.RequestID] = requestID
ctx.LogFields[fields.StatusCode] = status
......@@ -66,15 +67,12 @@ func (h *HTTPHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
access_log.Log(ctx.LogFields)
log.WithFields(ctx.LogFields).Info()
// 监控计数
labels:= make(diting.Labels)
labels := make(diting.Labels)
labels[goku_labels.API] = strconv.Itoa(ctx.ApiID())
labels[goku_labels.Strategy] = ctx.StrategyId()
labels[goku_labels.Status] = strconv.Itoa(status)
monitor.APIMonitor.Observe( float64( delay.Milliseconds()),labels)
monitor.APIMonitor.Observe(float64(delay/time.Millisecond), labels)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册