Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Commit

Permalink
Call the gauge callback using the current thread context
Browse files Browse the repository at this point in the history
Instead of the one that was passed when the callback was captured.
  • Loading branch information
iconara committed Mar 18, 2015
1 parent 8de0582 commit be8434f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ext/java/multimeter/MetricRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ public IRubyObject histogram(ThreadContext ctx, IRubyObject arg) {
}

@JRubyMethod
public IRubyObject gauge(final ThreadContext ctx, IRubyObject arg, final Block block) {
public IRubyObject gauge(ThreadContext ctx, IRubyObject arg, Block block) {
String name = arg.asJavaString();
final RubyProc callback = ctx.runtime.newProc(Block.Type.PROC, block);
final Ruby runtime = ctx.runtime;
Gauge wrapper = new Gauge(ctx.runtime, registry.register(name, new com.codahale.metrics.Gauge<IRubyObject>() {
@Override
public IRubyObject getValue() {
return callback.call19(ctx, IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
return callback.call(runtime.getCurrentContext(), IRubyObject.NULL_ARRAY);
}
}));
metrics.fastASet(arg, wrapper);
Expand Down

0 comments on commit be8434f

Please sign in to comment.