datarobot_genai.core.telemetry.datarobot_otel
datarobot_otel
DataRobot OTel ingest endpoint helpers.
Three 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/tracesor<host>/otel/v1/metricsendpoint).bootstrap_otel_provider_for_datarobot— install a global OTel SDKTracerProviderpointed at the DataRobot ingest so framework auto-instrumentors actually export spans.bootstrap_otel_meter_provider_for_datarobot— same, for metrics: without it,datarobot_dome(moderations) guard metrics record through the OTel SDK's no-op defaultMeterProviderand are silently dropped, since nothing else in this SDK's bootstrap path ever installs a real one.
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
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 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
bootstrap_otel_meter_provider_for_datarobot
Ensure datarobot_dome (moderations) guard metrics reach the DataRobot OTel ingest.
OtelMetricSession defers to the OTel SDK's global MeterProvider
(get_meter_provider()) whenever none is passed explicitly - but unlike
traces, nothing else in this SDK's bootstrap path ever installs one. Left
unfixed, every guard metric records through the SDK's no-op default meter
and is silently dropped before it ever reaches an exporter.
Same install-only shape as bootstrap_otel_provider_for_datarobot, with
one real difference: there is no "attach" mode here. A TracerProvider
can take an additional span processor after construction; an SDK
MeterProvider's metric readers are constructor-only and immutable
once built, so if an SDK MeterProvider is already installed globally
when this runs, we can't add our exporter to it and skip instead - the
same fail-safe behavior as an unrecognized provider type on the trace side.
Returns True when a provider was installed by this call, False
(silently) when the hosted-runtime env is incomplete, an SDK
MeterProvider is already installed, or this has already run once in
this process.
Source code in datarobot_genai/core/telemetry/datarobot_otel.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |