Add OpenTelemetry client instrumentation

This commit is contained in:
Gene Liverman 2020-10-09 22:04:34 -04:00
parent 6d1130bc8b
commit 8f8630540a
No known key found for this signature in database
GPG key ID: 66D794FE7043CBCA
3 changed files with 63 additions and 0 deletions

View file

@ -14,6 +14,7 @@ require 'vmfloaty/utils'
require 'vmfloaty/service'
require 'vmfloaty/ssh'
require 'vmfloaty/logger'
require 'vmfloaty/otel'
class Vmfloaty
include Commander::Methods
@ -45,6 +46,8 @@ class Vmfloaty
use_token = !options.notoken
force = options.force
Otel.configure_tracing(service)
if args.empty?
FloatyLogger.error 'No operating systems provided to obtain. See `floaty get --help` for more information on how to get VMs.'
exit 1
@ -98,6 +101,8 @@ class Vmfloaty
service = Service.new(options, config)
filter = args[0]
Otel.configure_tracing(service)
if options.active
# list active vms
if service.type == "ABS"
@ -146,6 +151,8 @@ class Vmfloaty
service = Service.new(options, config)
hostname = args[0]
Otel.configure_tracing(service)
query_req = service.query(verbose, hostname)
pp query_req
end
@ -171,6 +178,8 @@ class Vmfloaty
hostname = args[0]
modify_all = options.all
Otel.configure_tracing(service)
if hostname.nil? && !modify_all
FloatyLogger.error 'ERROR: Provide a hostname or specify --all.'
exit 1
@ -236,6 +245,8 @@ class Vmfloaty
delete_all = options.all
force = options.f
Otel.configure_tracing(service)
failures = []
successes = []
@ -324,6 +335,8 @@ class Vmfloaty
service = Service.new(options, config)
hostname = args[0]
Otel.configure_tracing(service)
begin
snapshot_req = service.snapshot(verbose, hostname)
rescue TokenError, ModifyError => e
@ -352,6 +365,8 @@ class Vmfloaty
hostname = args[0]
snapshot_sha = args[1] || options.snapshot
Otel.configure_tracing(service)
FloatyLogger.info "Two snapshot arguments were given....using snapshot #{snapshot_sha}" if args[1] && options.snapshot
begin
@ -377,6 +392,9 @@ class Vmfloaty
c.action do |_, options|
verbose = options.verbose || config['verbose']
service = Service.new(options, config)
Otel.configure_tracing(service)
if options.json
pp service.status(verbose)
else
@ -397,6 +415,8 @@ class Vmfloaty
verbose = options.verbose || config['verbose']
service = Service.new(options, config)
Otel.configure_tracing(service)
summary = service.summary(verbose)
pp summary
exit 0
@ -418,6 +438,8 @@ class Vmfloaty
service = Service.new(options, config)
action = args.first
Otel.configure_tracing(service)
begin
case action
when 'get'
@ -462,6 +484,8 @@ class Vmfloaty
service = Service.new(options, config)
use_token = !options.notoken
Otel.configure_tracing(service)
if args.empty?
FloatyLogger.error 'No operating systems provided to obtain. See `floaty ssh --help` for more information on how to get VMs.'
exit 1