dashboard / tuns / chore(analytics): send content-type to `metric-drain` #38 rss

accepted · opened on 2024-11-28T03:02:21Z by erock
Help
# add changes to patch request
git format-patch main --stdout | ssh pr.pico.sh pr add 38
# add review to patch request
git format-patch main --stdout | ssh pr.pico.sh pr add --review 38
# remove patchset
ssh pr.pico.sh ps rm ps-x
# checkout all patches
ssh pr.pico.sh pr print 38 | git am -3
# print a diff between the last two patches in a patch request
ssh pr.pico.sh pr diff 38
# accept PR
ssh pr.pico.sh pr accept 38
# close PR
ssh pr.pico.sh pr close 38

Logs

erock created pr with ps-81 on 2024-11-28T03:02:21Z
erock added ps-82 on 2024-11-28T03:36:31Z
erock added ps-83 on 2024-11-28T14:08:25Z
erock added ps-84 on 2024-11-28T14:09:17Z
erock changed status on 2024-12-20T18:22:20Z {"status":"accepted"}

Patchsets

ps-81 by erock on 2024-11-28T03:02:21Z
Range Diff ↕
1: 55cba32 = 1: 55cba32 chore(analytics): send content-type to `metric-drain`
-: ------- > 2: 334a6dc chore: check for resp
ps-82 by erock on 2024-11-28T03:36:31Z
Range Diff ↕
1: 55cba32 < -: ------- chore(analytics): send content-type to `metric-drain`
2: 334a6dc < -: ------- chore: check for resp
-: ------- > 1:
ps-83 by erock on 2024-11-28T14:08:25Z
Range Diff ↕
1: ! 1: ea8a742 chore(analytics): send content-type to `metric-drain`
ps-84 by erock on 2024-11-28T14:09:17Z

chore(analytics): send content-type to `metric-drain`

httpmuxer/httpmuxer.go link
+9 -8
 1diff --git a/httpmuxer/httpmuxer.go b/httpmuxer/httpmuxer.go
 2index ef3ece3..37e20cf 100644
 3--- a/httpmuxer/httpmuxer.go
 4+++ b/httpmuxer/httpmuxer.go
 5@@ -129,14 +129,15 @@ func Start(state *utils.State) {
 6 					slog.Info(logLine, "user", user, "userId", userId)
 7 
 8 					visit := &utils.MetricDrainVisit{
 9-						Namespace: "tuns",
10-						UserID:    userId,
11-						Host:      param.Request.Host,
12-						IpAddress: param.ClientIP,
13-						Status:    param.StatusCode,
14-						Path:      originalURI,
15-						UserAgent: param.Request.UserAgent(),
16-						Referer:   param.Request.Referer(),
17+						Namespace:   "tuns",
18+						UserID:      userId,
19+						Host:        param.Request.Host,
20+						IpAddress:   param.ClientIP,
21+						Status:      param.StatusCode,
22+						Path:        originalURI,
23+						UserAgent:   param.Request.UserAgent(),
24+						Referer:     param.Request.Referer(),
25+						ContentType: param.Request.Response.Header.Get("Content-Type"),
26 					}
27 
28 					select {
utils/state.go link
+9 -8
 1diff --git a/utils/state.go b/utils/state.go
 2index 44ca24f..ec99ef6 100644
 3--- a/utils/state.go
 4+++ b/utils/state.go
 5@@ -218,14 +218,15 @@ type Ports struct {
 6 
 7 // MetricDrainVisit represents a visit for the metric drain.
 8 type MetricDrainVisit struct {
 9-	Namespace string `json:"namespace"`
10-	UserID    string `json:"user_id"`
11-	Host      string `json:"host"`
12-	Path      string `json:"path"`
13-	IpAddress string `json:"ip_address"`
14-	UserAgent string `json:"user_agent"`
15-	Referer   string `json:"referer"`
16-	Status    int    `json:"status"`
17+	Namespace   string `json:"namespace"`
18+	UserID      string `json:"user_id"`
19+	Host        string `json:"host"`
20+	Path        string `json:"path"`
21+	IpAddress   string `json:"ip_address"`
22+	UserAgent   string `json:"user_agent"`
23+	Referer     string `json:"referer"`
24+	Status      int    `json:"status"`
25+	ContentType string `json:"content_type"`
26 }
27 
28 // State handles overall state. It retains mutexed maps for various