forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
49 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
logstash-core/src/main/java/org/logstash/instrument/metrics/SnapshotExt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.logstash.instrument.metrics; | ||
|
||
import org.jruby.Ruby; | ||
import org.jruby.RubyBasicObject; | ||
import org.jruby.RubyClass; | ||
import org.jruby.RubyTime; | ||
import org.jruby.anno.JRubyClass; | ||
import org.jruby.anno.JRubyMethod; | ||
import org.jruby.runtime.ThreadContext; | ||
import org.jruby.runtime.builtin.IRubyObject; | ||
|
||
@JRubyClass(name = "Snapshot") | ||
public final class SnapshotExt extends RubyBasicObject { | ||
|
||
private IRubyObject metricStore; | ||
|
||
private RubyTime createdAt; | ||
|
||
public SnapshotExt(final Ruby runtime, final RubyClass metaClass) { | ||
super(runtime, metaClass); | ||
} | ||
|
||
@JRubyMethod(required = 1, optional = 1) | ||
public SnapshotExt initialize(final ThreadContext context, final IRubyObject[] args) { | ||
metricStore = args[0]; | ||
if (args.length == 2) { | ||
createdAt = (RubyTime) args[1]; | ||
} else { | ||
createdAt = (RubyTime) RubyTime.newInstance(context, context.runtime.getTime()); | ||
} | ||
return this; | ||
} | ||
|
||
@JRubyMethod(name = "metric_store") | ||
public IRubyObject metricStore() { | ||
return metricStore; | ||
} | ||
|
||
@JRubyMethod(name = "created_at") | ||
public RubyTime createdAt() { | ||
return createdAt; | ||
} | ||
} |