datarobot_genai.core.telemetry.datarobot_otel
datarobot_otel
DataRobot OTel ingest endpoint helpers.
Two responsibilities, intentionally co-located so a single import covers
both the NAT telemetry exporter
(datarobot_genai.dragent.plugins.datarobot_otelcollector) and
the framework-instrumentor bootstrap (datarobot_genai.core.telemetry.agent):
resolve_*_from_env— readMLOPS_DEPLOYMENT_ID/WORKLOAD_ID/DATAROBOT_API_TOKEN/DATAROBOT_(PUBLIC_)ENDPOINTand shape them into the values the OTel ingest expects (deployment-<id>orworkload-<id>entity id;<host>/otel/v1/tracesendpoint).bootstrap_otel_provider_for_datarobot— install a global OTel SDKTracerProviderpointed at the DataRobot ingest so framework auto-instrumentors actually export spans.
bootstrap_otel_provider_for_datarobot
Ensure framework auto-instrumentor spans reach the DataRobot OTel ingest.
Sibling to (not replacing) the NAT-side datarobot_otelcollector exporter:
NAT pipes its own IntermediateStep-derived spans through its own
channel; this path serves framework auto-instrumentors that emit spans
through the OTel SDK's standard trace.get_tracer(...) API.
Two modes, picked at call time based on what's already in the global
TracerProvider slot:
- install — slot still holds the default
ProxyTracerProvider: we create a new SDKTracerProviderwith the DataRobot exporter and set it globally. - attach — slot already holds an SDK
TracerProvider(e.g. thedragent_fastapiserver's startup telemetry layer installs one before NAT plugin discovery happens): we add our own span processor to it instead of replacing it. The pre-existing provider's resource (including itsservice.name) is kept — DataRobot's OTel ingest routes off theX-DataRobot-*headers we set on the exporter, not off resource attributes, so the merge is safe.
Entity identity is derived from MLOPS_DEPLOYMENT_ID or WORKLOAD_ID
(deployment takes precedence).
Returns True when a processor was installed or attached by this call,
False (silently) when:
- the hosted-runtime env is incomplete (
MLOPS_DEPLOYMENT_IDorWORKLOAD_ID,DATAROBOT_API_TOKEN, orDATAROBOT_(PUBLIC_)ENDPOINTmissing) — the local-dev / CI shape; - something other than an SDK
TracerProvideror the default proxy is already installed (we can't attach to an unknown provider type); - this function has already run successfully in this process.
Source code in datarobot_genai/core/telemetry/datarobot_otel.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | |