consts

package
v0.1.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderAMTraceID          = "am-trace-id"
	HeaderXCloudTraceContext = "x-cloud-trace-context"
	HeaderEnableDebugLogging = "Enable-Debug-Log"

	KeyAMTraceID          = "am_trace_id"
	KeyCloudflareRay      = "cloudflare_ray"
	KeyEnableDebugLogging = "enable_debug_log"

	OtelDefaultTracerName = "default"

	DefaultAccessLogPattern = `%{2021-11-07T15:04:05.999-0700}t "%{CF-Ray}i" "${AM-Trace-ID}" ` +
		`%a %A %{Host}i "%r" %s - %T "%{X-Real-IP}i" "%{X-Forwarded-For}i" ` +
		`%{Content-Length}i - %{Content-Length}o %b`
	JSONAccessLogPattern = `{"message": "AccessLogger %r %s [${AM-Trace-ID}]",` +
		`"@timestamp":"%{2006-01-02T15:04:05.999-0700}t",` +
		`"category":"http_access_log",` +
		`"context_cloudflare_ray":"%{CF-Ray}i",` +
		`"context_trace_id":"${AM-Trace-ID}",` +
		`"remote_addr":"%a",` +
		`"server_addr":"%A",` +
		`"host":"%{Host}i",` +
		`"request":"%r",` +
		`"status":"%s",` +
		`"first_byte_commit_time":"%F ms",` +
		`"request_time":%D,` +
		`"http_x_real_ip":"%{X-Real-IP}i",` +
		`"http_x_forwarded_for":"%{X-Forwarded-For}i",` +
		`"content_length":"${Content-Length}",` +
		`"body_bytes_sent":"%B bytes"}`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextKey

type ContextKey string

The reason is that using a built-in type as a key can potentially cause collisions if another package decides to use the same type and value as a key. To avoid this, you can define your own type and use that as the key instead.

const (
	ContextKeyTraceID            ContextKey = "traceID"
	ContextKeyCloudflareRay      ContextKey = "cloudflareRay"
	ContextKeyRequestPath        ContextKey = "requestPath"
	ContextKeyEnableDebugLogging ContextKey = "enableDebugLog"
	ContextKeyMetricLabel        ContextKey = "metricLabel"
	ContextStartTimeKey          ContextKey = "startTime"
	ContextSegmentKey            ContextKey = "segment"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL