1
1
module Datadog
2
+ # Helpers to read the application environment
2
3
module DemoEnv
3
4
module_function
4
5
5
6
def gem_spec ( gem_name , defaults = { } )
6
- args = if local_gem ( gem_name )
7
- [ local_gem ( gem_name ) ]
8
- elsif git_gem ( gem_name )
9
- [ git_gem ( gem_name ) ]
10
- else
11
- [ ]
12
- end
7
+ args = if local_gem ( gem_name )
8
+ [ local_gem ( gem_name ) ]
9
+ elsif git_gem ( gem_name )
10
+ [ git_gem ( gem_name ) ]
11
+ else
12
+ [ ]
13
+ end
13
14
14
15
yield ( args ) if block_given?
15
16
16
17
args
17
18
end
18
19
19
20
def gem_env_name ( gem_name )
20
- gem_name . upcase . gsub ( '-' , '_' )
21
+ gem_name . upcase . tr ( '-' , '_' )
21
22
end
22
23
23
24
def local_gem ( gem_name )
@@ -55,11 +56,11 @@ def print_env(header = 'Datadog test environment')
55
56
puts "Features: #{ features } "
56
57
puts "Rails env: #{ ENV [ 'RAILS_ENV' ] } " if ENV [ 'RAILS_ENV' ]
57
58
puts "PID: #{ Process . pid } "
58
- if ddtrace = Gem . loaded_specs [ 'ddtrace' ]
59
- puts "Runtime ID: #{ Datadog ::Runtime :: Identity . id } " if defined? ( Datadog ::Runtime ::Identity )
59
+ if ( ddtrace = Gem . loaded_specs [ 'ddtrace' ] )
60
+ puts "Runtime ID: #{ Datadog ::Core :: Environment :: Identity . id } " if defined? ( Datadog ::Core :: Environment ::Identity )
60
61
puts "ddtrace version: #{ ddtrace . version } "
61
62
puts "ddtrace path: #{ ddtrace . full_gem_path } "
62
- if git_spec = git_gem ( 'ddtrace' )
63
+ if ( git_spec = git_gem ( 'ddtrace' ) )
63
64
puts "ddtrace git: #{ git_spec [ :git ] } "
64
65
puts "ddtrace ref: #{ git_spec [ :ref ] } "
65
66
end
@@ -69,10 +70,10 @@ def print_env(header = 'Datadog test environment')
69
70
70
71
def profiler_file_transport ( dump_path = "/data/profile-pid-#{ Process . pid } .pprof" )
71
72
Datadog ::Profiling ::Transport ::IO . default (
72
- write : -> ( out , data ) do
73
+ write : lambda do | _out , data |
73
74
result = nil
74
75
puts "Writing pprof #{ dump_path } ..."
75
- File . open ( dump_path , "w" ) { |f | result = f . write ( data ) }
76
+ File . open ( dump_path , 'w' ) { |f | result = f . write ( data ) }
76
77
puts "Pprof #{ dump_path } written!"
77
78
result
78
79
end
@@ -86,7 +87,7 @@ def start_mem_dump!
86
87
87
88
def finish_mem_dump! ( dump_path = "/data/mem-pid-#{ Process . pid } .dump" )
88
89
File . delete ( dump_path ) if File . exist? ( dump_path )
89
- File . open ( dump_path , "w" ) do |io |
90
+ File . open ( dump_path , 'w' ) do |io |
90
91
ObjectSpace . dump_all ( output : io )
91
92
end
92
93
end
0 commit comments