Skip to content

Commit db29a12

Browse files
feat: add http server url to clickhouse datamodel (#783)
Adds HTTP Server URL to clickhouse data model Usefully clickhouse driver is always fine convering null to empty string
1 parent ba9a2ec commit db29a12

File tree

7 files changed

+19
-6
lines changed

7 files changed

+19
-6
lines changed

.changeset/short-garlics-report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"server": patch
3+
---
4+
5+
adds http server url to clickhouse data model
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE `http_requests_raw` ADD COLUMN `http_server_url` String;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
h1:zOIbDWIKI94ZMQwpkDfQ+x5unOadKEgjdzOa9V0NkW0=
1+
h1:Xh9KFkOz16djkOb1Ti2SSPwUYKlPgirqntCaTEOZU4o=
22
20251013090028_initial.sql h1:I90GAjfJN/3i4nLe4AThT5OW/Qgc0+5LOI2jZ6WQZME=
33
20251028141444_add_indexes.sql h1:CDwn2EdBZ7Nrn9hx5vYguR1ljlP5hTxiOI6n/I25Cpk=
44
20251029120230_add_other_indexes.sql h1:3EtD+3hW8+s5me23va+BdfiIKmfQKOdv4glrQ34fle4=
55
20251106194508_set-default-ttl-30-days.sql h1:veC6yHSEfqhXJBVWCIXuOldWcQfd611qPW7ozjzg8Ww=
66
20251106194847_set-deployment-id-to-nullable.sql h1:yF1S8dZEsWgN3/D00mlV9f3NAqpV2C2ugGvkrEbAlrE=
7+
20251106210549_add-server-urls.sql h1:FHg+DVjSxnYDnnF5KskfioZ7+y8Jeh2u3a9TSbl/zvw=

server/clickhouse/schema.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ create table if not exists http_requests_raw
1313
span_id FixedString(16),
1414

1515
http_method LowCardinality(String),
16+
http_server_url String,
1617
http_route String,
1718
status_code Int64,
1819
duration_ms Float64,

server/internal/logs/listLogs_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ func TestListLogs_TimeRangeFilter(t *testing.T) {
206206
SpanID: id.String()[:16],
207207
HTTPMethod: "GET",
208208
HTTPRoute: "/test",
209+
HTTPServerURL: "",
209210
StatusCode: 200,
210211
DurationMs: 100.0,
211212
UserAgent: "test-agent",
@@ -336,6 +337,7 @@ func TestListLogs_VerifyLogFields(t *testing.T) {
336337
SpanID: spanID,
337338
HTTPMethod: "POST",
338339
HTTPRoute: "/api/users",
340+
HTTPServerURL: "",
339341
StatusCode: 201,
340342
DurationMs: 250.5,
341343
UserAgent: "Mozilla/5.0",
@@ -419,6 +421,7 @@ func insertTestLogs(t *testing.T, ctx context.Context, ti *testInstance, project
419421
SpanID: id.String()[:16],
420422
HTTPMethod: "GET",
421423
HTTPRoute: "/test",
424+
HTTPServerURL: "",
422425
StatusCode: 200,
423426
DurationMs: 100.0,
424427
UserAgent: "test-agent",

server/internal/thirdparty/toolmetrics/logging.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ func newToolLog(ctx context.Context, tool ToolInfo, toolType ToolType) (*ToolHTT
216216
StatusCode: 0,
217217
DurationMs: 0,
218218
UserAgent: "",
219+
HTTPServerURL: "",
219220
HTTPMethod: "",
220221
HTTPRoute: "",
221222
RequestHeaders: map[string]string{},

server/internal/thirdparty/toolmetrics/models.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,12 @@ type ToolHTTPRequest struct {
5353
SpanID string `ch:"span_id"` // FixedString(16)
5454

5555
// request metadata
56-
HTTPMethod string `ch:"http_method"` // LowCardinality(String)
57-
HTTPRoute string `ch:"http_route"` // String
58-
StatusCode int64 `ch:"status_code"` // Int64
59-
DurationMs float64 `ch:"duration_ms"` // Float64
60-
UserAgent string `ch:"user_agent"` // LowCardinality(String)
56+
HTTPMethod string `ch:"http_method"` // LowCardinality(String)
57+
HTTPServerURL string `ch:"http_server_url"` // String
58+
HTTPRoute string `ch:"http_route"` // String
59+
StatusCode int64 `ch:"status_code"` // Int64
60+
DurationMs float64 `ch:"duration_ms"` // Float64
61+
UserAgent string `ch:"user_agent"` // LowCardinality(String)
6162

6263
// request payload
6364
RequestHeaders map[string]string `ch:"request_headers"` // Map(String, String)

0 commit comments

Comments
 (0)