Documentation
¶
Index ¶
Constants ¶
const MigrateMutexKeyName = "request-log-migrate-lock"
MigrateMutexKeyName is the key that can be used when locking to perform a migration in redis.
const RequestLogRedisIndexName = "request_log_index_v1"
Variables ¶
var ErrNotFound = errors.New("record not found")
ErrNotFound is returned when a log record is not found that was requested. This isn't necessarily a bad request as the record may have expired due to TTL.
Functions ¶
Types ¶
type Entry ¶
type Entry struct { ID uuid.UUID `json:"id"` CorrelationID string `json:"cid"` Timestamp time.Time `json:"ts"` Duration time.Duration `json:"dur"` Request EntryRequest `json:"req"` Response EntryResponse `json:"res"` }
type EntryRecord ¶
type EntryRecord struct { Type RequestType `json:"type"` RequestId uuid.UUID `json:"request_id"` CorrelationId string `json:"correlation_id,omitempty"` Timestamp time.Time `json:"timestamp"` Duration time.Duration `json:"duration"` ConnectionId uuid.UUID `json:"connection_id,omitempty"` ConnectorType string `json:"connector_type,omitempty"` ConnectorId uuid.UUID `json:"connector_id,omitempty"` ConnectorVersion uint64 `json:"connector_version,omitempty"` Method string `json:"method"` Host string `json:"host"` Scheme string `json:"scheme"` Path string `json:"path"` ResponseStatusCode int `json:"response_status_code,omitempty"` ResponseError string `json:"response_error,omitempty"` RequestHttpVersion string `json:"request_http_version,omitempty"` RequestSizeBytes int64 `json:"request_size_bytes,omitempty"` RequestMimeType string `json:"request_mime_type,omitempty"` ResponseHttpVersion string `json:"response_http_version,omitempty"` ResponseSizeBytes int64 `json:"response_size_bytes,omitempty"` ResponseMimeType string `json:"response_mime_type,omitempty"` }
EntryRecord represents a record of an HTTP request as is stored in the request log in redis. This data is redacted to avoid containing sensitive information like information in headers. For a given record in redis, the full request may be stored as well, which would correspond to the data in the Entry struct.
JSON tagging on this struct is used so the same data structure can be passed directly to endpoint responses. It is not use for internal storage.
func EntryRecordFromRedisFields ¶
func EntryRecordFromRedisFields(vals map[string]string) (*EntryRecord, error)
EntryRecordFromRedisFields creates an EntryRecord from the redis fields. Note that the fields are a string/string map because that is what comes back from the go-redis client for RESP2 protocol.
type EntryRequest ¶
type EntryResponse ¶
type ListRequestBuilder ¶
type ListRequestBuilder interface { ListRequestExecutor Limit(int32) ListRequestBuilder OrderBy(RequestOrderByField, pagination.OrderBy) ListRequestBuilder }
type ListRequestExecutor ¶
type ListRequestExecutor interface { FetchPage(context.Context) pagination.PageResult[EntryRecord] Enumerate(context.Context, func(pagination.PageResult[EntryRecord]) (keepGoing bool, err error)) error }
type LogRetriever ¶
type LogRetriever interface { GetFullLog(ctx context.Context, id uuid.UUID) (*Entry, error) NewListRequestsBuilder() ListRequestBuilder ListRequestsFromCursor(ctx context.Context, cursor string) (ListRequestExecutor, error) }
LogRetriever is an interface for retrieving logs. Used by the API to retrieve logs.
func NewRetrievalService ¶
func NewRetrievalService(r apredis.R, cursorKey config.KeyData) LogRetriever
type Logger ¶
Logger is an interface for logging requests. This is used as a middleware for http.Client.
type RequestInfo ¶
type RequestOrderByField ¶
type RequestOrderByField string
const (
RequestOrderByCreatedAt RequestOrderByField = "created_at"
)
type RequestType ¶
type RequestType string
const ( RequestTypeGlobal RequestType = "global" RequestTypeProxy RequestType = "proxy" RequestTypeOAuth RequestType = "oauth" RequestTypePublic RequestType = "public" )