Documentation
¶
Overview ¶
Example (CreateOperator) ¶
op, err := createOperator(Operator{}) fmt.Printf("test: createOperator({}) -> [%v] [err:%v]\n", translateOperator(op), err) op, err = createOperator(Operator{Name: " ", Value: "static"}) fmt.Printf("test: createOperator(\"static\") -> [%v] [err:%v]\n", translateOperator(op), err) op, err = createOperator(Operator{Name: "static", Value: "value"}) fmt.Printf("test: createOperator(\"static\") -> [%v] [err:%v]\n", translateOperator(op), err) op, err = createOperator(Operator{Name: "", Value: "%TRAFFIC__%"}) fmt.Printf("test: createOperator(\"TRAFFIC__\") -> [%v] [err:%v]\n", translateOperator(op), err) op, err = createOperator(Operator{Name: "", Value: "%REQ("}) fmt.Printf("test: createOperator(\"REQ(static)\") -> [%v] [err:%v]\n", translateOperator(op), err) op, err = createOperator(Operator{Name: "", Value: "%REQ(test"}) fmt.Printf("test: createOperator(\"REQ(static)\") -> [%v] [err:%v]\n", translateOperator(op), err) //op, err = createOperator(Operator{Name: "", Value: "%REQ()%"}) //fmt.Printf("test: createOperator(\"REQ(static)\") -> [%v] [err:%v]\n", translateOperator(op), err) op, err = createOperator(Operator{Name: "", Value: "%REQ(static)%"}) fmt.Printf("test: createOperator(\"REQ(static)\") -> [%v] [err:%v]\n", translateOperator(op), err) op, err = createOperator(Operator{Name: "new-name", Value: "%REQ(static)%"}) fmt.Printf("test: createOperator(\"REQ(static)\") -> [%v] [err:%v]\n", translateOperator(op), err) op, err = createOperator(Operator{Name: "", Value: "%TRAFFIC%"}) fmt.Printf("test: createOperator(\"TRAFFIC\") -> [%v] [err:%v]\n", translateOperator(op), err) op, err = createOperator(Operator{Name: "new-name", Value: "%TRAFFIC%"}) fmt.Printf("test: createOperator(\"TRAFFIC\") -> [%v] [err:%v]\n", translateOperator(op), err)
Output: test: createOperator({}) -> [{<empty> <empty>}] [err:invalid operator: value is empty ] test: createOperator("static") -> [{<empty> <empty>}] [err:invalid operator: name is empty [static]] test: createOperator("static") -> [{static value}] [err:<nil>] test: createOperator("TRAFFIC__") -> [{<empty> <empty>}] [err:invalid operator: value not found or invalid %TRAFFIC__%] test: createOperator("REQ(static)") -> [{<empty> <empty>}] [err:invalid operator: value not found or invalid %REQ(] test: createOperator("REQ(static)") -> [{<empty> <empty>}] [err:invalid operator: value not found or invalid %REQ(test] test: createOperator("REQ(static)") -> [{static %REQ(static)%}] [err:<nil>] test: createOperator("REQ(static)") -> [{new-name %REQ(static)%}] [err:<nil>] test: createOperator("TRAFFIC") -> [{traffic %TRAFFIC%}] [err:<nil>] test: createOperator("TRAFFIC") -> [{new-name %TRAFFIC%}] [err:<nil>]
Index ¶
- Constants
- func FmtTimestamp(t time.Time) string
- func IsDirectOperator(op Operator) bool
- func IsEmpty(s string) bool
- func IsRequestOperator(op Operator) bool
- func IsStringValue(op Operator) bool
- func RequestOperatorHeaderName(op Operator) string
- func WriteJson(items []Operator, data *Entry) string
- func WriteText(items []Operator, data *Entry) string
- type Accessor
- type Entry
- func NewEgressEntry(start time.Time, duration time.Duration, req *http.Request, ...) *Entry
- func NewEmptyEntry() *Entry
- func NewEntry(traffic string, start time.Time, duration time.Duration, req *http.Request, ...) *Entry
- func NewIngressEntry(start time.Time, duration time.Duration, req *http.Request, ...) *Entry
- type Formatter
- type JsonFormatter
- type Operator
- type TextFormatter
Examples ¶
Constants ¶
View Source
const ( EgressTraffic = "egress" IngressTraffic = "ingress" PingTraffic = "ping" PingName = "ping" TimeoutName = "timeout" FailoverName = "failover" ProxyName = "proxy" RetryName = "retry" RetryRateLimitName = "retryRateLimit" RetryRateBurstName = "retryBurst" RateLimitName = "rateLimit" RateBurstName = "burst" ControllerName = "name" )
View Source
const ( OperatorPrefix = "%" RequestReferencePrefix = "%REQ(" RequestIdHeaderName = "X-REQUEST-ID" FromRouteHeaderName = "FROM-ROUTE" UserAgentHeaderName = "USER-AGENT" ForwardedForHeaderName = "X-FORWARDED-FOR" TrafficOperator = "%TRAFFIC%" // ingress, egress, ping StartTimeOperator = "%START_TIME%" // start time DurationOperator = "%DURATION%" // Total duration in milliseconds of the request from the start time to the last byte out. DurationStringOperator = "%DURATION_STR%" // Time package formatted OriginRegionOperator = "%REGION%" // origin region OriginZoneOperator = "%ZONE%" // origin zone OriginSubZoneOperator = "%SUB_ZONE%" // origin sub zone OriginServiceOperator = "%SERVICE%" // origin service OriginInstanceIdOperator = "%INSTANCE_ID%" // origin instance id RouteNameOperator = "%ROUTE_NAME%" TimeoutDurationOperator = "%TIMEOUT_DURATION%" RateLimitOperator = "%RATE_LIMIT%" RateBurstOperator = "%RATE_BURST%" RetryOperator = "%RETRY" RetryRateLimitOperator = "%RETRY_RATE_LIMIT%" RetryRateBurstOperator = "%RETRY_RATE_BURST%" FailoverOperator = "%FAILOVER%" ProxyOperator = "%PROXY%" ResponseStatusCodeOperator = "%STATUS_CODE%" // HTTP status code ResponseBytesReceivedOperator = "%BYTES_RECEIVED%" // bytes received ResponseBytesSentOperator = "%BYTES_SENT%" // bytes sent StatusFlagsOperator = "%STATUS_FLAGS%" // status flags RequestProtocolOperator = "%PROTOCOL%" // HTTP Protocol RequestMethodOperator = "%METHOD%" // HTTP method RequestUrlOperator = "%URL%" RequestPathOperator = "%PATH%" RequestHostOperator = "%HOST%" RequestIdOperator = "%X-REQUEST-ID%" // X-REQUEST-ID request header value RequestFromRouteOperator = "%FROM-ROUTE%" // request from route name RequestUserAgentOperator = "%USER-AGENT%" // user agent request header value RequestAuthorityOperator = "%AUTHORITY%" // authority request header value RequestForwardedForOperator = "%X-FORWARDED-FOR%" // client IP address (X-FORWARDED-FOR request header value) GRPCStatusOperator = "%GRPC_STATUS(X)%" // gRPC status code formatted according to the optional parameter X, which can be CAMEL_STRING, SNAKE_STRING and NUMBER. X-REQUEST-ID request header value GRPCStatusNumberOperator = "%GRPC_STATUS_NUMBER%" // gRPC status code. )
Variables ¶
This section is empty.
Functions ¶
func FmtTimestamp ¶
func IsDirectOperator ¶
func IsRequestOperator ¶
func IsStringValue ¶
Types ¶
type Entry ¶
type Entry struct { Traffic string Start time.Time Duration time.Duration CtrlState map[string]string // Request Url string Path string Host string Protocol string Method string Header http.Header // Response StatusCode int BytesSent int64 BytesReceived int64 StatusFlags string }
Entry - struct for all access logging accessdata
func NewEgressEntry ¶
func NewEgressEntry(start time.Time, duration time.Duration, req *http.Request, resp *http.Response, statusFlags string, controllerState map[string]string) *Entry
NewEgressEntry - create an Entry for egress traffic
func NewEmptyEntry ¶
func NewEmptyEntry() *Entry
func NewIngressEntry ¶
func NewIngressEntry(start time.Time, duration time.Duration, req *http.Request, resp *http.Response, statusFlags string, controllerState map[string]string) *Entry
NewIngressEntry - create an Entry for ingress traffic
func (*Entry) AddRequest ¶
func (*Entry) AddResponse ¶
type JsonFormatter ¶
type JsonFormatter struct{}
type Operator ¶
Operator - configuration of logging entries
func CreateOperators ¶
func InitOperators ¶
type TextFormatter ¶
type TextFormatter struct{}
Click to show internal directories.
Click to hide internal directories.