Skip to content

Commit

Permalink
feat: add prurl formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
krzko committed Oct 20, 2023
1 parent a09296e commit 631a489
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions receiver/githubactionseventreceiver/trace_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func eventToTraces(event interface{}, config *Config, logger *zap.Logger) (ptrac
}
default:
logger.Error("unknown event type, dropping payload")
return ptrace.Traces{}, fmt.Errorf("unknown event type, dropping payload")
return ptrace.Traces{}, fmt.Errorf("unknown event type")
}

return traces, nil
Expand Down Expand Up @@ -233,7 +233,7 @@ func createResourceAttributes(resource pcommon.Resource, event interface{}, conf
if len(e.WorkflowRun.PullRequests) > 0 {
var prUrls []string
for _, pr := range e.WorkflowRun.PullRequests {
prUrls = append(prUrls, pr.URL)
prUrls = append(prUrls, convertPRURL(pr.URL))
}
attrs.PutStr("scm.git.pull_requests.url", strings.Join(prUrls, ";"))
}
Expand All @@ -245,6 +245,12 @@ func createResourceAttributes(resource pcommon.Resource, event interface{}, conf
}
}

func convertPRURL(apiURL string) string {
apiURL = strings.Replace(apiURL, "/repos", "", 1)
apiURL = strings.Replace(apiURL, "/pulls", "/pull", 1)
return strings.Replace(apiURL, "api.", "", 1)
}

func createRootSpan(resourceSpans ptrace.ResourceSpans, event *WorkflowRunEvent, traceID pcommon.TraceID, logger *zap.Logger) (pcommon.SpanID, error) {
logger.Info("Creating root parent span", zap.String("name", event.WorkflowRun.Name))
scopeSpans := resourceSpans.ScopeSpans().AppendEmpty()
Expand Down

0 comments on commit 631a489

Please sign in to comment.