[metrics] Do not write to statsd when not supported

Previously, on platforms that did not support statsd, we would add a
null pointer to the list of backends when statsd was enabled. This led
to a null pointer dereference when trying to report metrics.

The problem was that CreateStatsdBackend returns nullptr when statsd
is not supported, but we were not checking the return value. This CL
fixes it.

Test: ./test.py --run-test --host -t 801 --jit --64 \
                --runtime-option=-Xwrite-metrics-to-statsd=true
Bug: 170149255
Change-Id: I02af48d1ec60f902ba2651b6991c017d88d75495
1 file changed