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

accepted · opened on 2024-11-28T03:02:21Z by erock
Help
checkout latest patchset:
ssh pr.pico.sh print pr-38 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print ps-X | git am -3
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
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 ↕ rd-82
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 ↕ rd-83
1: 55cba32 < -: ------- chore(analytics): send content-type to `metric-drain`
-: ------- > 1:
2: 334a6dc < -: ------- chore: check for resp
ps-83 by erock on 2024-11-28T14:08:25Z
Range Diff ↕ rd-84
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
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
diff --git a/httpmuxer/httpmuxer.go b/httpmuxer/httpmuxer.go
index ef3ece3..37e20cf 100644
--- a/httpmuxer/httpmuxer.go
+++ b/httpmuxer/httpmuxer.go
@@ -129,14 +129,15 @@ func Start(state *utils.State) {
 					slog.Info(logLine, "user", user, "userId", userId)
 
 					visit := &utils.MetricDrainVisit{
-						Namespace: "tuns",
-						UserID:    userId,
-						Host:      param.Request.Host,
-						IpAddress: param.ClientIP,
-						Status:    param.StatusCode,
-						Path:      originalURI,
-						UserAgent: param.Request.UserAgent(),
-						Referer:   param.Request.Referer(),
+						Namespace:   "tuns",
+						UserID:      userId,
+						Host:        param.Request.Host,
+						IpAddress:   param.ClientIP,
+						Status:      param.StatusCode,
+						Path:        originalURI,
+						UserAgent:   param.Request.UserAgent(),
+						Referer:     param.Request.Referer(),
+						ContentType: param.Request.Response.Header.Get("Content-Type"),
 					}
 
 					select {
utils/state.go link
+9 -8
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
diff --git a/utils/state.go b/utils/state.go
index 44ca24f..ec99ef6 100644
--- a/utils/state.go
+++ b/utils/state.go
@@ -218,14 +218,15 @@ type Ports struct {
 
 // MetricDrainVisit represents a visit for the metric drain.
 type MetricDrainVisit struct {
-	Namespace string `json:"namespace"`
-	UserID    string `json:"user_id"`
-	Host      string `json:"host"`
-	Path      string `json:"path"`
-	IpAddress string `json:"ip_address"`
-	UserAgent string `json:"user_agent"`
-	Referer   string `json:"referer"`
-	Status    int    `json:"status"`
+	Namespace   string `json:"namespace"`
+	UserID      string `json:"user_id"`
+	Host        string `json:"host"`
+	Path        string `json:"path"`
+	IpAddress   string `json:"ip_address"`
+	UserAgent   string `json:"user_agent"`
+	Referer     string `json:"referer"`
+	Status      int    `json:"status"`
+	ContentType string `json:"content_type"`
 }
 
 // State handles overall state. It retains mutexed maps for various