Skip to content

Commit 8b7a515

Browse files
committed
changeset
1 parent 39418a7 commit 8b7a515

File tree

4 files changed

+2
-73
lines changed

4 files changed

+2
-73
lines changed

framework/.changeset/v0.5.3.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Add logs upload from GHA to local Loki

framework/cmd/logs.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ import (
2020

2121
var L = framework.L
2222

23-
// LokiPushRequest represents the payload format expected by Loki's push API.
2423
type LokiPushRequest struct {
2524
Streams []LokiStream `json:"streams"`
2625
}
2726

28-
// LokiStream represents one log stream.
2927
type LokiStream struct {
3028
Stream map[string]string `json:"stream"`
3129
Values [][2]string `json:"values"`
@@ -37,8 +35,6 @@ const (
3735
grafanaURL2 = "%5C%22%7D%22,%22queryType%22:%22range%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22P8E80F9AEF21F6940%22%7D,%22editorMode%22:%22code%22%7D%5D,%22range%22:%7B%22from%22:%22now-6h%22,%22to%22:%22now%22%7D%7D%7D&schemaVersion=1&orgId=1"
3836
)
3937

40-
// processAndUploadDir traverses the given directory recursively and
41-
// processes every file (ignoring directories) by calling processAndUploadLog.
4238
func processAndUploadDir(dirPath string, limiter ratelimit.Limiter, chunks int, jobID string) error {
4339
return filepath.Walk(dirPath, func(path string, info os.FileInfo, err error) error {
4440
if err != nil {
@@ -61,8 +57,6 @@ func processAndUploadDir(dirPath string, limiter ratelimit.Limiter, chunks int,
6157
})
6258
}
6359

64-
// processAndUploadLog reads log lines from the provided reader,
65-
// splits them into chunks (if more than 10,000 lines) and uploads each chunk concurrently.
6660
func processAndUploadLog(source string, r io.Reader, limiter ratelimit.Limiter, chunks int, jobID string) error {
6761
scanner := bufio.NewScanner(r)
6862
var values [][2]string
@@ -84,7 +78,7 @@ func processAndUploadLog(source string, r io.Reader, limiter ratelimit.Limiter,
8478
L.Info().Msgf("No log lines found in %s", source)
8579
return nil
8680
}
87-
// Use one chunk if there are 10,000 or fewer lines.
81+
// Some logs may include CL node logs, skip chunking for all that is less
8882
if totalLines <= 10000 {
8983
chunks = 1
9084
}
@@ -110,7 +104,6 @@ func processAndUploadLog(source string, r io.Reader, limiter ratelimit.Limiter,
110104
endLine := end
111105
start = end
112106

113-
// Use the unique jobID as the "job" label.
114107
labels := map[string]string{
115108
"job": jobID,
116109
"chunk": fmt.Sprintf("%d", i+1),

framework/examples/myproject/go.mod

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ require (
4444
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
4545
github.com/armon/go-metrics v0.4.1 // indirect
4646
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
47-
github.com/atotto/clipboard v0.1.4 // indirect
4847
github.com/avast/retry-go v3.0.0+incompatible // indirect
4948
github.com/awalterschulze/gographviz v2.0.3+incompatible // indirect
5049
github.com/aws/aws-sdk-go v1.45.25 // indirect
@@ -62,7 +61,6 @@ require (
6261
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4 // indirect
6362
github.com/aws/aws-sdk-go-v2/service/sts v1.33.0 // indirect
6463
github.com/aws/smithy-go v1.22.1 // indirect
65-
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
6664
github.com/benbjohnson/clock v1.3.5 // indirect
6765
github.com/beorn7/perks v1.0.1 // indirect
6866
github.com/bits-and-blooms/bitset v1.13.0 // indirect
@@ -71,18 +69,9 @@ require (
7169
github.com/bytedance/sonic v1.12.3 // indirect
7270
github.com/bytedance/sonic/loader v0.2.0 // indirect
7371
github.com/c2h5oh/datasize v0.0.0-20220606134207-859f65c6625b // indirect
74-
github.com/catppuccin/go v0.2.0 // indirect
7572
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
7673
github.com/cespare/xxhash v1.1.0 // indirect
7774
github.com/cespare/xxhash/v2 v2.3.0 // indirect
78-
github.com/charmbracelet/bubbles v0.20.0 // indirect
79-
github.com/charmbracelet/bubbletea v1.1.1 // indirect
80-
github.com/charmbracelet/huh v0.6.0 // indirect
81-
github.com/charmbracelet/huh/spinner v0.0.0-20241028115900-20a4d21717a8 // indirect
82-
github.com/charmbracelet/lipgloss v0.13.0 // indirect
83-
github.com/charmbracelet/x/ansi v0.2.3 // indirect
84-
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
85-
github.com/charmbracelet/x/term v0.2.0 // indirect
8675
github.com/cloudwego/base64x v0.1.4 // indirect
8776
github.com/cloudwego/iasm v0.2.0 // indirect
8877
github.com/coder/websocket v1.8.12 // indirect
@@ -93,7 +82,6 @@ require (
9382
github.com/coreos/go-semver v0.3.1 // indirect
9483
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
9584
github.com/cpuguy83/dockercfg v0.3.2 // indirect
96-
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
9785
github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect
9886
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
9987
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
@@ -108,7 +96,6 @@ require (
10896
github.com/dustin/go-humanize v1.0.1 // indirect
10997
github.com/edsrzf/mmap-go v1.1.0 // indirect
11098
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
111-
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
11299
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
113100
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect
114101
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
@@ -184,18 +171,14 @@ require (
184171
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
185172
github.com/kylelemons/godebug v1.1.0 // indirect
186173
github.com/leodido/go-urn v1.4.0 // indirect
187-
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
188174
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
189175
github.com/magiconair/properties v1.8.7 // indirect
190176
github.com/mailru/easyjson v0.7.7 // indirect
191177
github.com/mattn/go-colorable v0.1.13 // indirect
192178
github.com/mattn/go-isatty v0.0.20 // indirect
193-
github.com/mattn/go-localereader v0.0.1 // indirect
194-
github.com/mattn/go-runewidth v0.0.16 // indirect
195179
github.com/miekg/dns v1.1.56 // indirect
196180
github.com/mitchellh/copystructure v1.0.0 // indirect
197181
github.com/mitchellh/go-homedir v1.1.0 // indirect
198-
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
199182
github.com/mitchellh/mapstructure v1.5.0 // indirect
200183
github.com/mitchellh/reflectwalk v1.0.1 // indirect
201184
github.com/mmcloughlin/addchain v0.4.0 // indirect
@@ -210,9 +193,6 @@ require (
210193
github.com/montanaflynn/stats v0.7.1 // indirect
211194
github.com/morikuni/aec v1.0.0 // indirect
212195
github.com/mr-tron/base58 v1.2.0 // indirect
213-
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
214-
github.com/muesli/cancelreader v0.2.2 // indirect
215-
github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a // indirect
216196
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
217197
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
218198
github.com/oklog/ulid v1.3.1 // indirect
@@ -221,7 +201,6 @@ require (
221201
github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e // indirect
222202
github.com/opentracing-contrib/go-stdlib v1.0.0 // indirect
223203
github.com/opentracing/opentracing-go v1.2.0 // indirect
224-
github.com/pelletier/go-toml v1.9.5 // indirect
225204
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
226205
github.com/pierrec/lz4/v4 v4.1.21 // indirect
227206
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
@@ -236,10 +215,8 @@ require (
236215
github.com/prometheus/exporter-toolkit v0.10.1-0.20230714054209-2f4150c63f97 // indirect
237216
github.com/prometheus/procfs v0.15.1 // indirect
238217
github.com/prometheus/prometheus v0.47.2-0.20231010075449-4b9c19fe5510 // indirect
239-
github.com/rivo/uniseg v0.4.7 // indirect
240218
github.com/robfig/cron/v3 v3.0.1 // indirect
241219
github.com/rogpeppe/go-internal v1.13.1 // indirect
242-
github.com/russross/blackfriday/v2 v2.1.0 // indirect
243220
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
244221
github.com/sercand/kuberesolver/v5 v5.1.1 // indirect
245222
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
@@ -264,9 +241,7 @@ require (
264241
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
265242
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
266243
github.com/ugorji/go/codec v1.2.12 // indirect
267-
github.com/urfave/cli/v2 v2.27.5 // indirect
268244
github.com/x448/float16 v0.8.4 // indirect
269-
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
270245
github.com/yusufpapurcu/wmi v1.2.3 // indirect
271246
go.etcd.io/etcd/api/v3 v3.5.14 // indirect
272247
go.etcd.io/etcd/client/pkg/v3 v3.5.14 // indirect

0 commit comments

Comments
 (0)