perfetto 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7384eed21d076be3de57b5afa9fc886e979ccc4d89e167afc61e2800314d61f4
4
- data.tar.gz: f6c71a99835e93c07734bfd790aba1d80fa86879327f2357007c184edbd0a619
3
+ metadata.gz: fd838b9d196922765c51a65336d1304c6d9ac9aca456fce60d42b8c72b8b62d4
4
+ data.tar.gz: 9c1972ee1b588bd0dacaaca9cd81c39d90fd892ff0c57b0286157cf8944c6ae8
5
5
  SHA512:
6
- metadata.gz: c77bd5af96cb578659982e03d292893426a64d7d8ef7618ea5ab782005c519c6e2244b4d6cd7885fc2b9f2e76f6551e1fb3bd67b803552df3c8b8e861f671c38
7
- data.tar.gz: e33c6fe69f65d1dcd2ed3a81ba6e2e699b85b89932511233638900514921d310dbf305f17bb0bb899fe39ac2593bac48667fcca452fa53f9fdf0467cf7a90923
6
+ metadata.gz: 92e2da1eceb1263f9d9590fed6130623deee27ab0caa9e4faaf701e3ad340456a6c3730abba3b84da93df94f732a9136ddc8fa9eb7558344701fc132a7f6b69e
7
+ data.tar.gz: f2f6ba2c22ca06fdaea0e09c6ad5e555d7b580a6630a77ff0132c0de1ee188fd33c6ab76b35fc5819a8ea1f5aed5863323207b232c0dfabbb633b6b524136247
data/README.md CHANGED
@@ -94,16 +94,15 @@ Perfetto.stop_tracing "example.pftrace"
94
94
  require "sinatra/base"
95
95
  require "perfetto"
96
96
 
97
- Perfetto.setup enable_tracing: true
98
-
99
97
  class Server < Sinatra::Base
100
- use Perfetto::Middleware
98
+ use Perfetto::Middleware, env_proc: ->(env) { env.to_json }
101
99
 
102
100
  get "/" do
103
101
  "Hello World"
104
102
  end
105
103
  end
106
104
 
105
+ Perfetto.setup enable_tracing: true
107
106
  Perfetto.start_tracing
108
107
  Server.run!
109
108
  Perfetto.stop_tracing "middleware.pftrace"
@@ -1,32 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "json"
4
-
5
3
  module Perfetto
6
4
  # Rack middleware
7
5
  class Middleware
8
6
  def initialize(app, options = {})
9
7
  @app = app
10
8
  @options = options
9
+ @env_proc = options[:env_proc]
11
10
  end
12
11
 
13
- if Perfetto::Configure.enable_tracing
14
- def call(env)
15
- category = "RackMiddleware"
16
- method = env["REQUEST_METHOD"] || "UNKNOWN"
17
- path = env["PATH_INFO"] || "UNKNOWN PATH"
18
- task_name = "#{method} #{path}"
19
- Perfetto.trace_event_begin_with_debug_info category, task_name, "env", env.to_json
20
- begin
21
- @app.call(env)
22
- ensure
23
- Perfetto.trace_event_end category
24
- end
25
- end
26
- else # Stub methods
27
- def call(env)
12
+ # rubocop:disable Metrics/MethodLength
13
+ def perfetto_traced_call(env)
14
+ category = "RackMiddleware"
15
+ method = env["REQUEST_METHOD"] || "UNKNOWN"
16
+ path = env["PATH_INFO"] || "UNKNOWN PATH"
17
+ task_name = "#{method} #{path}"
18
+ env_str = @env_proc&.call(env) || { env: "unknown" }.to_json
19
+
20
+ Perfetto.trace_event_begin_with_debug_info category, task_name, "env", env_str
21
+ begin
28
22
  @app.call(env)
23
+ ensure
24
+ Perfetto.trace_event_end category
29
25
  end
30
26
  end
27
+ # rubocop:enable Metrics/MethodLength
28
+
29
+ def call(env)
30
+ @app.call(env) unless Perfetto::Configure.enable_tracing
31
+
32
+ perfetto_traced_call(env)
33
+ end
31
34
  end
32
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Perfetto
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.8"
5
5
  end
data/lib/perfetto.rb CHANGED
@@ -1,10 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "json"
4
+
3
5
  require_relative "perfetto/version"
4
6
 
5
7
  require_relative "perfetto/core_ext/configurable"
6
8
  require_relative "perfetto/configure"
7
9
 
10
+ # Rack middleware
11
+ require_relative "perfetto/middleware"
12
+
8
13
  # To minimize the overhead of tracing at runtime
9
14
  # we determine whether to enable instrumentations
10
15
  # at the first call to 'setup' method instead of
@@ -20,7 +25,5 @@ module Perfetto
20
25
  require_relative "perfetto/perfetto"
21
26
  # Instrumentation Helper
22
27
  require_relative "perfetto/interceptor"
23
- # Rack middleware
24
- require_relative "perfetto/middleware"
25
28
  end
26
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perfetto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kowalski Dark
@@ -38,7 +38,6 @@ files:
38
38
  - lib/perfetto/middleware.rb
39
39
  - lib/perfetto/perfetto.rb
40
40
  - lib/perfetto/version.rb
41
- - perfetto.gemspec
42
41
  - sig/perfetto.rbs
43
42
  homepage: https://github.com/yet-another-ai/perfetto.rb
44
43
  licenses: []
data/perfetto.gemspec DELETED
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/perfetto/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "perfetto"
7
- spec.version = Perfetto::VERSION
8
- spec.authors = ["Kowalski Dark"]
9
- spec.email = ["github@akenonet.com"]
10
-
11
- spec.summary = "Yet another event tracing library for Ruby."
12
- spec.description = "Yet another event tracing library for Ruby."
13
- spec.homepage = "https://github.com/yet-another-ai/perfetto.rb"
14
- spec.required_ruby_version = ">= 3.3.0"
15
-
16
- spec.metadata["homepage_uri"] = spec.homepage
17
-
18
- # Specify which files should be added to the gem when it is released.
19
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
- spec.files = Dir.chdir(__dir__) do
21
- `git ls-files -z`.split("\x0").reject do |f|
22
- (File.expand_path(f) == __FILE__) ||
23
- f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
24
- end
25
- end
26
- spec.bindir = "exe"
27
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
- spec.require_paths = %w[lib ext]
29
- spec.extensions = ["ext/perfetto/extconf.rb"]
30
-
31
- # For more information and examples about making a new gem, check out our
32
- # guide at: https://bundler.io/guides/creating_gem.html
33
- spec.metadata["rubygems_mfa_required"] = "true"
34
- end