1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- import asyncio
1615import os
1716
17+ from volcengine .tls .TLSService import TLSService
18+
1819from veadk .consts import DEFAULT_TLS_LOG_PROJECT_NAME , DEFAULT_TLS_TRACING_INSTANCE_NAME
1920from veadk .integrations .ve_tls .utils import ve_tls_request
2021from veadk .utils .logger import get_logger
21- from volcengine .tls .TLSService import TLSService
2222
2323logger = get_logger (__name__ )
2424
@@ -63,13 +63,11 @@ def get_project_id_by_name(self, project_name: str) -> str:
6363
6464 try :
6565 res = None
66- res = asyncio .run (
67- ve_tls_request (
68- client = self ._client ,
69- api = "DescribeProjects" ,
70- body = request_body ,
71- method = "GET" ,
72- )
66+ res = ve_tls_request (
67+ client = self ._client ,
68+ api = "DescribeProjects" ,
69+ body = request_body ,
70+ method = "GET" ,
7371 )
7472 projects = res ["Projects" ]
7573 for project in projects :
@@ -97,10 +95,8 @@ def create_log_project(self, project_name: str) -> str:
9795 "Tags" : [{"Key" : "provider" , "Value" : "VeADK" }],
9896 }
9997 try :
100- res = asyncio .run (
101- ve_tls_request (
102- client = self ._client , api = "CreateProject" , body = request_body
103- )
98+ res = ve_tls_request (
99+ client = self ._client , api = "CreateProject" , body = request_body
104100 )
105101
106102 if res ["ErrorCode" ] == "ProjectAlreadyExist" :
@@ -122,13 +118,11 @@ def get_trace_instance_by_name(self, log_project_id: str, trace_instance_name: s
122118 "TraceInstanceName" : trace_instance_name ,
123119 }
124120 try :
125- res = asyncio .run (
126- ve_tls_request (
127- client = self ._client ,
128- api = "DescribeTraceInstances" ,
129- body = request_body ,
130- method = "GET" ,
131- )
121+ res = ve_tls_request (
122+ client = self ._client ,
123+ api = "DescribeTraceInstances" ,
124+ body = request_body ,
125+ method = "GET" ,
132126 )
133127
134128 for instance in res ["TraceInstances" ]:
@@ -156,12 +150,10 @@ def create_tracing_instance(self, log_project_id: str, trace_instance_name: str)
156150
157151 try :
158152 res = None
159- res = asyncio .run (
160- ve_tls_request (
161- client = self ._client ,
162- api = "CreateTraceInstance" ,
163- body = request_body ,
164- )
153+ res = ve_tls_request (
154+ client = self ._client ,
155+ api = "CreateTraceInstance" ,
156+ body = request_body ,
165157 )
166158
167159 if res ["ErrorCode" ] == "TopicAlreadyExist" :
@@ -173,13 +165,11 @@ def create_tracing_instance(self, log_project_id: str, trace_instance_name: str)
173165 )
174166
175167 # after creation, get the trace instance details
176- res = asyncio .run (
177- ve_tls_request (
178- client = self ._client ,
179- api = "DescribeTraceInstance" ,
180- body = {"TraceInstanceID" : res ["TraceInstanceID" ]},
181- method = "GET" ,
182- )
168+ res = ve_tls_request (
169+ client = self ._client ,
170+ api = "DescribeTraceInstance" ,
171+ body = {"TraceInstanceID" : res ["TraceInstanceID" ]},
172+ method = "GET" ,
183173 )
184174
185175 return res
0 commit comments