Skip to content

Commit

Permalink
feat: Add telemetry for all unsuccessful status codes returned from W…
Browse files Browse the repository at this point in the history
…akeup calls
  • Loading branch information
Matovidlo committed Nov 19, 2024
1 parent 3979510 commit 6154672
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
11 changes: 6 additions & 5 deletions internal/pkg/service/appsproxy/dataapps/api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ import (

const (
// maxCacheExpiration is the maximum duration for which an old AppConfig of a data app is cached.
maxCacheExpiration = time.Hour
attrProjectID = "proxy.app.projectId"
attrAppID = "proxy.app.id"
attrAppName = "proxy.app.name"
attrAppUpstream = "proxy.app.upstream"
maxCacheExpiration = time.Hour
attrSandboxesServiceStatusCode = "proxy.sandboxesService.statusCode"
attrProjectID = "proxy.app.projectId"
attrAppID = "proxy.app.id"
attrAppName = "proxy.app.name"
attrAppUpstream = "proxy.app.upstream"
)

type AppID string
Expand Down
16 changes: 15 additions & 1 deletion internal/pkg/service/appsproxy/dataapps/api/wakeup.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package api

import "github.com/keboola/go-client/pkg/request"
import (
"context"

"github.com/keboola/go-client/pkg/request"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)

type wakeupBody struct {
DesiredState string `json:"desiredState"`
Expand All @@ -9,6 +15,14 @@ type wakeupBody struct {
func (a *API) WakeupApp(appID AppID) request.APIRequest[request.NoResult] {
return request.NewAPIRequest(request.NoResult{}, a.newRequest().
WithError(&Error{}).
WithOnError(func(ctx context.Context, response request.HTTPResponse, err error) error {
span := trace.SpanFromContext(ctx)
attrs := []attribute.KeyValue{
attribute.Int(attrSandboxesServiceStatusCode, response.StatusCode()),
}
span.SetAttributes(attrs...)
return nil
}).
WithPatch("apps/{appId}").
AndPathParam("appId", appID.String()).
WithJSONBody(wakeupBody{
Expand Down

0 comments on commit 6154672

Please sign in to comment.