Dynatrace mock (#2745)
* feat(web): small changes in dynatrace + mock for testing * feat(backend): undo dynatrace mock * feat(backend): removed commented code from page builder * feat(backend): added 404 for not found sql response in integrations
This commit is contained in:
parent
c47d1063c1
commit
d2a5f42e37
3 changed files with 11 additions and 14 deletions
|
|
@ -72,7 +72,7 @@ func (b *pageEventBuilder) Handle(message Message, timestamp uint64) Message {
|
||||||
if msg.FirstContentfulPaint <= 30000 {
|
if msg.FirstContentfulPaint <= 30000 {
|
||||||
b.pageEvent.FirstContentfulPaint = msg.FirstContentfulPaint
|
b.pageEvent.FirstContentfulPaint = msg.FirstContentfulPaint
|
||||||
}
|
}
|
||||||
return nil //b.buildIfTimingsComplete()
|
return nil
|
||||||
case *PageRenderTiming:
|
case *PageRenderTiming:
|
||||||
if b.pageEvent == nil {
|
if b.pageEvent == nil {
|
||||||
break
|
break
|
||||||
|
|
@ -80,7 +80,7 @@ func (b *pageEventBuilder) Handle(message Message, timestamp uint64) Message {
|
||||||
b.pageEvent.SpeedIndex = msg.SpeedIndex
|
b.pageEvent.SpeedIndex = msg.SpeedIndex
|
||||||
b.pageEvent.VisuallyComplete = msg.VisuallyComplete
|
b.pageEvent.VisuallyComplete = msg.VisuallyComplete
|
||||||
b.pageEvent.TimeToInteractive = msg.TimeToInteractive
|
b.pageEvent.TimeToInteractive = msg.TimeToInteractive
|
||||||
return nil //b.buildIfTimingsComplete()
|
return nil
|
||||||
case *WebVitals:
|
case *WebVitals:
|
||||||
if b.webVitals == nil {
|
if b.webVitals == nil {
|
||||||
b.webVitals = make(map[string]string)
|
b.webVitals = make(map[string]string)
|
||||||
|
|
@ -105,17 +105,8 @@ func (b *pageEventBuilder) Build() Message {
|
||||||
if vitals, err := json.Marshal(b.webVitals); err == nil {
|
if vitals, err := json.Marshal(b.webVitals); err == nil {
|
||||||
pageEvent.WebVitals = string(vitals)
|
pageEvent.WebVitals = string(vitals)
|
||||||
} else {
|
} else {
|
||||||
// DEBUG
|
|
||||||
fmt.Printf("Error marshalling web vitals: %v\n", err)
|
fmt.Printf("Error marshalling web vitals: %v\n", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pageEvent
|
return pageEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (b *pageEventBuilder) buildIfTimingsComplete() Message {
|
|
||||||
// if b.firstTimingHandled {
|
|
||||||
// return b.Build()
|
|
||||||
// }
|
|
||||||
// b.firstTimingHandled = true
|
|
||||||
// return nil
|
|
||||||
//}
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ func requestParams(sessionID uint64) url.Values {
|
||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dynatraceClient) requestLogs(token, environmentID string, sessionID uint64) (*Logs, error) {
|
func (d *dynatraceClient) requestLogs(token, environmentID string, sessionID uint64) (interface{}, error) {
|
||||||
requestURL := fmt.Sprintf("https://%s.live.dynatrace.com/api/v2/logs/search", environmentID)
|
requestURL := fmt.Sprintf("https://%s.live.dynatrace.com/api/v2/logs/search", environmentID)
|
||||||
if sessionID == 0 {
|
if sessionID == 0 {
|
||||||
requestURL += "?" + testRequestParams().Encode()
|
requestURL += "?" + testRequestParams().Encode()
|
||||||
|
|
@ -149,5 +149,6 @@ func (d *dynatraceClient) requestLogs(token, environmentID string, sessionID uin
|
||||||
if len(logs.Results) == 0 {
|
if len(logs.Results) == 0 {
|
||||||
return nil, fmt.Errorf("empty logs, body: %s", string(body))
|
return nil, fmt.Errorf("empty logs, body: %s", string(body))
|
||||||
}
|
}
|
||||||
return logs, nil
|
responseContent, _ := json.Marshal(logs.Results)
|
||||||
|
return responseContent, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
|
@ -90,7 +91,11 @@ func (e *Router) getIntegration(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
intParams, err := e.services.Integrator.GetIntegration(project, integration)
|
intParams, err := e.services.Integrator.GetIntegration(project, integration)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
e.ResponseWithError(r.Context(), w, http.StatusInternalServerError, err, startTime, r.URL.Path, bodySize)
|
if strings.Contains(err.Error(), "no rows in result set") {
|
||||||
|
e.ResponseWithError(r.Context(), w, http.StatusNotFound, err, startTime, r.URL.Path, bodySize)
|
||||||
|
} else {
|
||||||
|
e.ResponseWithError(r.Context(), w, http.StatusInternalServerError, err, startTime, r.URL.Path, bodySize)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.ResponseWithJSON(r.Context(), w, intParams, startTime, r.URL.Path, bodySize)
|
e.ResponseWithJSON(r.Context(), w, intParams, startTime, r.URL.Path, bodySize)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue