Skip to content

Commit

Permalink
replace SignalType errors with logs
Browse files Browse the repository at this point in the history
  • Loading branch information
mterhar committed Dec 20, 2024
1 parent c3c82a0 commit 500af80
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
19 changes: 11 additions & 8 deletions receiver/libhoneyreceiver/internal/libhoneyevent/libhoneyevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,29 @@ func (l *LibhoneyEvent) DebugString() string {
}

// SignalType returns the type of signal this event represents. Only log is implemented for now.
func (l *LibhoneyEvent) SignalType() (string, error) {
func (l *LibhoneyEvent) SignalType(logger zap.Logger) string {
if sig, ok := l.Data["meta.signal_type"]; ok {
switch sig {
case "trace":
if atype, ok := l.Data["meta.annotation_type"]; ok {
if atype == "span_event" {
return "span_event", nil
return "span_event"
} else if atype == "link" {
return "span_link", nil
return "span_link"
}
return "span", errors.New("invalid annotation type, but probably a span")
logger.Warn("invalid annotation type", zap.String("meta.annotation_type", atype.(string)))
return "span"
}
return "span", nil
return "span"
case "log":
return "log", nil
return "log"
default:
return "log", errors.New("invalid meta.signal_type")
logger.Warn("invalid meta.signal_type", zap.String("meta.signal_type", sig.(string)))
return "log"
}
}
return "log", errors.New("missing meta.signal_type and meta.annotation_type")
logger.Warn("missing meta.signal_type and meta.annotation_type")
return "log"
}

// GetService returns the service name from the event or the dataset name if no service name is found.
Expand Down
5 changes: 1 addition & 4 deletions receiver/libhoneyreceiver/internal/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ func ToPdata(dataset string, lhes []libhoneyevent.LibhoneyEvent, cfg libhoneyeve
logger.Warn("parent id not found")
}

action, err := lhe.SignalType()
if err != nil {
logger.Warn("signal type unclear")
}
action := lhe.SignalType(logger)
switch action {
case "span":
spanService, _ := lhe.GetService(cfg, &foundServices, dataset)
Expand Down

0 comments on commit 500af80

Please sign in to comment.