cw-datadog 2.23.0.6 → 2.23.0.8
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/lib/datadog/core/cloudwise/client.rb +32 -0
- data/lib/datadog/core/cloudwise/component.rb +22 -23
- data/lib/datadog/core/cloudwise/docc_app_registration_worker.rb +86 -0
- data/lib/datadog/core/cloudwise/probe_state.rb +6 -7
- data/lib/datadog/core/cloudwise/time_sync_worker.rb +3 -2
- data/lib/datadog/core/configuration/settings.rb +1 -1
- data/lib/datadog/tracing/contrib/cloudwise/propagation.rb +9 -2
- data/lib/datadog/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ad65aab58434d4c3d2ccf8a00d2c728231eaca2369aab6d8fac4293d146d7641
|
|
4
|
+
data.tar.gz: 7e4d9d0fc890f0d6ea2cb11014879f6a86af57f8eb89882fa3cdfc0db1acd3c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ed84231230329b12381aeccf6d3fdaf3b2e24ec250ed86ba9ee6972d254f28ff0db07618807869c468f4409641557515f7e5e8df8e9a776c75e0ae5402ca332
|
|
7
|
+
data.tar.gz: 17566d9b7b129d408dbbf78904c59ce53931070d91ef6528f3b46402de4aa660f2b91ec263cb67293a9d0bb292668ef82597b97c2823792b3b534578fe58817e
|
|
@@ -245,6 +245,38 @@ module Datadog
|
|
|
245
245
|
})
|
|
246
246
|
end
|
|
247
247
|
|
|
248
|
+
# DOCC 模式下的应用注册接口(使用 doop-agent-api 前缀)
|
|
249
|
+
# 在 DOCC 模式下也需要调用 DOOP 模式的应用注册逻辑
|
|
250
|
+
# 接口路径: /doop-agent-api/v2/app/create
|
|
251
|
+
# 调用频率: 每3分钟一次
|
|
252
|
+
def docc_register_application
|
|
253
|
+
host_ip = get_local_ip
|
|
254
|
+
|
|
255
|
+
post('/doop-agent-api/v2/app/create', {
|
|
256
|
+
serviceType: 'RUBY',
|
|
257
|
+
accountId: @token_account_id.to_i,
|
|
258
|
+
hostId: 0,
|
|
259
|
+
agentId: generate_agent_id(host_ip).to_i,
|
|
260
|
+
appId: generate_app_id(server_name).to_i,
|
|
261
|
+
sn: host_ip,
|
|
262
|
+
sport: get_server_port,
|
|
263
|
+
appName: server_name,
|
|
264
|
+
userDirRaw: server_name,
|
|
265
|
+
codeType: 1012,
|
|
266
|
+
app_type: 1,
|
|
267
|
+
vpc: '',
|
|
268
|
+
env_tag: 'default',
|
|
269
|
+
service_tag: 'default',
|
|
270
|
+
version_tag: 'default',
|
|
271
|
+
business_tag: '',
|
|
272
|
+
sys: '',
|
|
273
|
+
host_tag: '{}',
|
|
274
|
+
tags: {},
|
|
275
|
+
service_instance_id: generate_service_instance_id(host_ip).to_i,
|
|
276
|
+
system_uuid: ''
|
|
277
|
+
})
|
|
278
|
+
end
|
|
279
|
+
|
|
248
280
|
# Check if should use integrated mode (DOCC interfaces)
|
|
249
281
|
# 判断是否需要使用融合模式
|
|
250
282
|
# token不为空且integrated_mode=true时启用
|
|
@@ -7,6 +7,7 @@ require_relative 'heartbeat_worker'
|
|
|
7
7
|
require_relative 'license_worker'
|
|
8
8
|
require_relative 'app_registration_worker'
|
|
9
9
|
require_relative 'docc_registration_worker'
|
|
10
|
+
require_relative 'docc_app_registration_worker'
|
|
10
11
|
require_relative 'docc_heartbeat_worker'
|
|
11
12
|
require_relative 'docc_operation_worker'
|
|
12
13
|
require_relative 'time_sync_worker'
|
|
@@ -49,7 +50,8 @@ module Datadog
|
|
|
49
50
|
class Component
|
|
50
51
|
attr_reader :client, :probe_state, :host_id_worker, :heartbeat_worker,
|
|
51
52
|
:license_worker, :app_registration_worker, :logger,
|
|
52
|
-
:docc_registration_worker, :
|
|
53
|
+
:docc_registration_worker, :docc_app_registration_worker,
|
|
54
|
+
:docc_heartbeat_worker, :docc_operation_worker,
|
|
53
55
|
:time_sync_worker
|
|
54
56
|
|
|
55
57
|
# 类级别的单例锁,确保全局只初始化一次
|
|
@@ -158,7 +160,7 @@ module Datadog
|
|
|
158
160
|
Cloudwise.log_debug { 'Starting Application registration worker (3 min interval)...' }
|
|
159
161
|
@app_registration_worker.start
|
|
160
162
|
|
|
161
|
-
# Start License Worker
|
|
163
|
+
# Start License Worker (only in traditional mode)
|
|
162
164
|
Cloudwise.log_debug { 'Starting License verification worker (5 min interval)...' }
|
|
163
165
|
@license_worker.start
|
|
164
166
|
end
|
|
@@ -192,8 +194,8 @@ module Datadog
|
|
|
192
194
|
if @client.use_integrated_mode?
|
|
193
195
|
@docc_heartbeat_worker&.stop(true)
|
|
194
196
|
@docc_registration_worker&.stop(true)
|
|
197
|
+
@docc_app_registration_worker&.stop(true)
|
|
195
198
|
@docc_operation_worker&.stop(true)
|
|
196
|
-
@license_worker&.stop(true)
|
|
197
199
|
Cloudwise.log_debug { 'Cloudwise DOCC component stopped' }
|
|
198
200
|
else
|
|
199
201
|
@host_id_worker&.stop(true)
|
|
@@ -233,8 +235,8 @@ module Datadog
|
|
|
233
235
|
can_collect_data: probe_status[:can_collect_data],
|
|
234
236
|
probe_active: probe_state.active?,
|
|
235
237
|
probe_suspended: probe_state.suspended?,
|
|
236
|
-
license_valid: probe_status[:license_valid],
|
|
237
|
-
license_running: license_worker&.running?,
|
|
238
|
+
license_valid: @client.use_integrated_mode? ? true : probe_status[:license_valid],
|
|
239
|
+
license_running: @client.use_integrated_mode? ? false : license_worker&.running?,
|
|
238
240
|
time_sync_enabled: time_sync_status[:enabled],
|
|
239
241
|
time_sync_offset_ms: time_sync_status[:offset_ms],
|
|
240
242
|
time_sync_running: time_sync_worker&.running?
|
|
@@ -247,6 +249,8 @@ module Datadog
|
|
|
247
249
|
docc_operation_active: probe_status[:docc_operation_active],
|
|
248
250
|
docc_heartbeat_running: docc_heartbeat_worker&.running?,
|
|
249
251
|
docc_registration_running: docc_registration_worker&.running?,
|
|
252
|
+
docc_app_registered: probe_status[:app_registered],
|
|
253
|
+
docc_app_registration_running: docc_app_registration_worker&.running?,
|
|
250
254
|
docc_operation_running: docc_operation_worker&.running?
|
|
251
255
|
)
|
|
252
256
|
else
|
|
@@ -322,22 +326,22 @@ module Datadog
|
|
|
322
326
|
interval: settings.cloudwise.heartbeat_interval
|
|
323
327
|
)
|
|
324
328
|
|
|
325
|
-
# 3. DOCC
|
|
326
|
-
@
|
|
329
|
+
# 3. DOCC App Registration Worker (3 min interval, DOOP prefix)
|
|
330
|
+
@docc_app_registration_worker = DOCCAppRegistrationWorker.new(
|
|
327
331
|
client: client,
|
|
328
332
|
logger: logger,
|
|
329
|
-
probe_state: probe_state
|
|
333
|
+
probe_state: probe_state,
|
|
334
|
+
interval: settings.cloudwise.app_registration_interval
|
|
330
335
|
)
|
|
331
336
|
|
|
332
|
-
# 4.
|
|
333
|
-
@
|
|
337
|
+
# 4. DOCC Operation Worker (30s interval)
|
|
338
|
+
@docc_operation_worker = DOCCOperationWorker.new(
|
|
334
339
|
client: client,
|
|
335
340
|
logger: logger,
|
|
336
|
-
probe_state: probe_state
|
|
337
|
-
interval: settings.cloudwise.license_check_interval
|
|
341
|
+
probe_state: probe_state
|
|
338
342
|
)
|
|
339
343
|
|
|
340
|
-
# 5. Time Sync Worker (3 min interval
|
|
344
|
+
# 5. Time Sync Worker (3 min interval)
|
|
341
345
|
@time_sync_worker = TimeSyncWorker.new(
|
|
342
346
|
client: client,
|
|
343
347
|
logger: logger,
|
|
@@ -421,11 +425,11 @@ module Datadog
|
|
|
421
425
|
end
|
|
422
426
|
|
|
423
427
|
# Start DOCC workers in background
|
|
424
|
-
# DOCC
|
|
428
|
+
# DOCC 模式启动流程(不需要 License 校验):
|
|
425
429
|
# 1. 启动 DOCC 心跳 worker
|
|
426
430
|
# 2. 等待第一次心跳成功
|
|
427
431
|
# 3. 启动 DOCC 注册 worker
|
|
428
|
-
# 4. 启动
|
|
432
|
+
# 4. 启动 App Registration worker (DOOP prefix, 3 min interval)
|
|
429
433
|
# 5. 启动 Time Sync worker (3 min interval)
|
|
430
434
|
# 6. 启动 DOCC 操作 worker
|
|
431
435
|
def start_docc_workers_when_ready
|
|
@@ -451,15 +455,10 @@ module Datadog
|
|
|
451
455
|
@docc_registration_worker.start
|
|
452
456
|
|
|
453
457
|
# ============================================================
|
|
454
|
-
# STEP 3: Start
|
|
458
|
+
# STEP 3: Start App Registration worker (DOOP prefix)
|
|
455
459
|
# ============================================================
|
|
456
|
-
Cloudwise.log_debug { 'Cloudwise docc: Starting
|
|
457
|
-
@
|
|
458
|
-
|
|
459
|
-
# Wait for first successful license validation
|
|
460
|
-
until probe_state.license_valid?
|
|
461
|
-
sleep(1)
|
|
462
|
-
end
|
|
460
|
+
Cloudwise.log_debug { 'Cloudwise docc: Starting application registration worker (DOOP prefix)...' }
|
|
461
|
+
@docc_app_registration_worker.start
|
|
463
462
|
|
|
464
463
|
# ============================================================
|
|
465
464
|
# STEP 4: Start Time Sync worker (3 min interval)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../worker'
|
|
4
|
+
require_relative '../workers/async'
|
|
5
|
+
require_relative '../workers/polling'
|
|
6
|
+
|
|
7
|
+
module Datadog
|
|
8
|
+
module Core
|
|
9
|
+
module Cloudwise
|
|
10
|
+
# Worker that registers application in DOCC mode using DOOP prefix
|
|
11
|
+
# DOCC 模式下调用 DOOP 的应用注册逻辑
|
|
12
|
+
# 接口路径: /doop-agent-api/v2/app/create
|
|
13
|
+
# 应用注册失败不影响数据采集
|
|
14
|
+
class DOCCAppRegistrationWorker < Worker
|
|
15
|
+
include Workers::Polling
|
|
16
|
+
|
|
17
|
+
# 3 minutes interval
|
|
18
|
+
DEFAULT_INTERVAL = 180
|
|
19
|
+
# 成功的状态码
|
|
20
|
+
CODE_SUCCESS = 1000
|
|
21
|
+
|
|
22
|
+
attr_reader :client
|
|
23
|
+
|
|
24
|
+
def initialize(client:, logger:, probe_state:, **options)
|
|
25
|
+
@client = client
|
|
26
|
+
@logger = logger
|
|
27
|
+
@probe_state = probe_state
|
|
28
|
+
@registration_successful = false
|
|
29
|
+
|
|
30
|
+
# Workers::Async::Thread settings
|
|
31
|
+
self.fork_policy = options.fetch(:fork_policy, Workers::Async::Thread::FORK_POLICY_STOP)
|
|
32
|
+
|
|
33
|
+
# Workers::IntervalLoop settings
|
|
34
|
+
self.loop_base_interval = options.fetch(:interval, DEFAULT_INTERVAL)
|
|
35
|
+
|
|
36
|
+
self.enabled = options.fetch(:enabled, true)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def perform
|
|
40
|
+
Cloudwise.log_debug { 'Cloudwise DOCC: Registering application (DOOP prefix)' }
|
|
41
|
+
|
|
42
|
+
result = client.docc_register_application
|
|
43
|
+
|
|
44
|
+
process_registration_result(result)
|
|
45
|
+
|
|
46
|
+
true
|
|
47
|
+
rescue => e
|
|
48
|
+
Cloudwise.log_error { "Cloudwise DOCC: Application registration worker error: #{e.class.name} #{e.message}" }
|
|
49
|
+
@probe_state.mark_app_unregistered!
|
|
50
|
+
true # Continue running
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def registered?
|
|
54
|
+
@registration_successful
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Public method to start the worker
|
|
58
|
+
def start
|
|
59
|
+
return false if !enabled? || started?
|
|
60
|
+
|
|
61
|
+
# Start the async worker thread
|
|
62
|
+
perform
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
attr_reader :logger, :probe_state
|
|
68
|
+
|
|
69
|
+
def process_registration_result(result)
|
|
70
|
+
# 接口请求成功且 code == 1000
|
|
71
|
+
if result[:success] && result[:code] == CODE_SUCCESS
|
|
72
|
+
@registration_successful = true
|
|
73
|
+
Cloudwise.log_debug { 'Cloudwise DOCC: Application registration successful (DOOP prefix)' }
|
|
74
|
+
probe_state.mark_app_registered!
|
|
75
|
+
else
|
|
76
|
+
@registration_successful = false
|
|
77
|
+
error_msg = result[:error] || "code=#{result[:code]}"
|
|
78
|
+
Cloudwise.log_warn { "Cloudwise DOCC: Application registration failed: #{error_msg}, will retry in #{DEFAULT_INTERVAL}s" }
|
|
79
|
+
Cloudwise.log_warn { 'Cloudwise DOCC: Note - Registration failure does NOT affect data collection' }
|
|
80
|
+
probe_state.mark_app_unregistered!
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -13,7 +13,7 @@ module Datadog
|
|
|
13
13
|
# 初始状态:所有条件都未满足,探针不活跃
|
|
14
14
|
@host_id_ready = false # Host ID 是否已生成
|
|
15
15
|
@heartbeat_active = false # 心跳是否正常
|
|
16
|
-
@license_valid = false # License
|
|
16
|
+
@license_valid = false # License 是否校验通过(仅传统模式使用,DOCC 模式忽略)
|
|
17
17
|
@app_registered = false # 应用是否已注册(注册失败不影响采集)
|
|
18
18
|
|
|
19
19
|
# 融合模式状态
|
|
@@ -61,7 +61,7 @@ module Datadog
|
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
# License
|
|
64
|
+
# License 相关(仅传统模式使用,DOCC 模式下不需要 License 校验)
|
|
65
65
|
def mark_license_valid!
|
|
66
66
|
@mutex.synchronize do
|
|
67
67
|
return if @license_valid
|
|
@@ -163,12 +163,12 @@ module Datadog
|
|
|
163
163
|
end
|
|
164
164
|
|
|
165
165
|
# 探针是否可以采集数据
|
|
166
|
-
# 如果使用 DOCC 模式:需要 DOCC 心跳 +
|
|
166
|
+
# 如果使用 DOCC 模式:需要 DOCC 心跳 + Operation 都正常(不需要 License)
|
|
167
167
|
# 如果使用传统模式:需要 Host ID + 心跳 + License 都正常
|
|
168
168
|
def can_collect_data?
|
|
169
169
|
@mutex.synchronize do
|
|
170
170
|
if @use_docc_mode
|
|
171
|
-
@docc_heartbeat_active && @
|
|
171
|
+
@docc_heartbeat_active && @docc_operation_active
|
|
172
172
|
else
|
|
173
173
|
@host_id_ready && @heartbeat_active && @license_valid
|
|
174
174
|
end
|
|
@@ -233,7 +233,7 @@ module Datadog
|
|
|
233
233
|
docc_registered: @docc_registered,
|
|
234
234
|
docc_heartbeat_active: @docc_heartbeat_active,
|
|
235
235
|
docc_operation_active: @docc_operation_active,
|
|
236
|
-
can_collect_data: @docc_heartbeat_active && @
|
|
236
|
+
can_collect_data: @docc_heartbeat_active && @docc_operation_active
|
|
237
237
|
)
|
|
238
238
|
else
|
|
239
239
|
base_status.merge(
|
|
@@ -252,12 +252,11 @@ module Datadog
|
|
|
252
252
|
# 直接读取实例变量,避免递归锁定(不调用 can_collect_data? 方法)
|
|
253
253
|
if @use_docc_mode
|
|
254
254
|
# DOCC 模式状态日志
|
|
255
|
-
if @docc_heartbeat_active && @
|
|
255
|
+
if @docc_heartbeat_active && @docc_operation_active
|
|
256
256
|
Cloudwise.log_debug { 'Cloudwise DOCC: Probe ACTIVE - data collection enabled' }
|
|
257
257
|
else
|
|
258
258
|
reasons = []
|
|
259
259
|
reasons << 'DOCC Heartbeat inactive' unless @docc_heartbeat_active
|
|
260
|
-
reasons << 'License invalid' unless @license_valid
|
|
261
260
|
reasons << 'Agent stopped by operation' unless @docc_operation_active
|
|
262
261
|
|
|
263
262
|
Cloudwise.log_debug { "Cloudwise DOCC: Probe SUSPENDED - data collection disabled (#{reasons.join(", ")})" }
|
|
@@ -128,8 +128,9 @@ module Datadog
|
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
def perform
|
|
131
|
-
#
|
|
132
|
-
|
|
131
|
+
# 传统模式下,只有在 License 校验通过后才执行时间同步
|
|
132
|
+
# DOCC 模式下不需要 License 校验
|
|
133
|
+
unless probe_state.using_docc_mode? || probe_state.license_valid?
|
|
133
134
|
Cloudwise.log_debug { 'Cloudwise: Waiting for license validation before time sync' }
|
|
134
135
|
return true
|
|
135
136
|
end
|
|
@@ -1071,7 +1071,7 @@ module Datadog
|
|
|
1071
1071
|
o.default 30
|
|
1072
1072
|
end
|
|
1073
1073
|
|
|
1074
|
-
# License check interval in seconds (5 minutes)
|
|
1074
|
+
# License check interval in seconds (5 minutes, 仅传统模式使用,DOCC 模式不需要 License 校验)
|
|
1075
1075
|
# @default `DD_CLOUDWISE_LICENSE_CHECK_INTERVAL` environment variable, otherwise `300`
|
|
1076
1076
|
# @return [Integer]
|
|
1077
1077
|
option :license_check_interval do |o|
|
|
@@ -91,8 +91,15 @@ module Datadog
|
|
|
91
91
|
host_id = get_host_id
|
|
92
92
|
app_id = generate_app_id(service_name)
|
|
93
93
|
instance_id = get_instance_id
|
|
94
|
-
#
|
|
95
|
-
|
|
94
|
+
# 如果上游传递了 trace_id_from(例如 Java1 -> Ruby -> Java2),
|
|
95
|
+
# 则使用上游的 trace_id_from 作为透传的 trace_id,保持端到端追踪链路一致
|
|
96
|
+
# 否则使用本服务的低 64 位 trace_id
|
|
97
|
+
upstream_trace_id = trace.get_tag('trace_id_from')
|
|
98
|
+
trace_id = if upstream_trace_id && !upstream_trace_id.empty? && upstream_trace_id != '-1'
|
|
99
|
+
upstream_trace_id
|
|
100
|
+
else
|
|
101
|
+
Tracing::Utils::TraceId.to_low_order(trace.id).to_s
|
|
102
|
+
end
|
|
96
103
|
assumed_app_id = generate_assumed_app_id(target_url)
|
|
97
104
|
span_id = span.id.to_s
|
|
98
105
|
segment_id = get_segment_id(span)
|
data/lib/datadog/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cw-datadog
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.23.0.
|
|
4
|
+
version: 2.23.0.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Datadog, Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-05-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: msgpack
|
|
@@ -303,6 +303,7 @@ files:
|
|
|
303
303
|
- lib/datadog/core/cloudwise/app_registration_worker.rb
|
|
304
304
|
- lib/datadog/core/cloudwise/client.rb
|
|
305
305
|
- lib/datadog/core/cloudwise/component.rb
|
|
306
|
+
- lib/datadog/core/cloudwise/docc_app_registration_worker.rb
|
|
306
307
|
- lib/datadog/core/cloudwise/docc_heartbeat_worker.rb
|
|
307
308
|
- lib/datadog/core/cloudwise/docc_operation_worker.rb
|
|
308
309
|
- lib/datadog/core/cloudwise/docc_registration_worker.rb
|
|
@@ -1095,8 +1096,8 @@ licenses:
|
|
|
1095
1096
|
- Apache-2.0
|
|
1096
1097
|
metadata:
|
|
1097
1098
|
allowed_push_host: https://rubygems.org
|
|
1098
|
-
changelog_uri: https://github.com/DataDog/dd-trace-rb/blob/v2.23.0.
|
|
1099
|
-
source_code_uri: https://github.com/DataDog/dd-trace-rb/tree/v2.23.0.
|
|
1099
|
+
changelog_uri: https://github.com/DataDog/dd-trace-rb/blob/v2.23.0.8/CHANGELOG.md
|
|
1100
|
+
source_code_uri: https://github.com/DataDog/dd-trace-rb/tree/v2.23.0.8
|
|
1100
1101
|
post_install_message:
|
|
1101
1102
|
rdoc_options: []
|
|
1102
1103
|
require_paths:
|