tim-group / java-statsd-client

a java statsd client library
Other
275 stars 139 forks source link

Android Dev issues #32

Open JuanBarriosPiaggio opened 9 years ago

JuanBarriosPiaggio commented 9 years ago

Hello,

Has this been tested against Android studio and has anyone successfuly integrated this client into an Android native app ?

Thanks

JuanBarriosPiaggio commented 9 years ago

Hello,

I have got it to compile with an android app but i'm not getting the packets to send. Here is the code so far.

@Override protected void onCreate(Bundle savedInstanceState) {

    new Connection().execute();

}

private class Connection extends AsyncTask <Void, Void, Void>{

    @Override
    protected Void doInBackground(Void... arg0) {
        connect();
        return null;
    }

}

private void connect() {
    final NonBlockingStatsDClient statsd = new NonBlockingStatsDClient("test.test", "192.168.0.3", 8125);
    try{

        statsd.incrementCounter("bar");
        statsd.recordGaugeValue("baz", 100);
        statsd.recordExecutionTime("bag", 25);
        statsd.recordSetEvent("qux", "one");
        statsd.incrementCounter("bar");

    }catch(Exception e){
        e.printStackTrace();
    }

}

Is there anything i'm doing wrong ? If i use a packet sender app i can see the packets reaching my statsd server but with the above code, i get no errors and the packets don't show up on my server.

scarytom commented 9 years ago

This library has not been tested on android, so I do not know if it will work. You might try passing an error handler to the statsd client that logs any errors:

StatsDClientErrorHandler handler = new StatsDClientErrorHandler() {
    @Override public void handle(Exception ex) {
        android.util.Log.e(ex.getMessage());
    }
}
NonBlockingStatsDClient statsd = new NonBlockingStatsDClient("test.test", "192.168.0.3", 8125, handler);
JuanBarriosPiaggio commented 9 years ago

Thanks for getting back to me, i will try again this evening and post the results back here.

red61wjt commented 9 years ago

How did you get on with your testing?