diff --git a/CHANGELOG.md b/CHANGELOG.md index cf0bef2b7..9d934782f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,10 @@ If you were using the `SpanProcessor` before, we recommend migrating over to `config.otlp` since it's a much simpler setup. +### Bug Fixes + +- Fix `MetricEvent` timestamp serialization to float ([#2862](https://github.com/getsentry/sentry-ruby/pull/2862)) + ## 6.3.1 ### Bug Fixes diff --git a/sentry-ruby/lib/sentry/metric_event.rb b/sentry-ruby/lib/sentry/metric_event.rb index 94e9ee346..ea161a501 100644 --- a/sentry-ruby/lib/sentry/metric_event.rb +++ b/sentry-ruby/lib/sentry/metric_event.rb @@ -33,7 +33,7 @@ def to_h type: @type, value: @value, unit: @unit, - timestamp: @timestamp, + timestamp: @timestamp.to_f, trace_id: @trace_id, span_id: @span_id, attributes: serialize_attributes diff --git a/sentry-ruby/spec/sentry/metric_event_spec.rb b/sentry-ruby/spec/sentry/metric_event_spec.rb index 999b651e3..f15b51224 100644 --- a/sentry-ruby/spec/sentry/metric_event_spec.rb +++ b/sentry-ruby/spec/sentry/metric_event_spec.rb @@ -59,7 +59,7 @@ expect(hash[:type]).to eq(:distribution) expect(hash[:value]).to eq(5.0) expect(hash[:unit]).to eq("seconds") - expect(hash[:timestamp]).to be_a(Time) + expect(hash[:timestamp]).to be_a(Float) end it "includes trace info if provided" do