Module: ScoutApmMcp::Helpers::Identifiers

Included in:
ScoutApmMcp::Helpers
Defined in:
lib/scout_apm_mcp/helpers/identifiers.rb

Instance Method Summary collapse

Instance Method Details

#decode_endpoint_id(endpoint_id) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/scout_apm_mcp/helpers/identifiers.rb', line 4

def decode_endpoint_id(endpoint_id)
  decoded = Base64.urlsafe_decode64(endpoint_id)
  if decoded.force_encoding(Encoding::UTF_8).valid_encoding?
    decoded.force_encoding(Encoding::UTF_8)
  else
    decoded = Base64.decode64(endpoint_id)
    if decoded.force_encoding(Encoding::UTF_8).valid_encoding?
      decoded.force_encoding(Encoding::UTF_8)
    else
      endpoint_id.dup.force_encoding(Encoding::UTF_8)
    end
  end
rescue
  endpoint_id.dup.force_encoding(Encoding::UTF_8)
end

#get_endpoint_id(endpoint) ⇒ Object



20
21
22
23
24
25
# File 'lib/scout_apm_mcp/helpers/identifiers.rb', line 20

def get_endpoint_id(endpoint)
  link = endpoint["link"] || endpoint[:link] || ""
  return "" if link.empty?

  link.split("/").last || ""
end

#get_job_id(job) ⇒ Object



27
28
29
# File 'lib/scout_apm_mcp/helpers/identifiers.rb', line 27

def get_job_id(job)
  job["job_id"] || job[:job_id] || ""
end