Sha256: 8c9cc2b1f2c798973d2561137eda30d55e8efe4dec2b76f82b1921494ee48cf4

Contents?: true

Size: 755 Bytes

Versions: 1

Compression:

Stored size: 755 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_module_function(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

1 entries across 1 versions & 1 rubygems

Version Path
plain_apm-0.5.0 ext/object_tracing/object_tracing.c