|
18 | 18 | #include "context.h" |
19 | 19 | #include "guards.h" |
20 | 20 | #include "otel_context.h" |
21 | | -#include "otel_process_ctx.h" |
22 | 21 | #include "profiler.h" |
23 | 22 | #include "thread.h" |
24 | 23 | #include <cstring> |
25 | 24 |
|
26 | | -// Reserved attribute index for local root span ID in OTEL attrs_data. |
27 | | -// Only used within this translation unit; not part of the public ContextApi header. |
28 | | -static const uint8_t LOCAL_ROOT_SPAN_ATTR_INDEX = 0; |
29 | | - |
30 | 25 | /** |
31 | 26 | * Initialize context TLS for the current thread on first use. |
32 | 27 | * Must be called with signals blocked to prevent musl TLS deadlock: |
@@ -71,55 +66,3 @@ Context ContextApi::snapshot() { |
71 | 66 | size_t numAttrs = Profiler::instance()->numContextAttributes(); |
72 | 67 | return thrd->snapshotContext(numAttrs); |
73 | 68 | } |
74 | | - |
75 | | -void ContextApi::registerAttributeKeys(const char** keys, int count) { |
76 | | - // Clip to DD_TAGS_CAPACITY: that is the actual sidecar slot limit and the |
77 | | - // maximum keyIndex accepted by ThreadContext.setContextAttribute. |
78 | | - int n = count < (int)DD_TAGS_CAPACITY ? count : (int)DD_TAGS_CAPACITY; |
79 | | - |
80 | | - // Build NULL-terminated key array for the process context config. |
81 | | - // Index LOCAL_ROOT_SPAN_ATTR_INDEX (0) is reserved for local_root_span_id; user keys start at index 1. |
82 | | - // otel_process_ctx_publish copies all strings, so no strdup is needed. |
83 | | - const char* key_ptrs[DD_TAGS_CAPACITY + 2]; // +1 reserved, +1 null |
84 | | - key_ptrs[LOCAL_ROOT_SPAN_ATTR_INDEX] = "datadog.local_root_span_id"; |
85 | | - for (int i = 0; i < n; i++) { |
86 | | - key_ptrs[i + 1] = keys[i]; |
87 | | - } |
88 | | - key_ptrs[n + 1] = nullptr; |
89 | | - |
90 | | - otel_thread_ctx_config_data config = { |
91 | | - .schema_version = "tlsdesc_v1_dev", |
92 | | - .attribute_key_map = key_ptrs, |
93 | | - }; |
94 | | - |
95 | | -#ifndef OTEL_PROCESS_CTX_NO_READ |
96 | | - otel_process_ctx_read_result read_result = otel_process_ctx_read(); |
97 | | - if (read_result.success) { |
98 | | - otel_process_ctx_data data = { |
99 | | - .deployment_environment_name = read_result.data.deployment_environment_name, |
100 | | - .service_instance_id = read_result.data.service_instance_id, |
101 | | - .service_name = read_result.data.service_name, |
102 | | - .service_version = read_result.data.service_version, |
103 | | - .telemetry_sdk_language = read_result.data.telemetry_sdk_language, |
104 | | - .telemetry_sdk_version = read_result.data.telemetry_sdk_version, |
105 | | - .telemetry_sdk_name = read_result.data.telemetry_sdk_name, |
106 | | - .resource_attributes = read_result.data.resource_attributes, |
107 | | - .extra_attributes = read_result.data.extra_attributes, |
108 | | - .thread_ctx_config = &config, |
109 | | - }; |
110 | | - |
111 | | - otel_process_ctx_publish(&data); |
112 | | - otel_process_ctx_read_drop(&read_result); |
113 | | - } |
114 | | -#endif |
115 | | -} |
116 | | - |
117 | | -void ContextApi::registerAttributeKeys(const std::vector<std::string>& keys) { |
118 | | - // Clip to DD_TAGS_CAPACITY before materializing C string pointers. |
119 | | - size_t n = keys.size() < DD_TAGS_CAPACITY ? keys.size() : DD_TAGS_CAPACITY; |
120 | | - const char* key_ptrs[DD_TAGS_CAPACITY]; |
121 | | - for (size_t i = 0; i < n; i++) { |
122 | | - key_ptrs[i] = keys[i].c_str(); |
123 | | - } |
124 | | - registerAttributeKeys(key_ptrs, (int)n); |
125 | | -} |
0 commit comments