Skip to content

Commit b19ba94

Browse files
committed
upgrade Go to 1.25.0, upgrade logstorage to v1.33.1, upgrade metrics SDK to v1.40.1, update compiler to glibc-based.
Signed-off-by: Jiekun <[email protected]>
1 parent 57bc8e7 commit b19ba94

File tree

157 files changed

+6554
-2082
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+6554
-2082
lines changed

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ endif
1414
GO_BUILDINFO = -X 'github.com/VictoriaMetrics/VictoriaMetrics/lib/buildinfo.Version=$(APP_NAME)-$(DATEINFO_TAG)-$(BUILDINFO_TAG)'
1515
TAR_OWNERSHIP ?= --owner=1000 --group=1000
1616

17-
GOLANGCI_LINT_VERSION := 2.2.1
17+
GOLANGCI_LINT_VERSION := 2.4.0
1818

1919
.PHONY: $(MAKECMDGOALS)
2020

@@ -155,8 +155,12 @@ test-full:
155155
test-full-386:
156156
GOEXPERIMENT=synctest GOARCH=386 go test -coverprofile=coverage.txt -covermode=atomic ./lib/... ./app/...
157157

158-
integration-test: victoria-traces
159-
go test ./apptest/... -skip="^TestCluster.*"
158+
integration-test:
159+
$(MAKE) apptest
160+
161+
apptest:
162+
$(MAKE) victoria-traces
163+
go test ./apptest/...
160164

161165
benchmark:
162166
GOEXPERIMENT=synctest go test -bench=. ./lib/...
@@ -169,7 +173,7 @@ benchmark-pure:
169173
vendor-update:
170174
go get -u ./lib/...
171175
go get -u ./app/...
172-
go mod tidy -compat=1.24
176+
go mod tidy -compat=1.25
173177
go mod vendor
174178

175179
app-local:

app/victoria-traces/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
8080
}
8181
w.Header().Add("Content-Type", "text/html; charset=utf-8")
8282
fmt.Fprintf(w, "<h2>Single-node VictoriaTraces</h2></br>")
83+
fmt.Fprintf(w, "Version %s<br>", buildinfo.Version)
8384
fmt.Fprintf(w, "See docs at <a href='https://docs.victoriametrics.com/victoriatraces/'>https://docs.victoriametrics.com/victoriatraces/</a></br>")
8485
fmt.Fprintf(w, "Useful endpoints:</br>")
8586
httpserver.WriteAPIHelp(w, [][2]string{

app/vmui/Dockerfile-web

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.24.6 AS build-web-stage
1+
FROM golang:1.25.0 AS build-web-stage
22
COPY build /build
33

44
WORKDIR /build

app/vtinsert/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
var (
1616
disableInsert = flag.Bool("insert.disable", false, "Whether to disable /insert/* HTTP endpoints")
17-
disableInternal = flag.Bool("internalinsert.disable", false, "Whether to disable /internal/insert HTTP endpoint")
17+
disableInternal = flag.Bool("internalinsert.disable", false, "Whether to disable /internal/insert HTTP endpoint. See https://docs.victoriametrics.com/victoriatraces/cluster/#security")
1818
)
1919

2020
// Init initializes vtinsert

app/vtselect/internalselect/internalselect.go

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ func processQueryRequest(ctx context.Context, w http.ResponseWriter, r *http.Req
100100

101101
bb := bufs.Get(workerID)
102102

103+
// Write the marker of a regular data block.
104+
bb.B = append(bb.B, 0)
105+
106+
// Marshal the data block.
103107
bb.B = db.Marshal(bb.B)
104108

105109
if len(bb.B) < 1024*1024 {
@@ -117,7 +121,10 @@ func processQueryRequest(ctx context.Context, w http.ResponseWriter, r *http.Req
117121
}
118122
}
119123

120-
if err := vtstorage.RunQuery(ctx, cp.TenantIDs, cp.Query, writeBlock); err != nil {
124+
qctx := cp.NewQueryContext(ctx)
125+
defer cp.UpdatePerQueryStatsMetrics()
126+
127+
if err := vtstorage.RunQuery(qctx, writeBlock); err != nil {
121128
return err
122129
}
123130
if errGlobal != nil {
@@ -131,7 +138,13 @@ func processQueryRequest(ctx context.Context, w http.ResponseWriter, r *http.Req
131138
}
132139
}
133140

134-
return nil
141+
// Send the query stats block.
142+
bb := bufs.Get(0)
143+
// Write the marker of query stats block.
144+
bb.B = append(bb.B, 1)
145+
// Marshal the block itself
146+
bb.B = marshalQueryStatsBlock(bb.B, qctx)
147+
return sendBuf(bb)
135148
}
136149

137150
func processFieldNamesRequest(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
@@ -140,12 +153,15 @@ func processFieldNamesRequest(ctx context.Context, w http.ResponseWriter, r *htt
140153
return err
141154
}
142155

143-
fieldNames, err := vtstorage.GetFieldNames(ctx, cp.TenantIDs, cp.Query)
156+
qctx := cp.NewQueryContext(ctx)
157+
defer cp.UpdatePerQueryStatsMetrics()
158+
159+
fieldNames, err := vtstorage.GetFieldNames(qctx)
144160
if err != nil {
145161
return fmt.Errorf("cannot obtain field names: %w", err)
146162
}
147163

148-
return writeValuesWithHits(w, fieldNames, cp.DisableCompression)
164+
return writeValuesWithHits(w, qctx, fieldNames, cp.DisableCompression)
149165
}
150166

151167
func processFieldValuesRequest(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
@@ -161,12 +177,15 @@ func processFieldValuesRequest(ctx context.Context, w http.ResponseWriter, r *ht
161177
return err
162178
}
163179

164-
fieldValues, err := vtstorage.GetFieldValues(ctx, cp.TenantIDs, cp.Query, fieldName, uint64(limit))
180+
qctx := cp.NewQueryContext(ctx)
181+
defer cp.UpdatePerQueryStatsMetrics()
182+
183+
fieldValues, err := vtstorage.GetFieldValues(qctx, fieldName, uint64(limit))
165184
if err != nil {
166185
return fmt.Errorf("cannot obtain field values: %w", err)
167186
}
168187

169-
return writeValuesWithHits(w, fieldValues, cp.DisableCompression)
188+
return writeValuesWithHits(w, qctx, fieldValues, cp.DisableCompression)
170189
}
171190

172191
func processStreamFieldNamesRequest(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
@@ -175,12 +194,15 @@ func processStreamFieldNamesRequest(ctx context.Context, w http.ResponseWriter,
175194
return err
176195
}
177196

178-
fieldNames, err := vtstorage.GetStreamFieldNames(ctx, cp.TenantIDs, cp.Query)
197+
qctx := cp.NewQueryContext(ctx)
198+
defer cp.UpdatePerQueryStatsMetrics()
199+
200+
fieldNames, err := vtstorage.GetStreamFieldNames(qctx)
179201
if err != nil {
180202
return fmt.Errorf("cannot obtain stream field names: %w", err)
181203
}
182204

183-
return writeValuesWithHits(w, fieldNames, cp.DisableCompression)
205+
return writeValuesWithHits(w, qctx, fieldNames, cp.DisableCompression)
184206
}
185207

186208
func processStreamFieldValuesRequest(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
@@ -196,12 +218,15 @@ func processStreamFieldValuesRequest(ctx context.Context, w http.ResponseWriter,
196218
return err
197219
}
198220

199-
fieldValues, err := vtstorage.GetStreamFieldValues(ctx, cp.TenantIDs, cp.Query, fieldName, uint64(limit))
221+
qctx := cp.NewQueryContext(ctx)
222+
defer cp.UpdatePerQueryStatsMetrics()
223+
224+
fieldValues, err := vtstorage.GetStreamFieldValues(qctx, fieldName, uint64(limit))
200225
if err != nil {
201226
return fmt.Errorf("cannot obtain stream field values: %w", err)
202227
}
203228

204-
return writeValuesWithHits(w, fieldValues, cp.DisableCompression)
229+
return writeValuesWithHits(w, qctx, fieldValues, cp.DisableCompression)
205230
}
206231

207232
func processStreamsRequest(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
@@ -215,12 +240,15 @@ func processStreamsRequest(ctx context.Context, w http.ResponseWriter, r *http.R
215240
return err
216241
}
217242

218-
streams, err := vtstorage.GetStreams(ctx, cp.TenantIDs, cp.Query, uint64(limit))
243+
qctx := cp.NewQueryContext(ctx)
244+
defer cp.UpdatePerQueryStatsMetrics()
245+
246+
streams, err := vtstorage.GetStreams(qctx, uint64(limit))
219247
if err != nil {
220248
return fmt.Errorf("cannot obtain streams: %w", err)
221249
}
222250

223-
return writeValuesWithHits(w, streams, cp.DisableCompression)
251+
return writeValuesWithHits(w, qctx, streams, cp.DisableCompression)
224252
}
225253

226254
func processStreamIDsRequest(ctx context.Context, w http.ResponseWriter, r *http.Request) error {
@@ -234,19 +262,33 @@ func processStreamIDsRequest(ctx context.Context, w http.ResponseWriter, r *http
234262
return err
235263
}
236264

237-
streamIDs, err := vtstorage.GetStreamIDs(ctx, cp.TenantIDs, cp.Query, uint64(limit))
265+
qctx := cp.NewQueryContext(ctx)
266+
defer cp.UpdatePerQueryStatsMetrics()
267+
268+
streamIDs, err := vtstorage.GetStreamIDs(qctx, uint64(limit))
238269
if err != nil {
239270
return fmt.Errorf("cannot obtain streams: %w", err)
240271
}
241272

242-
return writeValuesWithHits(w, streamIDs, cp.DisableCompression)
273+
return writeValuesWithHits(w, qctx, streamIDs, cp.DisableCompression)
243274
}
244275

245276
type commonParams struct {
246277
TenantIDs []logstorage.TenantID
247278
Query *logstorage.Query
248279

249280
DisableCompression bool
281+
282+
// qs contains execution statistics for the Query.
283+
qs logstorage.QueryStats
284+
}
285+
286+
func (cp *commonParams) NewQueryContext(ctx context.Context) *logstorage.QueryContext {
287+
return logstorage.NewQueryContext(ctx, &cp.qs, cp.TenantIDs, cp.Query)
288+
}
289+
290+
func (cp *commonParams) UpdatePerQueryStatsMetrics() {
291+
vtstorage.UpdatePerQueryStatsMetrics(&cp.qs)
250292
}
251293

252294
func getCommonParams(r *http.Request, expectedProtocolVersion string) (*commonParams, error) {
@@ -287,12 +329,18 @@ func getCommonParams(r *http.Request, expectedProtocolVersion string) (*commonPa
287329
return cp, nil
288330
}
289331

290-
func writeValuesWithHits(w http.ResponseWriter, vhs []logstorage.ValueWithHits, disableCompression bool) error {
332+
func writeValuesWithHits(w http.ResponseWriter, qctx *logstorage.QueryContext, vhs []logstorage.ValueWithHits, disableCompression bool) error {
291333
var b []byte
334+
335+
// Marshal vhs at first
336+
b = encoding.MarshalUint64(b, uint64(len(vhs)))
292337
for i := range vhs {
293338
b = vhs[i].Marshal(b)
294339
}
295340

341+
// Marshal query stats block after that
342+
b = marshalQueryStatsBlock(b, qctx)
343+
296344
if !disableCompression {
297345
b = zstd.CompressLevel(nil, b, 1)
298346
}
@@ -306,6 +354,13 @@ func writeValuesWithHits(w http.ResponseWriter, vhs []logstorage.ValueWithHits,
306354
return nil
307355
}
308356

357+
func marshalQueryStatsBlock(dst []byte, qctx *logstorage.QueryContext) []byte {
358+
queryDurationNsecs := qctx.QueryDurationNsecs()
359+
db := qctx.QueryStats.CreateDataBlock(queryDurationNsecs)
360+
dst = db.Marshal(dst)
361+
return dst
362+
}
363+
309364
func getInt64FromRequest(r *http.Request, argName string) (int64, error) {
310365
s := r.FormValue(argName)
311366
n, err := strconv.ParseInt(s, 10, 64)

0 commit comments

Comments
 (0)