【Azure 应用程序见解】在Docker中运行的ASP.NET Core应用如何开启Application Insights的Profiler Trace呢?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了【Azure 应用程序见解】在Docker中运行的ASP.NET Core应用如何开启Application Insights的Profiler Trace呢?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2324字,纯文字阅读大概需要4分钟。
内容图文
问题描述
使用Azure Application Insights收集AKS中ASP.NET Core应用的监控数据,自动收集请求的Trace情况,用于分析单个请求在应用内部的耗时及处理事件情况,参考Application Insights的文档,功能“Profiler Trace”可以追踪请求详情,但是在中国区的Application Insights中,确没有发现Profiler Trace功能。这里需要如何在Docker文件中配置呢?
期望结果 | 实际结果 |
|
|
那这里需要如何设置才能查看到Profiler Trace呢?
问题解决
根据示例的Docker代码,需要在构建镜像时候配置正确的Application Insights Connect String。而在文档中使用的是APPINSIGHTS_INSTRUMENTATIONKEY的方式,所以这里需要修改为APPLICATIONINSIGHTS_CONNECTION_STRING, 并且需要在其中必须包含Profiler 的Endpoint: ProfilerEndpoint=https://profiler.monitor.azure.cn/ 。
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build-env WORKDIR /app # Copy everything and build COPY . ./ # Adding a reference to hosting startup package RUN dotnet add package Microsoft.ApplicationInsights.Profiler.AspNetCore -v 2.* # Restore & publish the app RUN dotnet publish -c Release -o out # Build runtime image FROM mcr.microsoft.com/dotnet/aspnet:3.1 # Create an argument to allow docker builder to passing in application insights key. # For example: docker build . --build-arg APPINSIGHTS_CONNECTION_STRING=YOUR_APPLICATIONINSIGHTS_INSTRUMENTATION_CONNECTION_STRING ARG APPINSIGHTS_CONNECTION_STRING # Making sure the argument isset. Fail the build of the container otherwise. RUN test -n "$APPINSIGHTS_CONNECTION_STRING" # Light up Application Insights and Service Profiler ENV APPLICATIONINSIGHTS_CONNECTION_STRING $APPINSIGHTS_CONNECTION_STRING ENV ASPNETCORE_HOSTINGSTARTUPASSEMBLIES Microsoft.ApplicationInsights.Profiler.AspNetCore WORKDIR /app COPY --from=build-env /app/out . ENTRYPOINT ["dotnet", "EnableServiceProfilerForContainerApp.dll"]
APPLICATIONINSIGHTS_CONNECT_STRING格式如下:
InstrumentationKey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx;EndpointSuffix=applicationinsights.azure.cn;IngestionEndpoint=https://chinaeast2-0.in.applicationinsights.azure.cn/;ProfilerEndpoint=https://profiler.monitor.azure.cn/
参考资料
Enable Service Profiler for containerized ASP.NET Core application:https://github.com/microsoft/ApplicationInsights-Profiler-AspNetCore/tree/main/examples/EnableServiceProfilerForContainerApp
Profile production applications in Azure with Application Insights:https://docs.microsoft.com/en-us/azure/azure-monitor/app/profiler-overview#view-profiler-data
原文:https://www.cnblogs.com/lulight/p/14621310.html
内容总结
以上是互联网集市为您收集整理的【Azure 应用程序见解】在Docker中运行的ASP.NET Core应用如何开启Application Insights的Profiler Trace呢?全部内容,希望文章能够帮你解决【Azure 应用程序见解】在Docker中运行的ASP.NET Core应用如何开启Application Insights的Profiler Trace呢?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。