mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-01-26 05:28:40 -05:00
Add OpenTelemetry client instrumentation
This commit is contained in:
parent
6d1130bc8b
commit
8f8630540a
3 changed files with 63 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue