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 {
|
||||
b.pageEvent.FirstContentfulPaint = msg.FirstContentfulPaint
|
||||
}
|
||||
return nil //b.buildIfTimingsComplete()
|
||||
return nil
|
||||
case *PageRenderTiming:
|
||||
if b.pageEvent == nil {
|
||||
break
|
||||
|
|
@ -80,7 +80,7 @@ func (b *pageEventBuilder) Handle(message Message, timestamp uint64) Message {
|
|||
b.pageEvent.SpeedIndex = msg.SpeedIndex
|
||||
b.pageEvent.VisuallyComplete = msg.VisuallyComplete
|
||||
b.pageEvent.TimeToInteractive = msg.TimeToInteractive
|
||||
return nil //b.buildIfTimingsComplete()
|
||||
return nil
|
||||
case *WebVitals:
|
||||
if b.webVitals == nil {
|
||||
b.webVitals = make(map[string]string)
|
||||
|
|
@ -105,17 +105,8 @@ func (b *pageEventBuilder) Build() Message {
|
|||
if vitals, err := json.Marshal(b.webVitals); err == nil {
|
||||
pageEvent.WebVitals = string(vitals)
|
||||
} else {
|
||||
// DEBUG
|
||||
fmt.Printf("Error marshalling web vitals: %v\n", err)
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
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)
|
||||
if sessionID == 0 {
|
||||
requestURL += "?" + testRequestParams().Encode()
|
||||
|
|
@ -149,5 +149,6 @@ func (d *dynatraceClient) requestLogs(token, environmentID string, sessionID uin
|
|||
if len(logs.Results) == 0 {
|
||||
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"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"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)
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
e.ResponseWithJSON(r.Context(), w, intParams, startTime, r.URL.Path, bodySize)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue