Same as the above, but allows host injection for testability.
(startedAt time.Time, host string)
| 2999 | |
| 3000 | // Same as the above, but allows host injection for testability. |
| 3001 | func defaultClientIDWithHost(startedAt time.Time, host string) string { |
| 3002 | const maxHostLength = 60 |
| 3003 | |
| 3004 | // Truncate degenerately long host names. |
| 3005 | host = strings.ReplaceAll(host, ".", "_") |
| 3006 | if len(host) > maxHostLength { |
| 3007 | host = host[0:maxHostLength] |
| 3008 | } |
| 3009 | |
| 3010 | // Dots, hyphens, and colons aren't particularly friendly for double click |
| 3011 | // to select (depends on application and configuration), so avoid them all |
| 3012 | // in favor of underscores. |
| 3013 | // |
| 3014 | // Go's time package is really dumb and can't format subseconds without |
| 3015 | // using a dot. So use the dot, then replace it with an underscore below. |
| 3016 | const rfc3339Compact = "2006_01_02T15_04_05.000000" |
| 3017 | |
| 3018 | return host + "_" + strings.Replace(startedAt.Format(rfc3339Compact), ".", "_", 1) |
| 3019 | } |
no outgoing calls
searching dependent graphs…