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

Range-diff rd-82

title
chore(analytics): send content-type to `metric-drain`
description
Patch equal
old #1
55cba32
new #1
55cba32
title
chore: check for resp
description
Patch added
old #0
(none)
new #2
334a6dc
Back to top
1: 55cba32 = 1: 55cba32 chore(analytics): send content-type to `metric-drain`
-: ------- > 2: 334a6dc chore: check for resp

old


                    

new

old:httpmuxer/httpmuxer.go new:httpmuxer/httpmuxer.go
 					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(),
-						ContentType: param.Request.Response.Header.Get("Content-Type"),
+						Namespace: "tuns",
+						UserID:    userId,
+						Host:      param.Request.Host,
+						IpAddress: param.ClientIP,
+						Status:    param.StatusCode,
+						Path:      originalURI,
+						UserAgent: param.Request.UserAgent(),
+						Referer:   param.Request.Referer(),
+					}
+
+					if param.Request.Response != nil {
+						visit.ContentType = param.Request.Response.Header.Get("Content-Type")
 					}
 
 					select {