使用dotnet跟踪和计数器在kubernetes性能诊断上部署的C# dotnet应用程序

drkbr07n  于 2023-11-17  发布在  Kubernetes
关注(0)|答案(1)|浏览(105)

我正在尝试使用dotnet-trace和dotnet计数器为部署在kubernetes(GKE)集群上的应用启用性能诊断。为此,我在我的应用容器中添加了一个性能诊断sidecar。diagnostics.Dockerfile:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS tools
RUN dotnet tool install --tool-path /tools dotnet-trace
RUN dotnet tool install --tool-path /tools dotnet-counters
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine AS runtime
COPY --from=tools /tools /tools
ENV PATH="/tools:${PATH}"
ENV COMPlus_EnableDiagnostics="0"
WORKDIR /tools

字符串
我在这里使用的应用程序是一个简单的hello world应用程序。这是我在GKE上部署这些容器的方式:deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: demo-dotnet-diagnostics
spec:
  replicas: 1
  selector:
    matchLabels:
      app: demo-diagnostics
  template:
    metadata:
      labels:
        app: demo-diagnostics
    spec:
      shareProcessNamespace: true
      containers:
      - name: demo-app
        image: gcr.io/qp-fda-mystudies-2020-07/dotnetapp:latest
        ports:
        - containerPort: 8080
        volumeMounts:
        - name: dotnet-diagnostics
          mountPath: /tmp
      - name: demo-diagnostics
        image: gcr.io/qp-fda-mystudies-2020-07/diagnostics:latest
        stdin: true
        tty: true
        command: ["/bin/sh","-c"]
        args: ["dotnet-trace collect -p 1; dotnet-counters monitor -p 1"]
        volumeMounts:
        - name: dotnet-diagnostics
          mountPath: /tmp
      volumes:
      - name: dotnet-diagnostics
        emptyDir: {}


我在这里面临的问题是诊断容器不断运行到crashloopbackoff.我在这里得到的错误是:未能启动计数器会话:Microsoft.Diagnostics.NETCore.Client. ServerNotableException:Process 1 not running compatible .NET runtime.我一直在关注这些文章和线程:https://github.com/dotnet/diagnostics/issues/810https://im5tu.io/article/2020/01/diagnostics-in-.net-core-3-using-dotnet-counters-with-docker/目标是在后台运行这些诊断过程,并将使用这些工具捕获的信息推送到stackdriver。我不知道我在这里错过了什么,因为我对dotnet相对较新。请帮助。

m0rkklqb

m0rkklqb1#

注意测试,但我会尝试删除这一行(或将其设置为1):

ENV COMPlus_EnableDiagnostics="0"

字符串
来源MS

相关问题