microsoft / ApplicationInsights-Profiler-AspNetCore

Application Insights Profiler sample and documentation
MIT License
66 stars 24 forks source link

Trace Upload is not located when package is referenced indirectly #86

Closed wow-anton closed 4 years ago

wow-anton commented 4 years ago

Hi,

I was hoping you could help me diagnose this issue.

My web app has an indirect dependency on the AI Profiler package MyWebApp references -> My.Toolkit (nuget package) references -> Microsoft.ApplicationInsights.Profiler.AspNetCore

When I run my application, samples are gathered, but upload fails because the TraceUpload is not found.

[16:14:09 DBG] File uploader is not found. Try the zip file: /mywebappapp/bin/Debug/netcoreapp3.1/ServiceProfiler/TraceUpload.zip [16:14:09 DBG] Zip file does not exist. Fail the locating. [16:14:09 ERR] Trace Uploader is not located. [16:14:09 ERR] Upload trace failed.

The only thing I found to be different is that the ServiceProfiler/TraceUpload.zip file is not being created in this scenario.

If I add My.Toolkit as a project reference rather than as a package reference, TraceUpload.zip is created. Any ideas what could be causing this?

Additional Info: Web App version: ASP.NET Core 3.1 ASP.NET Core SDK Version: 3.1.100 Profiler Version: 2.1.0-beta-1 MacOS Catalina

xiaomi7732 commented 4 years ago

Hi @wow-anton thanks for the contacting. I don't know the library of My.Toolkit, could you please point me to the package on NuGet.org and I will see if I can repro the issue locally.

wow-anton commented 4 years ago

Sorry, I should have clarified that My.Toolkit is a fictional nuget package. The point I wanted to make is that when I wrap the AI Profiler plugin inside my own nuget package, ServiceProfiler/TraceUpload.zip does not get created on startup.

xiaomi7732 commented 4 years ago

@wow-anton That is good to know. Could you please explain us how are you wrapping up the Profiler package? And why aren't the toolkit package directly depend on the profiler package?

wow-anton commented 4 years ago

Sure.

Could you please explain us how are you wrapping up the Profiler package? My.Toolkit is my own netstandard 2.0 class library. It has a package dependency on Microsoft.ApplicationInsights.Profiler.AspNetCore. I have published My.Toolkit as a nuget package to my own private nuget repository.

MyWebApp is my ASP.NET Core 3.1 web app. It in turn has a dependency on My.Toolkit. When I restore the packages for the application, it will also download Microsoft.ApplicationInsights.Profiler.AspNetCore because My.Toolkit depends on it.

In MyWebApp I add the necessary services.AddServiceProfiler() and the application compiles. But when I run the application, ServiceProfiler/TraceUpload.zip is not created.

And why aren't the toolkit package directly depend on the profiler package? The toolkit DOES directly depend on the profiler package. If you're asking why the web app doesn't directly depend on it, it's difficult to explain but in short it's because we would like to encapsulate the profiler and other common packages we use in our org inside My.Toolkit for reuse.

xiaomi7732 commented 4 years ago

Hi @wow-anton, thanks for the update. I did some dig around the issue. The problem is the content files not not implicitly added and that is an NuGet limitation at this point. Refer to #9474 for details.

Until the issue is addressed, I am afraid we have limited options here.

One way would be asking the final project owner to take a dependency on Microsoft.ApplicationInsights.Profiler.AspNetCore directly. It then beats the purpose of the wrapping.

Another way is for your project of MyToolkit to re-wrap the content of the files.

Let us know if you need further help with this.

wow-anton commented 4 years ago

Hi @xiaomi7732 thanks for the follow-up and clarification.

We went ahead with the direct dependency workaround.

mewt666 commented 1 year ago

Was this issue never updated or resolved ? We're encountering a similar issue where Microsoft.ApplicationInsights.Profiler.AspNetCore is referenced and instantiated in a toolkit which is in turn referenced in a separate project. Trace messages captured show "Uploader can't be located." "Microsoft.ApplicationInsights.Profiler.Core.UploaderProxy.UploaderPathProvider"

xiaomi7732 commented 1 year ago

Hey @mewt666, thanks for bringing this up again. Checked the issue #9474 and it looks like it is still not resolved. Unfortunately, in that case, we are hand tightened.

Is it possible to make the head projects reference Microsoft.ApplicationInsights.Profiler.ASPNetCore directly?

jforhan70 commented 1 year ago

Hey @mewt666, thanks for bringing this up again. Checked the issue #9474 and it looks like it is still not resolved. Unfortunately, in that case, we are hand tightened.

Is it possible to make the head projects reference Microsoft.ApplicationInsights.Profiler.ASPNetCore directly?

Hi @xiaomi7732,

Adding the reference at the project level resolved the issue and the AI Profiler is now working.

Jeff

mewt666 commented 1 year ago

Hi @xiaomi7732,

Adding the reference at the project level resolved the issue and the AI Profiler is now working.

Jeff

Did you also perform instantiation from within the project for this to work correctly ?

Anton

jforhan70 commented 1 year ago

Hi @mewt666,

Hi @xiaomi7732, Adding the reference at the project level resolved the issue and the AI Profiler is now working. Jeff

Did you also perform instantiation from within the project for this to work correctly ?

Anton

This was for EPiServer CMS 12 (.NET Core). In VS we had the customer go into the project references and add the reference to profiler there. Nothing else changed from when they upgraded the code.