-
Notifications
You must be signed in to change notification settings - Fork 21
/
utils.go
23 lines (20 loc) · 827 Bytes
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package cloudlog
import (
"fmt"
)
// GenServiceLogGroupName creates the service log group name: clustername-servicename-serviceUUID.
func GenServiceLogGroupName(cluster string, service string, serviceUUID string, k8snamespace string) string {
if len(k8snamespace) != 0 {
return fmt.Sprintf("%s-%s-%s-%s", cluster, k8snamespace, service, serviceUUID)
}
return fmt.Sprintf("%s-%s-%s", cluster, service, serviceUUID)
}
// GenServiceMemberLogStreamName creates the log stream name for one service member: membername/hostname/containerID.
func GenServiceMemberLogStreamName(memberName string, hostname string, containerID string) string {
shortID := containerID
shortIDLen := 12
if len(containerID) > shortIDLen {
shortID = containerID[0:shortIDLen]
}
return fmt.Sprintf("%s/%s/%s", memberName, hostname, shortID)
}