From 1607cc71fe8ce603d20723758ffcc3e2045281b9 Mon Sep 17 00:00:00 2001 From: riddle xu Date: Mon, 6 May 2024 14:02:02 +0800 Subject: [PATCH] [Internal] Make runtime cloud trace also async (#3081) # 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 --- .../promptflow/_sdk/_tracing.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/promptflow-devkit/promptflow/_sdk/_tracing.py b/src/promptflow-devkit/promptflow/_sdk/_tracing.py index 0e21ceec725..2a1a0b69f37 100644 --- a/src/promptflow-devkit/promptflow/_sdk/_tracing.py +++ b/src/promptflow-devkit/promptflow/_sdk/_tracing.py @@ -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