Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
df7cdc3f
Commit
df7cdc3f
authored
May 09, 2018
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
telemetry: Add memory and goroutine metrics, rename container
And fix a typo in a comment, sigh
parent
86fd2f22
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
caddy/caddymain/run.go
caddy/caddymain/run.go
+3
-3
telemetry/telemetry.go
telemetry/telemetry.go
+15
-0
No files found.
caddy/caddymain/run.go
View file @
df7cdc3f
...
...
@@ -172,7 +172,7 @@ func Run() {
AESNI
:
cpuid
.
CPU
.
AesNi
(),
})
if
containerized
:=
detectContainer
();
containerized
{
telemetry
.
Set
(
"
in_
container"
,
containerized
)
telemetry
.
Set
(
"container"
,
containerized
)
}
telemetry
.
StartEmitting
()
...
...
@@ -299,7 +299,7 @@ func setCPU(cpu string) error {
return
nil
}
// detectContainer attemps to determine whether the process is
// detectContainer attemp
t
s to determine whether the process is
// being run inside a container. References:
// https://tuhrig.de/how-to-know-you-are-inside-a-docker-container/
// https://stackoverflow.com/a/20012536/1048862
...
...
@@ -397,7 +397,7 @@ func initTelemetry() error {
// initialize telemetry
telemetry
.
Init
(
id
,
disabledMetricsSlice
)
// if any metrics were disabled, report
it
// if any metrics were disabled, report
which ones (so we know how representative the data is)
if
len
(
disabledMetricsSlice
)
>
0
{
telemetry
.
Set
(
"disabled_metrics"
,
disabledMetricsSlice
)
log
.
Printf
(
"[NOTICE] The following telemetry metrics are disabled: %s"
,
disabledMetrics
)
...
...
telemetry/telemetry.go
View file @
df7cdc3f
...
...
@@ -40,6 +40,7 @@ import (
"log"
"math/rand"
"net/http"
"runtime"
"strconv"
"strings"
"sync"
...
...
@@ -66,6 +67,9 @@ func emit(final bool) error {
return
fmt
.
Errorf
(
"telemetry not enabled"
)
}
// some metrics are updated/set at time of emission
setEmitTimeMetrics
()
// ensure only one update happens at a time;
// skip update if previous one still in progress
updateMu
.
Lock
()
...
...
@@ -228,6 +232,17 @@ func stopUpdateTimer() {
updateTimerMu
.
Unlock
()
}
// setEmitTimeMetrics sets some metrics that should
// be recorded just before emitting.
func
setEmitTimeMetrics
()
{
Set
(
"goroutines"
,
runtime
.
NumGoroutine
())
var
mem
runtime
.
MemStats
runtime
.
ReadMemStats
(
&
mem
)
SetNested
(
"memory"
,
"heap_alloc"
,
mem
.
HeapAlloc
)
SetNested
(
"memory"
,
"sys"
,
mem
.
Sys
)
}
// makePayloadAndResetBuffer prepares a payload
// by emptying the collection buffer. It returns
// the bytes of the payload to send to the server.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment