Skip to content

Commit

Permalink
Merge pull request #739 from sysadmind/query-log
Browse files Browse the repository at this point in the history
Add job name tags to log events to improve debugging
  • Loading branch information
Victor Castell authored Apr 29, 2020
2 parents 0851cd1 + 90f2708 commit 7bfddc7
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions dkron/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ func (a *Agent) RunQuery(jobName string, ex *Execution) (*Job, error) {
if err != nil {
return nil, fmt.Errorf("agent: RunQuery error processing filtered nodes: %w", err)
}
log.Debug("agent: Filtered nodes to run: ", filterNodes)
log.Debug("agent: Filtered tags to run: ", filterTags)
log.WithFields(logrus.Fields{
"job": job.Name,
}).Debug("agent: Filtered nodes to run: ", filterNodes)
log.WithFields(logrus.Fields{
"job": job.Name,
}).Debug("agent: Filtered tags to run: ", filterTags)

//serf match regexp but we want only match full tag
serfFilterTags := make(map[string]string)
Expand Down Expand Up @@ -86,14 +90,14 @@ func (a *Agent) RunQuery(jobName string, ex *Execution) (*Job, error) {
rqpJSON, _ := json.Marshal(rqp)

log.WithFields(logrus.Fields{
"query": QueryRunJob,
"job_name": job.Name,
"query": QueryRunJob,
"job": job.Name,
}).Info("agent: Sending query")

log.WithFields(logrus.Fields{
"query": QueryRunJob,
"job_name": job.Name,
"json": string(rqpJSON),
"query": QueryRunJob,
"job": job.Name,
"json": string(rqpJSON),
}).Debug("agent: Sending query")

qr, err := a.serf.Query(QueryRunJob, rqpJSON, params)
Expand All @@ -111,13 +115,15 @@ func (a *Agent) RunQuery(jobName string, ex *Execution) (*Job, error) {
if ok {
log.WithFields(logrus.Fields{
"query": QueryRunJob,
"job": job.Name,
"from": ack,
}).Debug("agent: Received ack")
}
case resp, ok := <-respCh:
if ok {
log.WithFields(logrus.Fields{
"query": QueryRunJob,
"job": job.Name,
"from": resp.From,
"response": string(resp.Payload),
}).Debug("agent: Received response")
Expand All @@ -126,6 +132,7 @@ func (a *Agent) RunQuery(jobName string, ex *Execution) (*Job, error) {
}
log.WithFields(logrus.Fields{
"time": time.Since(start),
"job": job.Name,
"query": QueryRunJob,
}).Debug("agent: Done receiving acks and responses")

Expand Down

0 comments on commit 7bfddc7

Please sign in to comment.