Skip to content

Commit

Permalink
#130 Add debug output with event/insight/blob data to committer
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrencegripper committed Jul 6, 2018
1 parent bf365a8 commit c26cd58
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ client
ionctl
frontapi
imagetag.temp
cmd/management/debug
**/debug
Binary file removed cmd/management/debug
Binary file not shown.
9 changes: 9 additions & 0 deletions internal/app/handler/committer/committer.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ func (c *Committer) commitBlob(blobsPath string) (map[string]string, error) {
}

logger.Info(c.context, "committed blob data")
logger.DebugWithFields(c.context, "blob file names", map[string]interface{}{
"files": fileNames,
})
return blobURIs, nil
}

Expand Down Expand Up @@ -183,6 +186,9 @@ func (c *Committer) commitInsights(insightsPath string) error {
}

logger.Info(c.context, "committed insights data")
logger.DebugWithFields(c.context, "insights data", map[string]interface{}{
"insight": insight,
})
return nil
}

Expand Down Expand Up @@ -220,6 +226,9 @@ func (c *Committer) commitEvents(eventsPath string, blobURIs map[string]string)
if err != nil {
return fmt.Errorf("failed to unmarshal map '%s' with error: '%+v'", fileName, err)
}
logger.DebugWithFields(c.context, "event data", map[string]interface{}{
"event": keyValuePairs,
})

var eventType string
var includedFilesCSV string
Expand Down
20 changes: 20 additions & 0 deletions internal/app/handler/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ func Info(c *common.Context, message string) {
}).Info(message)
}

// InfoWithFields logs an info message with context
func InfoWithFields(c *common.Context, message string, fields map[string]interface{}) {
log.WithFields(log.Fields{
"eventID": c.EventID,
"correlationID": c.CorrelationID,
"name": c.Name,
"timestamp": time.Now(),
}).WithFields(fields).Info(message)
}

// Debug logs a debug message with context
func Debug(c *common.Context, message string) {
log.WithFields(log.Fields{
Expand All @@ -26,6 +36,16 @@ func Debug(c *common.Context, message string) {
}).Debug(message)
}

// DebugWithFields logs an info message with context
func DebugWithFields(c *common.Context, message string, fields map[string]interface{}) {
log.WithFields(log.Fields{
"eventID": c.EventID,
"correlationID": c.CorrelationID,
"name": c.Name,
"timestamp": time.Now(),
}).WithFields(fields).Debug(message)
}

// Error logs an error message with context
func Error(c *common.Context, message string) {
log.WithFields(log.Fields{
Expand Down
13 changes: 10 additions & 3 deletions tools/end2end-smoketest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,15 @@ echo "Deploying downloader and transcoder module with tag $ION_IMAGE_TAG"
echo "--------------------------------------------------------"

docker run --network host ion-cli module create -i frontapi.new_link -o file_downloaded -n downloader -m $DOCKER_USER/ion-module-download-file:$ION_IMAGE_TAG -p kubernetes --handler-image $DOCKER_USER/ion-handler:$ION_IMAGE_TAG
docker run --network host ion-cli module create -i file_downloaded -o file_transcoded -n transcodegpu -m $DOCKER_USER/ion-module-transcode:$ION_IMAGE_TAG -p azurebatch --handler-image $DOCKER_USER/ion-handler:$ION_IMAGE_TAG
docker run --network host ion-cli module create -i file_downloaded -o file_transcoded -n transcode -m $DOCKER_USER/ion-module-transcode:$ION_IMAGE_TAG -p azurebatch --handler-image $DOCKER_USER/ion-handler:$ION_IMAGE_TAG
sleep 30


echo "--------------------------------------------------------"
echo "Submitting a video for processing to the frontapi"
echo "--------------------------------------------------------"

curl --header "Content-Type: application/json" --request POST --data '{"url": "http://www.engr.colostate.edu/me/facil/dynamics/files/bird.avi"}' http://localhost:9001/

read -p "Press enter to to stop forwarding ports to management api and front api and exit..." key
kill $FORWARD_PID1
kill $FORWARD_PID2
ps aux | grep [k]ubectl | awk '{print $2}' | xargs kill || true

0 comments on commit c26cd58

Please sign in to comment.