gcplog

package
v0.0.0-...-332dcef Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package gcplog pulls log entries from GCP Cloud Logging and converts them into the workspace NDJSON envelope defined by ADR 0006.

Index

Constants

View Source
const DefaultSeverity = "DEFAULT"

DefaultSeverity is GCP's severity for entries without an explicit level.

Variables

This section is empty.

Functions

func CombinedFilter

func CombinedFilter(filter string, from, to time.Time) string

CombinedFilter joins the resolved time range with the user supplied filter. The time range is a separate concept from the filter; they are only combined here at query time.

func ConvertEntry

func ConvertEntry(entry Entry) (string, error)

ConvertEntry converts one GCP log entry into one envelope NDJSON line without a trailing newline. The timestamp is normalized to RFC3339 UTC, a missing severity becomes DEFAULT, jsonPayload is kept as is (compacted to a single line), and textPayload becomes {"message": <text>}. Provider metadata such as labels, trace, and resource is intentionally dropped here; it belongs in the ImportRun record, not in the log lines.

Types

type Entry

type Entry struct {
	Timestamp   time.Time       `json:"timestamp"`
	Severity    string          `json:"severity,omitempty"`
	JSONPayload json.RawMessage `json:"jsonPayload,omitempty"`
	TextPayload *string         `json:"textPayload,omitempty"`
}

Entry is one GCP Cloud Logging entry, using the REST JSON field names. At most one of JSONPayload and TextPayload is set. TextPayload is a pointer so a present but empty text payload stays distinguishable from an absent one.

type FetchRequest

type FetchRequest struct {
	Project string
	Filter  string
	From    time.Time
	To      time.Time
	Limit   int
}

FetchRequest describes one pull from GCP Cloud Logging. Filter is the user supplied Cloud Logging filter; the time range is combined with it when querying. Limit caps the number of returned entries.

type FetchResult

type FetchResult struct {
	Truncated bool
}

FetchResult reports facts about one completed fetch.

func Fetch

func Fetch(ctx context.Context, req FetchRequest, writeLine func(string) error) (FetchResult, error)

Fetch pulls matching entries from GCP Cloud Logging using Application Default Credentials and sends each converted NDJSON line to writeLine.

Jump to

Keyboard shortcuts

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