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
bb124e50
Commit
bb124e50
authored
Sep 24, 2012
by
Kamil Kisiel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a simple program for testing the statsd
parent
e1b7f409
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
0 deletions
+84
-0
tester/main.go
tester/main.go
+79
-0
tester/test_metrics
tester/test_metrics
+5
-0
No files found.
tester/main.go
0 → 100644
View file @
bb124e50
package
main
import
(
"bufio"
"flag"
"fmt"
"github.com/kisielk/gostatsd/statsd"
"io"
"math/rand"
"net"
"os"
"time"
)
var
(
statsdAddr
string
)
const
(
defaultStatsdAddr
=
":8125"
)
type
MetricDef
struct
{
Bucket
string
Type
statsd
.
MetricType
MinVal
float64
MaxVal
float64
MinDelay
time
.
Duration
MaxDelay
time
.
Duration
}
func
init
()
{
flag
.
StringVar
(
&
statsdAddr
,
"s"
,
defaultStatsdAddr
,
"address of statsd server"
)
}
func
main
()
{
flag
.
Parse
()
c
:=
make
(
chan
string
)
done
:=
make
(
chan
bool
)
go
func
()
{
conn
,
err
:=
net
.
Dial
(
"udp"
,
statsdAddr
)
if
err
!=
nil
{
panic
(
err
)
}
for
l
:=
range
c
{
_
,
err
=
fmt
.
Fprintln
(
conn
,
l
)
if
err
!=
nil
{
fmt
.
Println
(
"error sending:"
,
err
)
break
}
}
done
<-
true
}()
var
err
error
stdin
:=
bufio
.
NewReaderSize
(
os
.
Stdin
,
256
)
for
{
var
line
[]
byte
line
,
_
,
err
=
stdin
.
ReadLine
()
if
err
!=
nil
{
break
}
var
bucket
string
fmt
.
Sscanf
(
string
(
line
),
"%s"
,
&
bucket
)
go
func
()
{
for
{
time
.
Sleep
(
time
.
Second
*
time
.
Duration
(
rand
.
Intn
(
10
)))
c
<-
fmt
.
Sprintf
(
"%s:1|c"
,
bucket
)
}
}()
}
if
err
!=
io
.
EOF
{
panic
(
err
)
}
<-
done
}
tester/test_metrics
0 → 100644
View file @
bb124e50
gostatsd.abcd
gostatsd.defg
gostatsd.asdasd
gostatsd.asdsd
gostatsd.asdee1
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