Sha256: 0b533c93be2841dccb5767482540918807bb0e1e61984155245116c1cb5672e0

Contents?: true

Size: 756 Bytes

Versions: 20

Compression:

Stored size: 756 Bytes

Contents

#include <ruby/ruby.h>
#include <ruby/debug.h>

static __thread uint64_t allocated_objects = 0;

static VALUE rb_mPlainApm;
static VALUE rb_mObjTracing;

static VALUE total_thread_allocated_objects(VALUE self) {
  return ULL2NUM(allocated_objects);
}

static void track_thread_allocated_objects(VALUE tpval, void *data) {
  allocated_objects++;
}

void Init_object_tracing(void) {
  rb_mPlainApm = rb_define_module("PlainApm");
  rb_mObjTracing = rb_define_module_under(rb_mPlainApm, "ObjectTracing");

  rb_define_singleton_method(rb_mObjTracing, "total_thread_allocated_objects", total_thread_allocated_objects, 0);

  VALUE tpval = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ, track_thread_allocated_objects, NULL);
  rb_tracepoint_enable(tpval);
}

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
plain_apm-0.8.3 ext/object_tracing/object_tracing.c
plain_apm-0.8.2 ext/object_tracing/object_tracing.c
plain_apm-0.8.1 ext/object_tracing/object_tracing.c
plain_apm-0.8.0 ext/object_tracing/object_tracing.c
plain_apm-0.7.1 ext/object_tracing/object_tracing.c
plain_apm-0.7.0 ext/object_tracing/object_tracing.c
plain_apm-0.6.7 ext/object_tracing/object_tracing.c
plain_apm-0.6.6 ext/object_tracing/object_tracing.c
plain_apm-0.6.5 ext/object_tracing/object_tracing.c
plain_apm-0.6.4 ext/object_tracing/object_tracing.c
plain_apm-0.6.3 ext/object_tracing/object_tracing.c
plain_apm-0.6.2 ext/object_tracing/object_tracing.c
plain_apm-0.6.1 ext/object_tracing/object_tracing.c
plain_apm-0.5.7 ext/object_tracing/object_tracing.c
plain_apm-0.5.6 ext/object_tracing/object_tracing.c
plain_apm-0.5.5 ext/object_tracing/object_tracing.c
plain_apm-0.5.4 ext/object_tracing/object_tracing.c
plain_apm-0.5.3 ext/object_tracing/object_tracing.c
plain_apm-0.5.2 ext/object_tracing/object_tracing.c
plain_apm-0.5.1 ext/object_tracing/object_tracing.c