Skip to content

Commit

Permalink
Merge pull request #150 from instana/log_docker_stats_errors
Browse files Browse the repository at this point in the history
Log errors occurred while fetching the Docker container stats
  • Loading branch information
Andrey Slotin authored Sep 16, 2020
2 parents c61ec47 + 489853f commit c7017c9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fargate_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ func newFargateAgent(
ServiceName: serviceName,
},
dockerStats: &ecsDockerStatsCollector{
ecs: mdProvider,
ecs: mdProvider,
logger: logger,
},
processStats: &processStatsCollector{
logger: logger,
Expand Down Expand Up @@ -381,6 +382,7 @@ type ecsDockerStatsCollector struct {
ecs interface {
TaskStats(context.Context) (map[string]docker.ContainerStats, error)
}
logger LeveledLogger

mu sync.RWMutex
stats map[string]docker.ContainerStats
Expand Down Expand Up @@ -414,11 +416,12 @@ func (c *ecsDockerStatsCollector) fetchStats(ctx context.Context) {
if err != nil {
if ctx.Err() != nil {
// request either timed out or had been cancelled, keep the old value
c.logger.Debug("failed to retireve Docker container stats (timed out), skipping")
return
}

// request failed, reset recorded stats
// TODO: log error
c.logger.Warn("failed to retrieve Docker container stats: ", err)
stats = nil
}

Expand Down

0 comments on commit c7017c9

Please sign in to comment.