Skip to content

Commit

Permalink
Add gateway host to trace / log redis lock error (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-lombardi authored Oct 17, 2024
1 parent d6cf954 commit 2654901
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/abstractions/common/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package abstractions
import (
"context"
"errors"
"fmt"
"log"
"os"
"time"

"github.com/beam-cloud/beta9/pkg/common"
Expand Down Expand Up @@ -178,7 +180,6 @@ func (i *AutoscaledInstance) ConsumeContainerEvent(event types.ContainerEvent) {
}

func (i *AutoscaledInstance) Monitor() error {

go i.Autoscaler.Start(i.Ctx) // Start the autoscaler
ignoreScalingEventWindow := time.Now().Add(-IgnoreScalingEventInterval)

Expand Down Expand Up @@ -224,12 +225,14 @@ func (i *AutoscaledInstance) Monitor() error {

func (i *AutoscaledInstance) HandleScalingEvent(desiredContainers int) error {
trace := common.TraceFunc(i.Ctx, "pkg/abstractions/common", "AutoscaledInstance.HandleScalingEvent",
attribute.String("stub.id", i.Stub.ExternalId))
attribute.String("stub.id", i.Stub.ExternalId),
attribute.String("gateway.host", os.Getenv("HOSTNAME")),
)
defer trace.End()

err := i.Lock.Acquire(i.Ctx, i.InstanceLockKey, common.RedisLockOptions{TtlS: 10, Retries: 0})
if err != nil {
trace.Span.AddEvent("Failed to acquire lock")
trace.Span.AddEvent(fmt.Sprintf("Failed to acquire lock: %v", err))
return err
}
defer i.Lock.Release(i.InstanceLockKey)
Expand Down

0 comments on commit 2654901

Please sign in to comment.