Skip to content

Commit 9023ace

Browse files
authored
Merge pull request Azure-Samples#64 from qubitron/main
guard against empyt app insights connection string
2 parents 29fd484 + 97f15ab commit 9023ace

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/api/api/logging.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ def log_output(*args):
1818
def init_logging(sampling_rate=1.0):
1919
# Enable logging to app insights if a connection string is provided
2020
if 'APPLICATIONINSIGHTS_CONNECTION_STRING' in os.environ:
21-
inject_openai_api()
22-
2321
connection_string=os.environ['APPLICATIONINSIGHTS_CONNECTION_STRING']
24-
trace.set_tracer_provider(TracerProvider(sampler=ParentBasedTraceIdRatio(sampling_rate)))
25-
trace.get_tracer_provider().add_span_processor(BatchSpanProcessor(AzureMonitorTraceExporter(connection_string=connection_string)))
22+
if connection_string != "":
23+
inject_openai_api()
24+
trace.set_tracer_provider(TracerProvider(sampler=ParentBasedTraceIdRatio(sampling_rate)))
25+
trace.get_tracer_provider().add_span_processor(BatchSpanProcessor(AzureMonitorTraceExporter(connection_string=connection_string)))
2626

2727
# Enable logging locally if the below variable is set
2828
if 'PROMPTFLOW_TRACING_SERVER' in os.environ and os.environ['PROMPTFLOW_TRACING_SERVER'] != 'false':

0 commit comments

Comments
 (0)