bitfab 0.51.8 → 0.51.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/bitfab/client.rb +14 -4
- data/lib/bitfab/constants.rb +1 -0
- data/lib/bitfab/env.rb +27 -0
- data/lib/bitfab/version.rb +1 -1
- data/lib/bitfab.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f468d991f207bab17dbf93e1d8336e293aa2d759a83a31a8eee7631f1e93daa8
|
|
4
|
+
data.tar.gz: 4ab69ab42011952d9611a3708ed9f4308760aeb839eaa109ba413a798d5c59d4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fcd27044d500aa10fb278940b3665cd54e27c2732e011e828bdd778dc598807960ae84686968957d48fd279f26dc93e2ff72cc1c8ccfa8a91824235548f0b394
|
|
7
|
+
data.tar.gz: 5c3c831e7c6e30e5ea9f8aaa2a5d63f55f561c831e57caa87504a86b7d73cfc62a98260c943f4024b664c9d6a419bb0b2727e83952dc10f0f62ba4bdb3b496ad
|
data/README.md
CHANGED
|
@@ -72,7 +72,7 @@ Bitfab.configure(
|
|
|
72
72
|
|
|
73
73
|
### Disabling Span Sending
|
|
74
74
|
|
|
75
|
-
The `enabled` option controls whether spans are sent to Bitfab. When disabled, your code executes normally but no spans are created or sent.
|
|
75
|
+
The `enabled` option controls whether spans are sent to Bitfab. When disabled, your code executes normally but no spans are created or sent. Leave it out and `BITFAB_CAPTURE_ENABLED` decides: `1`, `true`, or `yes` sends spans, `0`, `false`, or `no` stops them, and sending stays on when the variable is unset.
|
|
76
76
|
|
|
77
77
|
```ruby
|
|
78
78
|
# Disable tracing (useful for development/test environments)
|
|
@@ -91,10 +91,10 @@ Bitfab.configure(
|
|
|
91
91
|
enabled: Rails.env.production?
|
|
92
92
|
)
|
|
93
93
|
|
|
94
|
-
# Environment variable control
|
|
94
|
+
# Environment variable control: leave enabled: out and set BITFAB_CAPTURE_ENABLED
|
|
95
|
+
# to 0 or 1 in the environment. Anything passed here wins over it.
|
|
95
96
|
Bitfab.configure(
|
|
96
|
-
api_key: ENV.fetch('BITFAB_API_KEY', 'dummy-key')
|
|
97
|
-
enabled: ENV.fetch('BITFAB_ENABLED', 'false') == 'true'
|
|
97
|
+
api_key: ENV.fetch('BITFAB_API_KEY', 'dummy-key')
|
|
98
98
|
)
|
|
99
99
|
|
|
100
100
|
# Multi-environment control
|
data/lib/bitfab/client.rb
CHANGED
|
@@ -4,6 +4,7 @@ require "securerandom"
|
|
|
4
4
|
require "time"
|
|
5
5
|
|
|
6
6
|
require_relative "constants"
|
|
7
|
+
require_relative "env"
|
|
7
8
|
require_relative "http_client"
|
|
8
9
|
require_relative "replay"
|
|
9
10
|
require_relative "span_context"
|
|
@@ -37,11 +38,12 @@ module Bitfab
|
|
|
37
38
|
# Trace lookup operations for the authenticated organization.
|
|
38
39
|
attr_reader :traces
|
|
39
40
|
|
|
40
|
-
def initialize(api_key: nil, service_url: nil, enabled:
|
|
41
|
+
def initialize(api_key: nil, service_url: nil, enabled: nil, strict: false)
|
|
41
42
|
@api_key_config = api_key
|
|
42
43
|
@service_url = service_url || DEFAULT_SERVICE_URL
|
|
43
44
|
# The user's on/off intent; effective enabled also requires a resolved key.
|
|
44
|
-
@
|
|
45
|
+
@enabled_in_code = enabled
|
|
46
|
+
@capture_configured_from_env = nil
|
|
45
47
|
@strict = strict
|
|
46
48
|
# Cached only once a non-empty key is found, so an early resolve (before
|
|
47
49
|
# env loaded) can't poison a later one.
|
|
@@ -654,17 +656,25 @@ module Bitfab
|
|
|
654
656
|
"Bitfab.configure. If a script loads env later, load it before the first " \
|
|
655
657
|
"traced call, or pass api_key: -> { ENV[\"BITFAB_API_KEY\"] }."
|
|
656
658
|
end
|
|
657
|
-
if
|
|
659
|
+
if capture_configured? && !@api_key_warned
|
|
658
660
|
@api_key_warned = true
|
|
659
661
|
warn("Bitfab: api_key is empty: tracing is disabled. Provide a valid API key to enable tracing.")
|
|
660
662
|
end
|
|
661
663
|
nil
|
|
662
664
|
end
|
|
663
665
|
|
|
666
|
+
def capture_configured?
|
|
667
|
+
return @enabled_in_code unless @enabled_in_code.nil?
|
|
668
|
+
return @capture_configured_from_env unless @capture_configured_from_env.nil?
|
|
669
|
+
|
|
670
|
+
from_env = Bitfab.read_boolean_env(CAPTURE_ENABLED_ENV)
|
|
671
|
+
@capture_configured_from_env = from_env.nil? || from_env
|
|
672
|
+
end
|
|
673
|
+
|
|
664
674
|
# Whether tracing should run, decided lazily at call time. An explicit
|
|
665
675
|
# `enabled: false` short-circuits without ever touching the key.
|
|
666
676
|
def tracing_enabled?
|
|
667
|
-
return false unless
|
|
677
|
+
return false unless capture_configured?
|
|
668
678
|
|
|
669
679
|
!resolve_api_key.nil?
|
|
670
680
|
end
|
data/lib/bitfab/constants.rb
CHANGED
data/lib/bitfab/env.rb
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "warn_once"
|
|
4
|
+
|
|
5
|
+
module Bitfab
|
|
6
|
+
TRUE_ENV_VALUES = %w[1 true yes].freeze
|
|
7
|
+
FALSE_ENV_VALUES = %w[0 false no].freeze
|
|
8
|
+
private_constant :TRUE_ENV_VALUES, :FALSE_ENV_VALUES
|
|
9
|
+
|
|
10
|
+
class << self
|
|
11
|
+
def read_boolean_env(name)
|
|
12
|
+
raw = ENV[name]
|
|
13
|
+
return nil if raw.nil?
|
|
14
|
+
|
|
15
|
+
value = raw.strip.downcase
|
|
16
|
+
return nil if value.empty?
|
|
17
|
+
return true if TRUE_ENV_VALUES.include?(value)
|
|
18
|
+
return false if FALSE_ENV_VALUES.include?(value)
|
|
19
|
+
|
|
20
|
+
warn_once(
|
|
21
|
+
"unrecognized-boolean-env:#{name}",
|
|
22
|
+
"#{name}=\"#{raw}\" is not 0 or 1; ignoring it."
|
|
23
|
+
)
|
|
24
|
+
nil
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
data/lib/bitfab/version.rb
CHANGED
data/lib/bitfab.rb
CHANGED
|
@@ -79,7 +79,7 @@ module Bitfab
|
|
|
79
79
|
# @example
|
|
80
80
|
# Bitfab.configure(api_key: ENV["BITFAB_API_KEY"])
|
|
81
81
|
#
|
|
82
|
-
def configure(api_key: nil, service_url: nil, enabled:
|
|
82
|
+
def configure(api_key: nil, service_url: nil, enabled: nil, strict: false)
|
|
83
83
|
@client = Client.new(api_key:, service_url:, enabled:, strict:)
|
|
84
84
|
end
|
|
85
85
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bitfab
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.51.
|
|
4
|
+
version: 0.51.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Harvest Team
|
|
@@ -145,6 +145,7 @@ files:
|
|
|
145
145
|
- lib/bitfab/constants.rb
|
|
146
146
|
- lib/bitfab/datasets.rb
|
|
147
147
|
- lib/bitfab/db_snapshot.rb
|
|
148
|
+
- lib/bitfab/env.rb
|
|
148
149
|
- lib/bitfab/git_command.rb
|
|
149
150
|
- lib/bitfab/git_state.rb
|
|
150
151
|
- lib/bitfab/http_client.rb
|