11using Aspire . Hosting . ApplicationModel ;
2- using Aspire . Hosting . Python ;
32using CommunityToolkit . Aspire . Utils ;
43
54namespace Aspire . Hosting ;
@@ -46,17 +45,9 @@ private static IResourceBuilder<StreamlitAppResource> AddStreamlitApp(
4645
4746 projectDirectory = PathNormalizer . NormalizePathForCurrentPlatform ( Path . Combine ( builder . AppHostDirectory , wd ) ) ;
4847
49- var virtualEnvironment = new VirtualEnvironment ( Path . IsPathRooted ( virtualEnvironmentPath )
50- ? virtualEnvironmentPath
51- : Path . Join ( projectDirectory , virtualEnvironmentPath ) ) ;
48+ var projectResource = new StreamlitAppResource ( name , projectDirectory ) ;
5249
53- var instrumentationExecutable = virtualEnvironment . GetExecutable ( "opentelemetry-instrument" ) ;
54- var streamlitExecutable = virtualEnvironment . GetExecutable ( "streamlit" ) ?? "streamlit" ;
55- var projectExecutable = instrumentationExecutable ?? streamlitExecutable ;
56-
57- var projectResource = new StreamlitAppResource ( name , projectExecutable , projectDirectory ) ;
58-
59- var resourceBuilder = builder . AddResource ( projectResource )
50+ return builder . AddResource ( projectResource )
6051 . WithEnvironment ( context =>
6152 {
6253 // Streamlit uses STREAMLIT_SERVER_PORT instead of PORT, so map PORT to STREAMLIT_SERVER_PORT
@@ -67,28 +58,8 @@ private static IResourceBuilder<StreamlitAppResource> AddStreamlitApp(
6758 } )
6859 . WithArgs ( context =>
6960 {
70- // If the project is to be automatically instrumented, add the instrumentation executable arguments first.
71- if ( ! string . IsNullOrEmpty ( instrumentationExecutable ) )
72- {
73- AddOpenTelemetryArguments ( context ) ;
74-
75- // Add the streamlit executable as the next argument so we can run the project.
76- context . Args . Add ( "streamlit" ) ;
77- }
78-
7961 AddProjectArguments ( scriptPath , args , context ) ;
8062 } ) ;
81-
82- if ( ! string . IsNullOrEmpty ( instrumentationExecutable ) )
83- {
84- resourceBuilder . WithOtlpExporter ( ) ;
85-
86- // Make sure to attach the logging instrumentation setting, so we can capture logs.
87- // Without this you'll need to configure logging yourself. Which is kind of a pain.
88- resourceBuilder . WithEnvironment ( "OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED" , "true" ) ;
89- }
90-
91- return resourceBuilder ;
9263 }
9364
9465 private static void AddProjectArguments ( string scriptPath , string [ ] scriptArgs , CommandLineArgsCallbackContext context )
@@ -105,16 +76,4 @@ private static void AddProjectArguments(string scriptPath, string[] scriptArgs,
10576 context . Args . Add ( arg ) ;
10677 }
10778 }
108-
109- private static void AddOpenTelemetryArguments ( CommandLineArgsCallbackContext context )
110- {
111- context . Args . Add ( "--traces_exporter" ) ;
112- context . Args . Add ( "otlp" ) ;
113-
114- context . Args . Add ( "--logs_exporter" ) ;
115- context . Args . Add ( "console,otlp" ) ;
116-
117- context . Args . Add ( "--metrics_exporter" ) ;
118- context . Args . Add ( "otlp" ) ;
119- }
12079}
0 commit comments