Skip to content

Commit

Permalink
[Internal] Make runtime cloud trace also async (#3081)
Browse files Browse the repository at this point in the history
# Description

Currently, the cloud trace in runtime is in sync mode. This seems
unnecessary. The local and runtime should use the same async pattern.

# All Promptflow Contribution checklist:
- [ ] **The pull request does not introduce [breaking changes].**
- [ ] **CHANGELOG is updated for new features, bug fixes or other
significant changes.**
- [ ] **I have read the [contribution guidelines](../CONTRIBUTING.md).**
- [ ] **Create an issue and link to the pull request to get dedicated
review from promptflow team. Learn more: [suggested
workflow](../CONTRIBUTING.md#suggested-workflow).**

## General Guidelines and Best Practices
- [ ] Title of the pull request is clear and informative.
- [ ] There are a small number of commits, each of which have an
informative message. This means that previously merged commits do not
appear in the history of the PR. For more information on cleaning up the
commits in your PR, [see this
page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md).

### Testing Guidelines
- [ ] Pull request includes test coverage for the included changes.

Co-authored-by: Yangtong Xu <[email protected]>
  • Loading branch information
riddlexu and Yangtong Xu authored May 6, 2024
1 parent c8f0e8c commit 1607cc7
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/promptflow-devkit/promptflow/_sdk/_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,17 +609,11 @@ def process_otlp_trace_request(
else:
all_spans.append(span)

if cloud_trace_only:
# If we only trace to cloud, we should make sure the data writing is success before return.
_try_write_trace_to_cosmosdb(
all_spans, get_created_by_info_with_cache, logger, get_credential, is_cloud_trace=True
)
else:
# Create a new thread to write trace to cosmosdb to avoid blocking the main thread
ThreadWithContextVars(
target=_try_write_trace_to_cosmosdb,
args=(all_spans, get_created_by_info_with_cache, logger, get_credential, False),
).start()
# Create a new thread to write trace to cosmosdb to avoid blocking the main thread
ThreadWithContextVars(
target=_try_write_trace_to_cosmosdb,
args=(all_spans, get_created_by_info_with_cache, logger, get_credential, cloud_trace_only),
).start()

return

Expand Down

0 comments on commit 1607cc7

Please sign in to comment.