Module: SolidApm::ApplicationHelper

Defined in:
app/helpers/solid_apm/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#area_chart_options(browser_timezone: nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'app/helpers/solid_apm/application_helper.rb', line 22

def area_chart_options(browser_timezone: nil)
  timezone_js = if browser_timezone.present?
                  "if (!val) return ''; return new Date(val).toLocaleString('en-US', { timeZone: '#{browser_timezone}', hour12: false })"
                else
                  "if (!val) return ''; return new Date(val).toLocaleString('en-US', { hour12: false })"
                end

  # Create date formatter for x-axis labels that respects timezone
  xaxis_formatter = if browser_timezone.present?
                      "if (!val) return ''; return new Date(val).toLocaleString('en-US', { timeZone: '#{browser_timezone}', hour: '2-digit', minute: '2-digit', day: '2-digit', month: 'short', hour12: false })"
                    else
                      "if (!val) return ''; return new Date(val).toLocaleString('en-US', { hour: '2-digit', minute: '2-digit', day: '2-digit', month: 'short', hour12: false })"
                    end

  {
    module: true,
    chart: {
      type: 'area',
      height: '200',
      background: '0',
      foreColor: '#ffffff55',
      zoom: {
        enabled: true,
        autoScaleYaxis: true
      },
      selection: {
        enabled: true,
        type: 'x'
      },
      toolbar: {
        show: false
      },
      events: {
        zoomed: {
          function: {
            args: 'chartContext, { xaxis, yaxis }',
            body: 'handleChartSelection(xaxis.min, xaxis.max)'
          }
        },
        selection: {
          function: {
            args: 'chartContext, { xaxis, yaxis }',
            body: 'handleChartSelection(xaxis.min, xaxis.max)'
          }
        }
      }
    },
    xaxis: {
      type: 'datetime',
      tooltip: {
        enabled: false
      },
      labels: {
        formatter: {
          function: {
            args: 'val',
            body: xaxis_formatter
          }
        }
      }
    },
    stroke: {
      curve: 'smooth'
    },
    theme: {
      mode: 'dark'
    },
    grid: {
      show: true,
      borderColor: '#ffffff55'
    },
    dataLabels: {
      enabled: false
    },
    tooltip: {
      x: {
        formatter: {
          function: {
            args: 'val',
            body: timezone_js
          }
        }
      }
    }
  }
end

#span_type_color(span) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/solid_apm/application_helper.rb', line 3

def span_type_color(span)
  case span.type
  when 'action_view'
    '#00bcd4cc' # cyan
  when 'action_dispatch'
    '#4caf50cc' # green
  when 'active_record'
    '#ff9800cc' # orange
  when 'active_support'
    '#f44336cc' # red
  when 'net_http'
    '#9c27b0cc' # purple
  when 'custom'
    '#3f51b5cc' # indigo
  else
    '#9e9e9ecc' # grey
  end
end