obtrace 1.0.0 → 2.0.0
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/obtrace_sdk/client.rb +2 -2
- data/lib/obtrace_sdk/rails.rb +5 -4
- data/lib/obtrace_sdk/types.rb +1 -1
- data/lib/obtrace_sdk/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dd0f90f3f695937c398b35ba072b0f30ee1cc217b23d2646af7cf8383c7b6f0a
|
|
4
|
+
data.tar.gz: b7842067d7dffdc388c1d7e8ff300aa0b752d717e577dbac9c5cae30dc85c0f8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d2345a6af6153804bf704ca02dac369de23554b8edd5d44d1f7451a50cd2421f306a42b7c0c2c55c735783057742aa5066a8ad7585a20814505c05f628a71aaf
|
|
7
|
+
data.tar.gz: 4cd706438e9399ca8e944ef178c29ac642395a420d1120330c48610cd5a27fa2e6f75eee71a02f5b9c74ccb44e9e54762144ce567c1c68e4ecf50bcf6556007a
|
data/README.md
CHANGED
|
@@ -29,9 +29,11 @@ require_relative "lib/obtrace_sdk"
|
|
|
29
29
|
|
|
30
30
|
Required:
|
|
31
31
|
- `api_key`
|
|
32
|
-
- `ingest_base_url`
|
|
33
32
|
- `service_name`
|
|
34
33
|
|
|
34
|
+
Optional (defaults to `https://ingest.obtrace.ai`):
|
|
35
|
+
- `ingest_base_url`
|
|
36
|
+
|
|
35
37
|
Optional (auto-resolved from API key on the server side):
|
|
36
38
|
- `tenant_id`
|
|
37
39
|
- `project_id`
|
|
@@ -43,14 +45,13 @@ Optional (auto-resolved from API key on the server side):
|
|
|
43
45
|
|
|
44
46
|
### Simplified setup
|
|
45
47
|
|
|
46
|
-
The API key resolves `tenant_id`, `project_id`, `app_id`, and `env` automatically on the server side, so only
|
|
48
|
+
The API key resolves `tenant_id`, `project_id`, `app_id`, and `env` automatically on the server side, so only two fields are needed:
|
|
47
49
|
|
|
48
50
|
```ruby
|
|
49
51
|
require "obtrace_sdk"
|
|
50
52
|
|
|
51
53
|
cfg = ObtraceSDK::Config.new(
|
|
52
54
|
api_key: "obt_live_...",
|
|
53
|
-
ingest_base_url: "https://ingest.obtrace.io",
|
|
54
55
|
service_name: "my-service"
|
|
55
56
|
)
|
|
56
57
|
|
|
@@ -66,7 +67,6 @@ require_relative "lib/obtrace_sdk"
|
|
|
66
67
|
|
|
67
68
|
cfg = ObtraceSDK::Config.new(
|
|
68
69
|
api_key: "<API_KEY>",
|
|
69
|
-
ingest_base_url: "https://inject.obtrace.ai",
|
|
70
70
|
service_name: "ruby-api"
|
|
71
71
|
)
|
|
72
72
|
|
data/lib/obtrace_sdk/client.rb
CHANGED
|
@@ -15,7 +15,7 @@ module ObtraceSDK
|
|
|
15
15
|
return
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
raise ArgumentError, "api_key
|
|
18
|
+
raise ArgumentError, "api_key and service_name are required" if cfg.api_key.to_s.empty? || cfg.service_name.to_s.empty?
|
|
19
19
|
|
|
20
20
|
@@initialized = true
|
|
21
21
|
@cfg = cfg
|
|
@@ -40,7 +40,7 @@ module ObtraceSDK
|
|
|
40
40
|
uri = URI("#{base}/v1/init")
|
|
41
41
|
payload = JSON.generate({
|
|
42
42
|
sdk: "obtrace-sdk-ruby",
|
|
43
|
-
sdk_version: "
|
|
43
|
+
sdk_version: "2.0.0",
|
|
44
44
|
service_name: @cfg.service_name,
|
|
45
45
|
service_version: @cfg.service_version.to_s,
|
|
46
46
|
runtime: "ruby",
|
data/lib/obtrace_sdk/rails.rb
CHANGED
|
@@ -4,21 +4,22 @@ module ObtraceSDK
|
|
|
4
4
|
class Railtie < ::Rails::Railtie
|
|
5
5
|
config.after_initialize do |app|
|
|
6
6
|
api_key = Railtie.credentials_fetch("obtrace_api_key") || ENV["OBTRACE_API_KEY"]
|
|
7
|
-
ingest_url = Railtie.credentials_fetch("obtrace_ingest_url") || ENV["OBTRACE_INGEST_BASE_URL"]
|
|
7
|
+
ingest_url = Railtie.credentials_fetch("obtrace_ingest_url") || ENV["OBTRACE_INGEST_BASE_URL"]
|
|
8
8
|
service_name = Railtie.credentials_fetch("obtrace_service_name") || ENV["OBTRACE_SERVICE_NAME"] || ::Rails.application.class.module_parent_name.underscore rescue "rails-app"
|
|
9
9
|
|
|
10
10
|
next unless api_key
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
opts = {
|
|
13
13
|
api_key: api_key,
|
|
14
|
-
ingest_base_url: ingest_url,
|
|
15
14
|
service_name: service_name,
|
|
16
15
|
env: ::Rails.env.to_s,
|
|
17
16
|
tenant_id: Railtie.credentials_fetch("obtrace_tenant_id") || ENV["OBTRACE_TENANT_ID"],
|
|
18
17
|
project_id: Railtie.credentials_fetch("obtrace_project_id") || ENV["OBTRACE_PROJECT_ID"],
|
|
19
18
|
app_id: Railtie.credentials_fetch("obtrace_app_id") || ENV["OBTRACE_APP_ID"],
|
|
20
19
|
debug: ENV["OBTRACE_DEBUG"] == "true"
|
|
21
|
-
|
|
20
|
+
}
|
|
21
|
+
opts[:ingest_base_url] = ingest_url if ingest_url
|
|
22
|
+
cfg = ObtraceSDK::Config.new(**opts)
|
|
22
23
|
|
|
23
24
|
client = ObtraceSDK::Client.new(cfg)
|
|
24
25
|
ObtraceSDK.instance_variable_set(:@rails_client, client)
|
data/lib/obtrace_sdk/types.rb
CHANGED
|
@@ -4,7 +4,7 @@ module ObtraceSDK
|
|
|
4
4
|
attr_accessor :service_name, :service_version, :request_timeout_sec
|
|
5
5
|
attr_accessor :default_headers, :debug, :validate_semantic_metrics
|
|
6
6
|
|
|
7
|
-
def initialize(api_key:,
|
|
7
|
+
def initialize(api_key:, service_name:, ingest_base_url: "https://ingest.obtrace.ai", tenant_id: nil, project_id: nil, app_id: nil, env: "dev", service_version: "1.0.0", request_timeout_sec: 5, default_headers: {}, validate_semantic_metrics: false, debug: false)
|
|
8
8
|
@api_key = api_key
|
|
9
9
|
@ingest_base_url = ingest_base_url
|
|
10
10
|
@tenant_id = tenant_id
|
data/lib/obtrace_sdk/version.rb
CHANGED