tencent cloud

All product documents
Tencent Cloud Observability Platform
Automatic Access of .NET Applications in Kubernetes Environment (Recommended)
Last updated: 2025-03-04 22:02:22
Automatic Access of .NET Applications in Kubernetes Environment (Recommended)
Last updated: 2025-03-04 22:02:22
For the .NET applications deployed on Kubernetes, Application Performance Management (APM) offers an automatic access solution that enables automatic agent injection, which facilitates quick access of applications.
The .NET applications adopting automatic access in Kubernetes environment will use the community edition of the OpenTelemetry-dotnet solution to inject agents. For more information about OpenTelemetry-dotnet, see the community OpenTelemetry-dotnet project.

Prerequisites

Ensure that the .NET version, dependency libraries, and frameworks are within the supported range of the agent by referring to Components and Frameworks Supported by the OpenTelemetry-dotnet Solution. For dependency libraries and frameworks supported by automatic instrumentation, data reporting will be completed upon successful access without the need to modify the code. If automatic instrumentation does not meet your needs, or you need to perform instrumentation at the business layer, please do so.

Step 1: Installing Operator

Install Operator in the Kubernetes cluster. It is recommended to install Operator in the APM console with one click. For details, see Installing tencent-opentelemetry-operator.

Step 2: Adding Annotation to Workload

Taking Tencent Kubernetes Engine (TKE) as an example, annotations can be added to workloads by following the steps below. For general Kubernetes clusters, use tools like kubectl to add annotations.
1. Log in to the TKE console.
2. Click Cluster to enter the corresponding TKE cluster.
3. In Workload, find the application that needs to access APM, click More, then click Edit YAML.
4. Add the following content in the Pod annotation, and click Complete to finish the access.
cloud.tencent.com/inject-dotnet: "true"
cloud.tencent.com/otel-service-name: my-app # Application name. For the processes that access using the same application name are displayed in APM as multiple instances under the same application.
# The application name can contain up to 63 characters, consisting of lowercase letters, digits, and the separator (-) only. It must start with a lowercase letter and end with a digit or lowercase letter.
Note that this content needs to be added to spec.template.metadata.annotations, affecting the Pod's annotation, rather than the workload's annotation. You can see the following code snippet:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
k8s-app: my-app
name: my-app
namespace: default
spec:
selector:
matchLabels:
k8s-app: my-app
template:
metadata:
labels:
k8s-app: my-app
annotations:
cloud.tencent.com/inject-dotnet: "true" # Add it here.
cloud.tencent.com/otel-service-name: my-app
spec:
containers:
image: my-app:0.1
name: my-app

Access Verification

After an annotation is added to the workload, the system triggers a restart of the application Pod based on the release policy. The newly started Pod will be automatically injected with an agent and access the APM server to report monitoring data. The reported business system is the default business system of Operator. Under normal traffic conditions, the application will be displayed in APM > Application list . After you enter the corresponding application, you can see the application instance in Instance monitoring. Since there is certain delay in processing of observable data, you may wait for about 30 seconds if the application or instance is not found in the console.

More Access Configuration Items (Optional)

At the workload level, you can add more annotations to adjust the access behaviors:
Configuration Item
Description
cloud.tencent.com/apm-token
Specifies the Token for the APM business system. If this configuration item is not added, the configuration of the Operator is used (corresponding to the Operator's env.APM_TOKEN field).
cloud.tencent.com/dotnet-instr-version
Specifies the .NET agent version. If this configuration item is not added, the configuration of Operator (corresponding to the env.DOTNET_INSTR_VERSION field of Operator) is used. The value can be latest (default) or a specific version number. For a list of specific version numbers, see Agent Version Information. It is not recommended to fill in this field unless necessary.
cloud.tencent.com/container-names
Specifies the container(s) where the agent is injected. Injecting an agent into multiple containers is supported. In this case, simply enter multiple container names separated by English commas in the value section of this configuration item. If this configuration item is not added, the agent will be injected into the first container by default. This configuration item is supported in Operator version 0.88 and later.
cloud.tencent.com/otel-dotnet-auto-runtime
Specifies the location of .NET CLR Profiler. If this configuration item is not added, the configuration of Operator (corresponding to the env.CORECLR_PROFILER_PATH field of Operator) is used. It is not recommended to fill in this field unless necessary. This configuration item is supported in Operator version 0.88 and later.
Optional configuration items:
linux-x64 (default): Suitable for Linux glibc-based images.
linux-musl-x64: Suitable for Linux musl-based images.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support