Currently it is not possible to generate counters through UDF. We should support this.
Pig currently allows this.
HIVE-1016 Ability to access DistributedCache from UDFs
HIVE-2261 Add cleanup stages for UDFs