Class: Appsignal::Extension
- Inherits:
-
Object
- Object
- Appsignal::Extension
- Defined in:
- lib/appsignal/extension.rb,
ext/appsignal_extension.c
Defined Under Namespace
Classes: ExtTransaction
Class Method Summary collapse
- .add_distribution_value(key, value) ⇒ Object
- .agent_config ⇒ Object
- .agent_version ⇒ Object
-
.get_server_state(key) ⇒ Object
Server state.
- .increment_counter(key, count) ⇒ Object
-
.install_allocation_event_hook ⇒ Object
Event hook installation.
- .install_gc_event_hooks ⇒ Object
- .method_missing(m, *args, &block) ⇒ Object
-
.set_gauge(key, value) ⇒ Object
Metrics.
-
.start ⇒ Object
Starting and stopping.
-
.start_transaction(transaction_id, namespace) ⇒ Object
Start transaction.
- .stop ⇒ Object
Class Method Details
.add_distribution_value(key, value) ⇒ Object
198 199 200 201 202 203 204 205 206 207 |
# File 'ext/appsignal_extension.c', line 198
static VALUE add_distribution_value(VALUE self, VALUE key, VALUE value) {
Check_Type(key, T_STRING);
Check_Type(value, T_FLOAT);
appsignal_add_distribution_value(
StringValueCStr(key),
NUM2DBL(value)
);
return Qnil;
}
|
.agent_config ⇒ Object
17 18 19 20 21 |
# File 'lib/appsignal/extension.rb', line 17 def agent_config @agent_config ||= YAML.load( File.read(File.join(File.dirname(__FILE__), '../../ext/agent.yml')) ) end |
.agent_version ⇒ Object
23 24 25 |
# File 'lib/appsignal/extension.rb', line 23 def agent_version agent_config['version'] end |
.get_server_state(key) ⇒ Object
Server state
20 21 22 23 24 25 26 27 28 29 30 |
# File 'ext/appsignal_extension.c', line 20
static VALUE get_server_state(VALUE self, VALUE key) {
char * ptr = appsignal_get_server_state(StringValueCStr(key));
Check_Type(key, T_STRING);
if (ptr) {
return rb_str_new2(ptr);
} else {
return Qnil;
}
}
|
.increment_counter(key, count) ⇒ Object
187 188 189 190 191 192 193 194 195 196 |
# File 'ext/appsignal_extension.c', line 187
static VALUE increment_counter(VALUE self, VALUE key, VALUE count) {
Check_Type(key, T_STRING);
Check_Type(count, T_FIXNUM);
appsignal_increment_counter(
StringValueCStr(key),
FIX2INT(count)
);
return Qnil;
}
|
.install_allocation_event_hook ⇒ Object
Event hook installation
221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'ext/appsignal_extension.c', line 221
static VALUE install_allocation_event_hook() {
// This event hook is only available on Ruby 2.1 and 2.2
#if defined(RUBY_INTERNAL_EVENT_NEWOBJ)
rb_add_event_hook(
track_allocation,
RUBY_INTERNAL_EVENT_NEWOBJ,
Qnil
);
#endif
return Qnil;
}
|
.install_gc_event_hooks ⇒ Object
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'ext/appsignal_extension.c', line 234
static VALUE install_gc_event_hooks() {
// These event hooks are only available on Ruby 2.1 and 2.2
#if defined(RUBY_INTERNAL_EVENT_GC_START)
rb_add_event_hook(
track_gc_start,
RUBY_INTERNAL_EVENT_GC_START,
Qnil
);
#endif
#if defined(RUBY_INTERNAL_EVENT_GC_END_SWEEP)
rb_add_event_hook(
track_gc_end,
RUBY_INTERNAL_EVENT_GC_END_MARK | RUBY_INTERNAL_EVENT_GC_END_SWEEP,
Qnil
);
#endif
return Qnil;
}
|
.method_missing(m, *args, &block) ⇒ Object
27 28 29 |
# File 'lib/appsignal/extension.rb', line 27 def method_missing(m, *args, &block) # Do nothing if the extension methods are not loaded end |
.set_gauge(key, value) ⇒ Object
Metrics
176 177 178 179 180 181 182 183 184 185 |
# File 'ext/appsignal_extension.c', line 176
static VALUE set_gauge(VALUE self, VALUE key, VALUE value) {
Check_Type(key, T_STRING);
Check_Type(value, T_FLOAT);
appsignal_set_gauge(
StringValueCStr(key),
NUM2DBL(value)
);
return Qnil;
}
|
.start ⇒ Object
Starting and stopping
8 9 10 11 12 |
# File 'ext/appsignal_extension.c', line 8 static VALUE start(VALUE self) { appsignal_start(); return Qnil; } |
.start_transaction(transaction_id, namespace) ⇒ Object
Start transaction
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'ext/appsignal_extension.c', line 32
static VALUE start_transaction(VALUE self, VALUE transaction_id, VALUE namespace) {
appsignal_transaction* transaction;
Check_Type(transaction_id, T_STRING);
Check_Type(namespace, T_STRING);
transaction = appsignal_start_transaction(
StringValueCStr(transaction_id),
StringValueCStr(namespace)
);
if (transaction) {
return Data_Wrap_Struct(ExtTransaction, NULL, appsignal_free_transaction, transaction);
} else {
return Qnil;
}
}
|
.stop ⇒ Object
14 15 16 17 18 |
# File 'ext/appsignal_extension.c', line 14 static VALUE stop(VALUE self) { appsignal_stop(); return Qnil; } |