【azure 应用程序见解】在docker中运行的asp.net core应用如何开启application insights的profiler trace呢? _路边两盏灯-编程思维

问题描述

使用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 is set. 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 applicationhttps://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

 

版权声明:本文版权归作者所有,遵循 CC 4.0 BY-SA 许可协议, 转载请注明原文链接
https://www.cnblogs.com/lulight/p/14621310.html

【azure application insights】在azure function中启用application insights后,如何配置不输出某些日志到ai 的trace中_路边两盏灯-编程思维

问题描述 基于.NET Core的Function App如果配置了Application Insights之后,每有一个函数被执行,则在Application Insights中的Logs中的trace里都可以查询到函数的执行启动,执行结束的信息。类似如下的日志, 函数执行开始 Executing Functi

【应用程序见解 application insights】application insights 使用 application maps 构建请求链路视图_路边两盏灯-编程思维

Applicaotn  Insigths 使用 Application Maps 构建请求链路视图  构建系统时,请求的逻辑操作大多数情况下都需要在不同的服务,或接口中完成整个请求链路。一个请求可以经历多个组件,极有可能出现客户端请求站点1,站点1请求站点2, … 站点N才是最终处理数据然后依次返回。 在这样的情况,如

【api管理 apim】如何查看apim中的request与response详细信息,如header,body中的参数内容_路边两盏灯-编程思维

问题描述 通过APIM门户或者是Developer门户,我们可以通过Test功能测试某一个接口,通过Trace可以获取非常详细的Request,Response的信息,包含Header,X-Forward-To,及Respnse的信息。但是,当我们正式使用时,确无法得到这些信息。APIM门户及日志中都没有保存请求中携带

【azure 应用程序见解】通过azure funciton的门户启用application insights后,application insights无法收到监控数据_路边两盏灯-编程思维

问题描述 比较早期创建的Azure Funciton服务,近期发现在门户中已经启用了Application Insights功能,但是正确配置Applicaiton Insights后,却无法获取关联的Azure Function的监控数据?   问题分析 到目前为止,Azure Function已经经历了三个版本的发

【azure 应用服务】app service 通过门户配置数据库连接字符串不生效 _路边两盏灯-编程思维

应用设置 Application Setting 在应用服务中,应用设置是作为环境变量传递给应用程序代码的变量。 对于 Linux 应用和自定义容器,应用服务使用 --env 标志将应用设置传递到容器,以在容器中设置环境变量。 无论是这两种情况中的哪一种,它们都会在应用启动时注入到应用环境。 在添加、删除或编辑应用设置