diff --git a/lisp/x/profiler/funlabeler.go b/lisp/x/profiler/funlabeler.go index 5e13519..afe4caf 100644 --- a/lisp/x/profiler/funlabeler.go +++ b/lisp/x/profiler/funlabeler.go @@ -41,7 +41,9 @@ const ELPSDocLabel = `@trace{([^}]+)}` var elpsDocLabelRegExp = regexp.MustCompile(ELPSDocLabel) var sanitizeRegExp = regexp.MustCompile(`[\W_]+`) -var validLabelRegExp = regexp.MustCompile(`[a-zA-Z_][\w_]*`) + +//var validLabelRegExp = regexp.MustCompile(`[a-zA-Z_][\w_]*`) +var validLabelRegExp = regexp.MustCompile(`[a-zA-Z][\w_]*`) func sanitizeLabel(userLabel string) string { userLabel = strings.TrimSpace(userLabel) @@ -52,16 +54,6 @@ func sanitizeLabel(userLabel string) string { // Replace spaces with underscores userLabel = sanitizeRegExp.ReplaceAllString(userLabel, "_") - // Eliminate duplicate underscores - parts := strings.Split(userLabel, "_") - var nonEmptyParts []string - for _, part := range parts { - if part != "" { - nonEmptyParts = append(nonEmptyParts, part) - } - } - userLabel = strings.Join(nonEmptyParts, "_") - // Find the first valid label match matches := validLabelRegExp.FindStringSubmatch(userLabel) if len(matches) > 0 { @@ -69,7 +61,6 @@ func sanitizeLabel(userLabel string) string { } return "" - } func elpsDocFunLabeler(runtime *lisp.Runtime, fun *lisp.LVal) string { diff --git a/lisp/x/profiler/funlabeler_test.go b/lisp/x/profiler/funlabeler_test.go index 940e05e..e281335 100644 --- a/lisp/x/profiler/funlabeler_test.go +++ b/lisp/x/profiler/funlabeler_test.go @@ -25,7 +25,7 @@ func TestSanitizeLabel(t *testing.T) { { name: "contains special characters", label: "Label@#$%^&", - expected: "Label", + expected: "Label_", }, { name: "starts with a digit", @@ -42,6 +42,11 @@ func TestSanitizeLabel(t *testing.T) { label: "_Label", expected: "Label", }, + { + name: "label with underscores", + label: "label__with__underscores", + expected: "label_with_underscores", + }, { name: "starts with a special character", label: "@Label",