Documentation
¶
Overview ¶
Example ¶
package main import ( "fmt" "time" "github.com/vvakame/gcplogurl" ) func main() { exp := &gcplogurl.Explorer{ ProjectID: "test-project", StorageScope: gcplogurl.StorageScopeProject, Query: `trace="projects/test-project/traces/2f029f622a49837d621cbe6dc5e5d146"`, TimeRange: &gcplogurl.SpecificTimeWithRange{ At: time.Date(2020, 11, 14, 4, 20, 0, 0, time.FixedZone("Asia/Tokyo", 9*60*60)), Range: 2 * time.Hour, }, } logURL := exp.String() fmt.Println(logURL) }
Output: https://console.cloud.google.com/logs/query;query=trace%3D%22projects%2Ftest-project%2Ftraces%2F2f029f622a49837d621cbe6dc5e5d146%22;storageScope=project;timeRange=2020-11-13T19:20:00Z%2F2020-11-13T19:20:00Z--PT2H?project=test-project
Index ¶
Examples ¶
Constants ¶
View Source
const StorageScopeProject = storageScopeProject(0)
StorageScopeProject use scope by project.
Variables ¶
This section is empty.
Functions ¶
func TraceLogURL ¶
TraceLogURL construct Cloud Logging URL about this trace (request).
Example ¶
package main import ( "context" "fmt" "os" "go.opencensus.io/trace" "github.com/vvakame/gcplogurl" ) func main() { _ = os.Setenv("GCP_PROJECT", "test-project") ctx := context.Background() ctx, span := trace.StartSpan(ctx, "test-span") defer span.End() logURL, err := gcplogurl.TraceLogURL(ctx) if err != nil { panic(err) } fmt.Println(logURL) }
Output:
Types ¶
type Explorer ¶
type Explorer struct { BaseURL *url.URL ProjectID string // Query expression for logs. // https://cloud.google.com/logging/docs/view/logging-query-language Query Query // StorageScope for refine scope. StorageScope StorageScope // TimeRange for filter logs. TimeRange TimeRange // SummaryFields for manage summary fields. SummaryFields *SummaryFields }
Explorer is a map of GCP Cloud Logging Log Explorer.
type RecentRange ¶
RecentRange provides "** seconds/minutes/hours/days ago".
type SpecificTimeBetween ¶
SpecificTimeBetween pvovides custom range.
type SpecificTimeWithRange ¶
SpecificTimeWithRange provides jump tp time.
type StorageScope ¶
type StorageScope interface {
// contains filtered or unexported methods
}
StorageScope means scope about logs.
type StorageScopeStorage ¶
type StorageScopeStorage struct {
Src []string
}
StorageScopeStorage use scope by storage.
type SummaryFields ¶
type SummaryFields struct { Fields []string Truncate bool MaxLen int TruncateFrom TruncateFrom }
SummaryFields provides configurations for log's summary fields.
type TimeRange ¶
type TimeRange interface {
// contains filtered or unexported methods
}
TimeRange means when to display the logs.
type TruncateFrom ¶
type TruncateFrom string
TruncateFrom provides option for truncate field name.
const ( // TruncateFromBeginning about field name. TruncateFromBeginning TruncateFrom = "beginning" // TruncateFromEnd about field name. TruncateFromEnd TruncateFrom = "end" )
Click to show internal directories.
Click to hide internal directories.