Skip to content

Commit

Permalink
UPPSF-1150 Fixed logging issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsvetan Dimitrov committed Mar 17, 2020
1 parent 8986950 commit 71c6358
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -5,7 +5,8 @@ STATIK_VERSION=$(shell go list -m all | grep statik | cut -d ' ' -f2)
all: clean build-readonly test

install:
go get github.com/rakyll/statik@${STATIK_VERSION}
GO111MODULE="off" go get -u github.com/myitcv/gobin
gobin github.com/rakyll/statik@${STATIK_VERSION}

build:
@echo ">>> Embedding static resources in binary..."
Expand Down
1 change: 0 additions & 1 deletion configs/app.yml
Expand Up @@ -42,7 +42,6 @@ contentMetadata:
contentType: "article"
pac:
origin: "http://cmdb.ft.com/systems/pac"
contentType: "article"

esContentTypeMetadata:
article:
Expand Down
12 changes: 7 additions & 5 deletions pkg/mapper/mapper.go
Expand Up @@ -59,11 +59,12 @@ func (h *Handler) ToIndexModel(enrichedContent schema.EnrichedContent, contentTy
h.populateContentRelatedFields(&model, enrichedContent, contentType, tid)

annotations, concepts, err := h.prepareAnnotationsWithConcepts(&enrichedContent, tid)
log := h.log.WithTransactionID(tid).WithUUID(enrichedContent.UUID)
if err != nil {
if err == errNoAnnotation {
h.log.WithTransactionID(tid).Warn(err.Error())
log.Warn(err.Error())
} else {
h.log.WithTransactionID(tid).WithError(err).Error(err)
log.WithError(err).Error(err)
}
return model
}
Expand All @@ -72,14 +73,14 @@ func (h *Handler) ToIndexModel(enrichedContent schema.EnrichedContent, contentTy
canonicalID := strings.TrimPrefix(annotation.ID, concept.ThingURIPrefix)
concepts, found := concepts[annotation.ID]
if !found {
h.log.WithTransactionID(tid).WithUUID(enrichedContent.UUID).Warnf("No concordance found for %v", canonicalID)
log.Warnf("No concordance found for %v", canonicalID)
continue
}
annIDs := []string{canonicalID}
if concepts.TmeIDs != nil {
annIDs = append(annIDs, concepts.TmeIDs...)
} else {
h.log.WithTransactionID(tid).WithUUID(enrichedContent.Content.UUID).Warnf("TME id missing for concept with id %s, using only canonical id", canonicalID)
log.Warnf("TME id missing for concept with id %s, using only canonical id", canonicalID)
}

h.populateAnnotationRelatedFields(annotation, &model, annIDs, canonicalID)
Expand Down Expand Up @@ -225,8 +226,9 @@ func (h *Handler) populateContentRelatedFields(model *schema.IndexModel, enriche
imageID, err = uuidutils.NewUUIDDeriverWith(uuidutils.IMAGE_SET).From(imageSetUUID)
}

log := h.log.WithTransactionID(tid).WithUUID(enrichedContent.UUID)
if err != nil {
h.log.WithTransactionID(tid).WithError(err).Warnf("Couldn't generate image uuid for the image set with uuid %s: image field won't be populated.", enrichedContent.Content.MainImage)
log.WithError(err).Warnf("Couldn't generate image uuid for the image set with uuid %s: image field won't be populated.", enrichedContent.Content.MainImage)
} else {
*model.ThumbnailURL = strings.Replace(imageServiceURL, imagePlaceholder, imageID.String(), -1)
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/message/message_handler.go
Expand Up @@ -110,16 +110,14 @@ func (h *Handler) handleMessage(msg consumer.Message) {
return
}

log = log.WithMonitoringEvent("ContentDeleteElasticsearch", tid, contentType)

conceptType := h.Mapper.Config.ESContentTypeMetadataMap.Get(contentType).Collection
if combinedPostPublicationEvent.MarkedDeleted == "true" {
_, err = h.esService.DeleteData(conceptType, uuid)
if err != nil {
log.WithError(err).Error("Failed to delete indexed content")
return
}
log.Info("Successfully deleted")
log.WithMonitoringEvent("ContentDeleteElasticsearch", tid, contentType).Info("Successfully deleted")
return
}

Expand All @@ -135,7 +133,7 @@ func (h *Handler) handleMessage(msg consumer.Message) {
log.WithError(err).Error("Failed to index content")
return
}
log.Info("Successfully saved")
log.WithMonitoringEvent("ContentWriteElasticsearch", tid, contentType).Info("Successfully saved")
}

func (h *Handler) readContentType(msg consumer.Message, event schema.EnrichedContent) string {
Expand Down

0 comments on commit 71c6358

Please sign in to comment.