Class: Appsignal::Extension Private

Inherits:
Object show all
Extended by:
Jruby
Defined in:
lib/appsignal/extension.rb,
lib/appsignal/extension/jruby.rb,
ext/appsignal_extension.c

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Modules: Jruby Classes: Data, MockData, MockTransaction, Span, Transaction

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Jruby

add_distribution_value, diagnose, get_server_state, increment_counter, lib_extension, log, running_in_container?, set_environment_metadata, set_gauge, set_host_gauge, set_process_gauge, start, start_transaction, stop

Methods included from Jruby::StringHelpers

#make_appsignal_string, #make_ruby_string

Class Method Details

.add_distribution_value(key, value, tags) ⇒ Object



801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
# File 'ext/appsignal_extension.c', line 801

static VALUE add_distribution_value(VALUE self, VALUE key, VALUE value, VALUE tags) {
  appsignal_data_t* tags_data;

  Check_Type(key, T_STRING);
  Check_Type(value, T_FLOAT);
  Check_Type(tags, RUBY_T_DATA);

  Data_Get_Struct(tags, appsignal_data_t, tags_data);

  appsignal_add_distribution_value(
      make_appsignal_string(key),
      NUM2DBL(value),
      tags_data
  );
  return Qnil;
}

.agent_configObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
# File 'lib/appsignal/extension.rb', line 24

def agent_config
  require_relative "../../ext/agent"
  ::APPSIGNAL_AGENT_CONFIG
end

.agent_versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
# File 'lib/appsignal/extension.rb', line 29

def agent_version
  agent_config["version"]
end

.data_array_newObject



312
313
314
315
316
317
318
319
320
321
322
# File 'ext/appsignal_extension.c', line 312

static VALUE data_array_new(VALUE self) {
  appsignal_data_t* data;

  data = appsignal_data_array_new();

  if (data) {
    return Data_Wrap_Struct(Data, NULL, appsignal_free_data, data);
  } else {
    return Qnil;
  }
}

.data_map_newObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create a data map or array



300
301
302
303
304
305
306
307
308
309
310
# File 'ext/appsignal_extension.c', line 300

static VALUE data_map_new(VALUE self) {
  appsignal_data_t* data;

  data = appsignal_data_map_new();

  if (data) {
    return Data_Wrap_Struct(Data, NULL, appsignal_free_data, data);
  } else {
    return Qnil;
  }
}

.diagnoseObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Diagnostics



36
37
38
# File 'ext/appsignal_extension.c', line 36

static VALUE diagnose(VALUE self) {
  return make_ruby_string(appsignal_diagnose());
}

.get_server_state(key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Server state



40
41
42
43
44
45
46
47
48
49
50
51
# File 'ext/appsignal_extension.c', line 40

static VALUE get_server_state(VALUE self, VALUE key) {
  appsignal_string_t string;

  Check_Type(key, T_STRING);

  string = appsignal_get_server_state(make_appsignal_string(key));
  if (string.len > 0) {
    return make_ruby_string(string);
  } else {
    return Qnil;
  }
}

.increment_counter(key, count, tags) ⇒ Object



784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
# File 'ext/appsignal_extension.c', line 784

static VALUE increment_counter(VALUE self, VALUE key, VALUE count, VALUE tags) {
  appsignal_data_t* tags_data;

  Check_Type(key, T_STRING);
  Check_Type(count, T_FLOAT);
  Check_Type(tags, RUBY_T_DATA);

  Data_Get_Struct(tags, appsignal_data_t, tags_data);

  appsignal_increment_counter(
      make_appsignal_string(key),
      NUM2DBL(count),
      tags_data
  );
  return Qnil;
}

.install_allocation_event_hookObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Other helper methods



822
823
824
825
826
827
828
829
830
831
832
833
# File 'ext/appsignal_extension.c', line 822

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;
}

.log(group, severity, format, message, attributes) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Logging



723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
# File 'ext/appsignal_extension.c', line 723

static VALUE a_log(VALUE self, VALUE group, VALUE severity, VALUE format, VALUE message, VALUE attributes) {
  appsignal_data_t* attributes_data;

  Check_Type(group, T_STRING);
  Check_Type(severity, T_FIXNUM);
  Check_Type(format, T_FIXNUM);
  Check_Type(message, T_STRING);
  Check_Type(attributes, RUBY_T_DATA);

  Data_Get_Struct(attributes, appsignal_data_t, attributes_data);

  appsignal_log(
      make_appsignal_string(group),
      FIX2INT(severity),
      FIX2INT(format),
      make_appsignal_string(message),
      attributes_data
   );

  return Qnil;
}

.method_missing(m, *args, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Do nothing if the extension methods are not loaded

Disabled in testing so we can make sure that we don't miss a extension function implementation.



37
38
39
# File 'lib/appsignal/extension.rb', line 37

def method_missing(m, *args, &block)
  super if Appsignal.testing?
end

.running_in_container?Boolean

Returns:

  • (Boolean)


835
836
837
# File 'ext/appsignal_extension.c', line 835

static VALUE running_in_container() {
  return appsignal_running_in_container() == 1 ? Qtrue : Qfalse;
}

.set_environment_metadata(key, value) ⇒ Object



839
840
841
842
843
844
845
# File 'ext/appsignal_extension.c', line 839

static VALUE set_environment_metadata(VALUE self, VALUE key, VALUE value) {
  appsignal_set_environment_metadata(
      make_appsignal_string(key),
      make_appsignal_string(value)
  );
  return Qnil;
}

.set_gauge(key, value, tags) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Metrics



745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
# File 'ext/appsignal_extension.c', line 745

static VALUE set_gauge(VALUE self, VALUE key, VALUE value, VALUE tags) {
  appsignal_data_t* tags_data;

  Check_Type(key, T_STRING);
  Check_Type(value, T_FLOAT);
  Check_Type(tags, RUBY_T_DATA);

  Data_Get_Struct(tags, appsignal_data_t, tags_data);

  appsignal_set_gauge(
      make_appsignal_string(key),
      NUM2DBL(value),
      tags_data
  );
  return Qnil;
}

.set_host_gauge(key, value) ⇒ Object



762
763
764
765
766
767
768
769
770
771
# File 'ext/appsignal_extension.c', line 762

static VALUE set_host_gauge(VALUE self, VALUE key, VALUE value) {
  Check_Type(key, T_STRING);
  Check_Type(value, T_FLOAT);

  appsignal_set_host_gauge(
      make_appsignal_string(key),
      NUM2DBL(value)
  );
  return Qnil;
}

.set_process_gauge(key, value) ⇒ Object



773
774
775
776
777
778
779
780
781
782
# File 'ext/appsignal_extension.c', line 773

static VALUE set_process_gauge(VALUE self, VALUE key, VALUE value) {
  Check_Type(key, T_STRING);
  Check_Type(value, T_FLOAT);

  appsignal_set_process_gauge(
      make_appsignal_string(key),
      NUM2DBL(value)
  );
  return Qnil;
}

.startObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Starting and stopping



24
25
26
27
28
# File 'ext/appsignal_extension.c', line 24

static VALUE start(VALUE self) {
  appsignal_start();

  return Qnil;
}

.start_transaction(transaction_id, namespace, gc_duration_ms) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Start transaction



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'ext/appsignal_extension.c', line 53

static VALUE start_transaction(VALUE self, VALUE transaction_id, VALUE namespace, VALUE gc_duration_ms) {
  appsignal_transaction_t* transaction;

  Check_Type(transaction_id, T_STRING);
  Check_Type(namespace, T_STRING);
  Check_Type(gc_duration_ms, T_FIXNUM);

  transaction = appsignal_start_transaction(
      make_appsignal_string(transaction_id),
      make_appsignal_string(namespace),
      NUM2LONG(gc_duration_ms)
  );

  if (transaction) {
    return Data_Wrap_Struct(Transaction, NULL, appsignal_free_transaction, transaction);
  } else {
    return Qnil;
  }
}

.stopObject



30
31
32
33
34
# File 'ext/appsignal_extension.c', line 30

static VALUE stop(VALUE self) {
  appsignal_stop();

  return Qnil;
}

Instance Method Details

#data_array_newObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



46
47
48
# File 'lib/appsignal/extension.rb', line 46

def data_array_new
  Appsignal::Extension::MockData.new
end

#data_map_newObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
# File 'lib/appsignal/extension.rb', line 42

def data_map_new
  Appsignal::Extension::MockData.new
end