From 631a48965e917c527d22ee3ed911091d4ae918cd Mon Sep 17 00:00:00 2001 From: Kristof Kowalski Date: Fri, 20 Oct 2023 15:15:31 +1100 Subject: [PATCH] feat: add prurl formatting --- receiver/githubactionseventreceiver/trace_receiver.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/receiver/githubactionseventreceiver/trace_receiver.go b/receiver/githubactionseventreceiver/trace_receiver.go index 53f0c4327d9b..b01a9c2d523d 100644 --- a/receiver/githubactionseventreceiver/trace_receiver.go +++ b/receiver/githubactionseventreceiver/trace_receiver.go @@ -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 @@ -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, ";")) } @@ -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()