Skip to content

Add OTel spans to model artifact loading#2244

Merged
ecarrara merged 4 commits intomainfrom
erle/otel-model-artifacts-tracing
Apr 20, 2026
Merged

Add OTel spans to model artifact loading#2244
ecarrara merged 4 commits intomainfrom
erle/otel-model-artifacts-tracing

Conversation

@ecarrara
Copy link
Copy Markdown
Contributor

@ecarrara ecarrara commented Apr 20, 2026

What does this PR do?

Adds OpenTelemetry child spans inside the existing model.load span to make model artifact loading observable. Previously, model.load_time_seconds was a single opaque measurement — it was impossible to tell whether the time was spent reading from local disk cache or downloading weights from a remote source.

Three new spans are emitted, each carrying model.id and model.artifacts.source attributes:

Span model.artifacts.source Triggered by
model.artifacts.load local_cache weights already in disk cache
model.artifacts.download s3 download from S3 bucket
model.artifacts.download roboflow_api download from Roboflow API

Related Issue(s): N/A

Type of Change

  • New feature (non-breaking change that adds functionality)

Testing

  • I have added/updated tests for this change

Test details: Spans are emitted via the existing start_span helper which degrades to a noop when OTel is not configured, so no existing behaviour changes.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • I have updated the documentation accordingly (if applicable)

Additional Context

model.load_time_seconds on the parent model.load span is intentionally kept. It measures total model initialization time, which includes ONNX session creation and other setup beyond artifact fetching. The new child spans cover only the artifact portion, so the full picture looks like:

model.load  (total: model.load_time_seconds)
├── model.artifacts.load / model.artifacts.download  (artifact fetch)
└── [remaining time = ONNX session init, etc.]

…te source

Adds child spans under the existing model.load span:
- model.artifacts.load (source=local_cache) for cache hits
- model.artifacts.download (source=s3 or roboflow_api) for remote downloads

Each span carries model.id and model.artifacts.source attributes.
Copy link
Copy Markdown
Collaborator

@hansent hansent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ecarrara ecarrara merged commit 4118592 into main Apr 20, 2026
46 checks passed
@ecarrara ecarrara deleted the erle/otel-model-artifacts-tracing branch April 20, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants