File: telemetry_attributes.rb

package info (click to toggle)
ruby-sentry-ruby 6.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 644 kB
  • sloc: ruby: 5,771; makefile: 8; sh: 4
file content (30 lines) | stat: -rw-r--r-- 647 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

require "json"

module Sentry
  module Utils
    module TelemetryAttributes
      private

      def attribute_hash(value)
        case value
        when String
          { value: value, type: "string" }
        when TrueClass, FalseClass
          { value: value, type: "boolean" }
        when Integer
          { value: value, type: "integer" }
        when Float
          { value: value, type: "double" }
        else
          begin
            { value: JSON.generate(value), type: "string" }
          rescue
            { value: value, type: "string" }
          end
        end
      end
    end
  end
end