summaryrefslogtreecommitdiffhomepage
path: root/tsweb
AgeCommit message (Collapse)AuthorFilesLines
2025-10-10tsweb/varz: add support for ShardedInt metricsAnton Tolchanov2-0/+19
Fixes tailscale/corp#33236 Signed-off-by: Anton Tolchanov <anton@tailscale.com>
2025-06-16scripts/check_license_headers.sh: delete, rewrite as a Go testBrad Fitzpatrick1-0/+1
Updates tailscale/corp#29650 Change-Id: Iad4e4ccd9d68ebb1d1a12f335cc5295d0bd05b60 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-06-12tsweb/varz: add binary name to version metricBrad Fitzpatrick1-1/+19
Fixes tailscale/corp#29530 Change-Id: Iae04456d7ac5527897f060370e90c9517c00a818 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-04-28tsweb/varz: export GC CPU fraction gaugeJames Tucker2-14/+124
We were missing this metric, but it can be important for some workloads. Varz memstats output allocation cost reduced from 30 allocs per invocation to 1 alloc per invocation. Updates tailscale/corp#28033 Signed-off-by: James Tucker <james@tailscale.com> Co-authored-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-04-16tsd: wire up the event bus to tailscaledDavid Anderson2-1/+3
Updates #15160 Signed-off-by: David Anderson <dave@tailscale.com>
2025-04-16tsweb: don't hook up pprof handlers in javascript buildsDavid Anderson4-12/+33
Updates #15160 Signed-off-by: David Anderson <dave@tailscale.com>
2025-03-18tsweb: split promvarz into an optional dependencyDavid Anderson3-5/+23
Allows the use of tsweb without pulling in all of the heavy prometheus client libraries, protobuf and so on. Updates #15160 Signed-off-by: David Anderson <dave@tailscale.com>
2025-03-12tsweb: add title to DebugHandler and helper registration methodsWill Norris1-5/+26
Allow customizing the title on the debug index page. Also add methods for registering http.HandlerFunc to make it a little easier on callers. Updates tailscale/corp#27058 Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d Signed-off-by: Will Norris <will@tailscale.com>
2025-01-22tsweb: add missing debug pprof endpointsBrad Fitzpatrick1-7/+7
Updates tailscale/corp#26016 Change-Id: I47a5671e881cc092d83c1e992e2271f90afcae7e Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-11-20tsweb: change RequestID format to have a date in itBrad Fitzpatrick2-5/+30
So we can locate them in logs more easily. Updates tailscale/corp#24721 Change-Id: Ia766c75608050dde7edc99835979a6e9bb328df2 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-11-07tsweb/varz: optimize some allocs, add helper func for othersBrad Fitzpatrick1-2/+8
Updates #cleanup Updates tailscale/corp#23546 (noticed when doing this) Change-Id: Ia9f627fe32bb4955739b2787210ba18f5de27f4d Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-08-27usermetric: add initial user-facing metricsKristoffer Dalby1-12/+21
This commit adds a new usermetric package and wires up metrics across the tailscale client. Updates tailscale/corp#22075 Co-authored-by: Anton Tolchanov <anton@tailscale.com> Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
2024-08-27tsweb/varz: remove pprofKristoffer Dalby1-1/+0
Updates tailscale/corp#22075 Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
2024-08-12tsweb: fix TestStdHandler_ConnectionClosedDuringBody flake (#13046)Paul Scott1-11/+12
Fixes #13017 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-08-03tsweb: mark TestStdHandler_ConnectionClosedDuringBody flakyMaisem Ali1-0/+2
Updates #13107 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2024-07-29tsweb: add QuietLogging option (#12838)Paul Scott2-1/+61
Allows the use of tsweb.LogHandler exclusively for callbacks describing the handler HTTP requests. Fixes #12837 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-07-25tsweb: Add MiddlewareStack func to apply lists of Middleware (#12907)Paul Scott2-0/+66
Fixes #12909 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-07-24tsweb: log all cancellations as 499s (#12894)Paul Scott2-29/+250
Updates #12141 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-07-19tsweb: log cancelled requests as 499Paul Scott2-16/+105
Fixes #12860 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-07-18tsweb: swallow panicsPaul Scott2-104/+231
With this change, the error handling and request logging are all done in defers after calling inner.ServeHTTP. This ensures that any recovered values which we want to re-panic with retain a useful stacktrace. However, we now only re-panic from errorHandler when there's no outside logHandler. Which if you're using StdHandler there always is. We prefer this to ensure that we are able to write a 500 Internal Server Error to the client. If a panic hits http.Server then the response is not sent back. Updates #12784 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-07-16tsweb: log once per requestPaul Scott2-157/+422
StdHandler/retHandler would previously emit one log line for each request. If there were multiple StdHandler in the chain, there would be one log line per instance of retHandler. With this change, only the outermost StdHandler/logHandler actually logs the request or invokes OnStart or OnCompletion callbacks. The error-rendering part of retHandler lives on in errorHandler, and errorHandler passes those errors up the stack to logHandler through a callback that logHandler places in the request.Context(). Updates tailscale/corp#19999 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-07-15tsweb: fix TestStdHandler_panic flakePaul Scott1-9/+3
Fixes #12816 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-07-15tsweb: add stack trace to panic error msgPaul Scott2-4/+96
Updates #12784 Signed-off-by: Paul Scott <paul@tailscale.com>
2024-06-26tsweb: accept a function to call before request handlingAnton Tolchanov2-3/+28
To complement the existing `onCompletion` callback, which is called after request handler. Updates tailscale/corp#17075 Signed-off-by: Anton Tolchanov <anton@tailscale.com>
2024-06-14derp/xdp,cmd/xdpderper: initial skeleton (#12390)Jordan Whited1-1/+1
This commit introduces a userspace program for managing an experimental eBPF XDP STUN server program. derp/xdp contains the eBPF pseudo-C along with a Go pkg for loading it and exporting its metrics. cmd/xdpderper is a package main user of derp/xdp. Updates tailscale/corp#20689 Signed-off-by: Jordan Whited <jordan@tailscale.com>
2024-06-06tsweb: add optional on completion callback funcKristoffer Dalby1-0/+12
Updates corp#17075 Co-Authored-By: Anton Tolchanov <anton@tailscale.com> Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
2024-05-31tsweb: rename AccessLogRecord's When to TimeMarwan Sulaiman3-26/+26
This change makes our access log record more consistent with the new log/tslog package formatting of "time". Note that we can change slog itself to call "time" "when" but we're chosing to make this breaking change to be consistent with the std lib's defaults. Updates tailscale/corp#17071 Signed-off-by: Marwan Sulaiman <marwan@tailscale.com>
2024-05-05tsweb: remove redundant bumpStartIfNeeded funcWill Norris1-7/+8
Updates #12001 Signed-off-by: Will Norris <will@tailscale.com>
2024-05-03tsweb: ensure in-flight requests are always marked as finishedWill Norris1-2/+5
The inflight request tracker only starts recording a new bucket after the first non-error request. Unfortunately, it's written in such a way that ONLY successful requests are ever marked as being finished. Once a bucket has had at least one successful request and begun to be tracked, all subsequent error cases are never marked finished and always appear as in-flight. This change ensures that if a request is recorded has having been started, we also mark it as finished at the end. Updates tailscale/corp#19767 Signed-off-by: Will Norris <will@tailscale.com>
2024-04-16all: use Go 1.22 range-over-intBrad Fitzpatrick1-2/+2
Updates #11058 Change-Id: I35e7ef9b90e83cac04ca93fd964ad00ed5b48430 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-04-09tsweb: switch to fastuuid for request ID generationJames Tucker1-2/+2
Request ID generation appears prominently in some services cumulative allocation rate, and while this does not eradicate this issue (the API still makes UUID objects), it does improve the overhead of this API and reduce the amount of garbage that it produces. Updates tailscale/corp#18266 Updates tailscale/corp#19054 Signed-off-by: James Tucker <james@tailscale.com>
2024-04-05tsweb: handle panics in retHandlerMaisem Ali1-1/+26
We would have incomplete stats and missing logs in cases of panics. Updates tailscale/corp#18687 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2024-04-02tsweb: update doc on BucketedStatsOptions.Finish to match behaviorJames Tucker1-1/+2
I originally came to update this to match the documented behavior, but the code is deliberately avoiding this behavior currently, making it hard to decide how to update this. For now just align the documentation to the behavior. Updates #cleanup Signed-off-by: James Tucker <james@tailscale.com>
2024-03-28tsweb: make BucketedStats not track 400s, 404s, etcBrad Fitzpatrick1-2/+20
Updates tailscale/corp#18687 Change-Id: I142ccb1301ec4201c70350799ff03222bce96668 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-03-27tsweb/varz: add charset=utf-8 to varz handlerBrad Fitzpatrick1-1/+1
Some of our labels contain UTF-8 and get mojibaked in the browser right now. Updates tailscale/corp#18687 Change-Id: I6069cffd6cc8813df415f06bb308bc2fc3ab65c4 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-03-26metrics, tsweb/varz: add multi-label map metricsBrad Fitzpatrick2-0/+28
Updates tailscale/corp#18640 Change-Id: Ia9ae25956038e9d3266ea165537ac6f02485b74c Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-03-24tsweb/varz: flesh out munging of expvar keys into valid Prometheus metricsBrad Fitzpatrick2-1/+42
From a problem we hit with how badger registers expvars; it broke trunkd's exported metrics. Updates tailscale/corp#1297 Change-Id: I42e1552e25f734c6f521b6e993d57a82849464b2 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-03-06tsweb: add String method to tsweb.RequestIDAndrew Dunham1-0/+6
In case we want to change the format to something opaque later. Updates tailscale/corp#2549 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: Ie2eac8b885b694be607e9d5101d24b650026d89c
2024-03-04tsweb: add more test cases for TestCleanRedirectURL (#11331)Chris Palmer1-1/+9
Updates #cleanup Signed-off-by: Chris Palmer <cpalmer@tailscale.com>
2024-02-28tsweb: allow empty redirect URL in CleanRedirectURL (#11295)Andrew Lytvynov2-28/+36
Updates #cleanup Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
2024-02-27tsweb: expose function to generate request IDsAndrew Dunham1-7/+14
For use in corp. Updates tailscale/corp#2549 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: I71debae1ce9ae48cf69cc44c2ab5c443fc3b2005
2024-02-13Revert "tsweb: update ServeMux matching to 1.22.0 syntax (#11090)" (#11125)Patrick O'Doherty1-8/+8
This reverts commit 30c9189ed307df6f2c1567aa7945bde77bb54c52. Signed-off-by: Patrick O'Doherty <patrick@tailscale.com>
2024-02-13tsweb: update ServeMux matching to 1.22.0 syntax (#11090)Patrick O'Doherty1-8/+8
* tsweb: update ServeMux matching to 1.22.0 syntax Updates #cleanup Go 1.22.0 introduced the ability to use more expressive routing patterns that include HTTP method when constructing ServeMux entries. Applications that attempted to use these patterns in combination with the old `tsweb.Debugger` would experience a panic as Go would not permit the use of matching rules with mixed level of specificity. We now specify the method for each `/debug` handler to prevent incompatibilities. Signed-off-by: Patrick O'Doherty <patrick@tailscale.com>
2024-02-09Revert "tsweb: update ServeMux matching to 1.22.0 syntax (#11087)" (#11089)Patrick O'Doherty1-1/+1
This reverts commit 291f91d164f1ec60ca77c0cb935a7895ac4cc555. Updates #cleanup This PR needs additional changes to the registration of child handlers under /debug Signed-off-by: Patrick O'Doherty <patrick@tailscale.com>
2024-02-09tsweb: update ServeMux matching to 1.22.0 syntax (#11087)Patrick O'Doherty1-1/+1
Updates #cleanup Go 1.22.0 introduced the ability to use more expressive routing patterns that include HTTP method when constructing ServeMux entries. Applications that attempted to use these patterns in combination with the old `tsweb.Debugger` would experience a panic as Go would not permit the use of matching rules with mixed level of specificity. Signed-off-by: Patrick O'Doherty <patrick@tailscale.com>
2024-02-07util/cmpx: delete now that we're using Go 1.22Brad Fitzpatrick2-6/+6
Updates #11058 Change-Id: I09dea8e86f03ec148b715efca339eab8b1f0f644 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-02-07tsweb: normalize passkey identities in bucketed statsTom DNetto2-3/+5
Signed-off-by: Tom DNetto <tom@tailscale.com> Updates: corp#17075
2024-02-07tsweb: normalize common StableID's in bucketed stats, export as LabelMapTom DNetto2-3/+7
Signed-off-by: Tom DNetto <tom@tailscale.com> Updates: corp#17075
2024-02-07tsweb: replace domains/emails in paths when bucketing statsTom DNetto2-8/+17
Signed-off-by: Tom DNetto <tom@tailscale.com> Updates: corp#17075
2024-02-06tsweb: implementing bucketed statistics for started/finished countsTom DNetto2-0/+91
Signed-off-by: Tom DNetto <tom@tailscale.com> Updates: corp#17075