Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gostatsd
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ale
gostatsd
Commits
49bd4284
Commit
49bd4284
authored
Apr 16, 2012
by
Kamil Kisiel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added pretty-printing of metrics via TCP client
parent
96c16085
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
gostatsd.go
gostatsd.go
+23
-3
No files found.
gostatsd.go
View file @
49bd4284
package
main
import
(
"bytes"
"fmt"
"log"
"math"
...
...
@@ -58,6 +59,25 @@ func (m Metric) String() string {
type
MetricMap
map
[
string
]
float64
type
MetricListMap
map
[
string
][]
float64
func
(
m
MetricListMap
)
String
()
string
{
buf
:=
new
(
bytes
.
Buffer
)
for
k
,
v
:=
range
m
{
buf
.
Write
([]
byte
(
fmt
.
Sprint
(
k
)))
for
_
,
v2
:=
range
v
{
buf
.
Write
([]
byte
(
fmt
.
Sprintf
(
"
\t
%f
\n
"
,
k
,
v2
)))
}
}
return
buf
.
String
()
}
func
(
m
MetricMap
)
String
()
string
{
buf
:=
new
(
bytes
.
Buffer
)
for
k
,
v
:=
range
m
{
buf
.
Write
([]
byte
(
fmt
.
Sprintf
(
"%s: %f
\n
"
,
k
,
v
)))
}
return
buf
.
String
()
}
type
ConsoleRequest
struct
{
Command
string
ResultChan
chan
string
...
...
@@ -205,11 +225,11 @@ func metricAggregator(metricChan chan Metric, consoleChan chan ConsoleRequest) {
case
"stats"
:
result
=
"stats:
\n
"
case
"counters"
:
result
=
"counters:
\n
"
result
=
fmt
.
Sprint
(
counters
)
case
"timers"
:
result
=
"timers:
\n
"
result
=
fmt
.
Sprint
(
timers
)
case
"gauges"
:
result
=
"gauges:
\n
"
result
=
fmt
.
Sprint
(
gauges
)
case
"delcounters"
:
for
_
,
k
:=
range
parts
[
1
:
]
{
delete
(
counters
,
k
)
...
...
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