opentelemetry-ruby icon indicating copy to clipboard operation
opentelemetry-ruby copied to clipboard

release: metrics-sdk metrics-api

Open xuan-cao-swi opened this issue 1 year ago • 4 comments

I'd like to suggest an alpha release for the metrics-api and metrics-sdk.

Releasing an alpha version of these metrics components could provide benefits to end-users who wish to adopt the technology and to contributors looking to gather feedback and refine the implementation based on actual usage scenarios.

xuan-cao-swi avatar May 30 '24 18:05 xuan-cao-swi

.alpha is kinda unique (should there be .alpha2, .alpha.2?) Also, the semantic versioning spec says:

Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable.

Based on that, it feels like releasing 0.0.1 should be good for an alpha stability.

dmathieu avatar May 31 '24 07:05 dmathieu

Sample prometheus graph on histogram and counter demo-promethesus-1 demo-promethesus-2

Here is the script that generate the graph

require 'opentelemetry/sdk'
require 'opentelemetry-metrics-sdk'
require 'opentelemetry/exporter/otlp'
require 'vmstat'

ENV['OTEL_SERVICE_NAME'] = 'prometheus-metrics'

OpenTelemetry::SDK.configure
console_metric_exporter = OpenTelemetry::Exporter::OTLP::MetricsExporter.new
OpenTelemetry.meter_provider.add_metric_reader(console_metric_exporter)
meter = OpenTelemetry.meter_provider.meter("sample_ruby_meter_name")

mem_free_hist = meter.create_histogram("ff6fdf6a349c_mem_free", unit: 'smidgen')
mem_active_hist = meter.create_histogram("ff6fdf6a349c_mem_active", unit: 'smidgen')
mem_inactive_hist = meter.create_histogram("ff6fdf6a349c_mem_inactive", unit: 'smidgen')
mem_wired_hist = meter.create_histogram("ff6fdf6a349c_mem_wired", unit: 'smidgen')

random_number_generator_1 = meter.create_counter("ff6fdf6a349c_rand_1", unit: 'smidgen')
random_number_generator_2 = meter.create_counter("ff6fdf6a349c_rand_2", unit: 'smidgen')
random_number_generator_3 = meter.create_counter("ff6fdf6a349c_rand_3", unit: 'smidgen')
random_number_generator_4 = meter.create_counter("ff6fdf6a349c_rand_4", unit: 'smidgen')

loop do
  vmstat = Vmstat.snapshot
  memory_info = vmstat.memory

  total_memory = memory_info.wired + memory_info.active + memory_info.inactive + memory_info.free
  free = (memory_info.free.to_f / total_memory) * 100
  active = (memory_info.active.to_f / total_memory) * 100
  inactive = (memory_info.inactive.to_f / total_memory) * 100
  wired = (memory_info.wired.to_f / total_memory) * 100

  mem_free_hist.record(free.round(2), attributes: {'sample_attr' => '1'})
  mem_active_hist.record(active.round(2), attributes: {'sample_attr' => '2'})
  mem_inactive_hist.record(inactive.round(2), attributes: {'sample_attr' => '3'})
  mem_wired_hist.record(wired.round(2), attributes: {'sample_attr' => '4'})

  random_number_generator_1.add(rand(0..10), attributes: {'sample_attr' => '10'})
  random_number_generator_2.add(rand(10..20), attributes: {'sample_attr' => '11'})
  random_number_generator_3.add(rand(20..30), attributes: {'sample_attr' => '12'})
  random_number_generator_4.add(rand(30..40), attributes: {'sample_attr' => '13'})

  sleep 5
  OpenTelemetry.meter_provider.metric_readers.each(&:pull)
  sleep 10
  puts "========================= collect finished ========================="
end

xuan-cao-swi avatar Jun 13 '24 17:06 xuan-cao-swi

Based on that, it feels like releasing 0.0.1 should be good for an alpha stability.

@dmathieu I am open to change the name for alpha release.

xuan-cao-swi avatar Jun 13 '24 17:06 xuan-cao-swi

Looking forward to having the first alpha version. We're currently integrating Opentelemetry metrics in our apps (we already have traces) and would be great to also do it for Ruby (instead of using prometheus endpoint).

hwo411 avatar Jun 27 '24 08:06 hwo411

@xuan-cao-swi - I opened a PR with readmes for the metrics-sdk and metrics-api gems. It also includes a few small updates to the text in this PR.

https://github.com/xuan-cao-swi/opentelemetry-ruby/pull/3

kaylareopelle avatar Jul 24 '24 22:07 kaylareopelle

I'll plan to merge this at EOD on Monday barring any new feedback.

mwear avatar Jul 25 '24 22:07 mwear