Skip to content

[Core] Add start_time kwargs to start_span methods #41106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025

Conversation

pvaneck
Copy link
Member

@pvaneck pvaneck commented May 14, 2025

We should expose a start_time keyword argument in the start_span methods to allow users to specify the start time of the span. This is useful in scenarios like in SB, where you want to create a span for a receive operation, but also want to add links to the messages that are received, so we want to create the span after the receive operation, but still portray a more accurate duration for the span.

@pvaneck pvaneck force-pushed the core-start-time branch from c92af16 to aafd49e Compare May 14, 2025 23:51
Copy link

github-actions bot commented May 15, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure-core

@pvaneck pvaneck force-pushed the core-start-time branch from aafd49e to 23faf0f Compare May 21, 2025 02:43
@pvaneck pvaneck marked this pull request as ready for review May 21, 2025 19:44
@Copilot Copilot AI review requested due to automatic review settings May 21, 2025 19:44
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds the ability to specify a custom start time when creating spans via the OpenTelemetry tracer.

  • Introduce a start_time kwarg to start_span and start_as_current_span
  • Update tests to verify spans honor the provided start time
  • Document the feature in the CHANGELOG

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
sdk/core/azure-core/azure/core/tracing/opentelemetry.py Added start_time parameter, updated docstrings, and propagated it through context manager
sdk/core/azure-core/tests/test_tracer_otel.py New tests for start_span and start_as_current_span with start_time
sdk/core/azure-core/CHANGELOG.md Recorded the addition of the start_time argument

@pvaneck pvaneck merged commit 96090a5 into Azure:main May 29, 2025
64 checks passed
@pvaneck pvaneck deleted the core-start-time branch May 29, 2025 21:56
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