Setting up .NET tracing on z/OS
You can set up .NET tracing on z/OS systems by using manual instrumentation. Due to platform limitations, automatic instrumentation is not available on z/OS.
For details about the working of .NET monitoring, see How .NET monitoring works.
Before you begin
To set up .NET Core tracing on z/OS, complete the following steps:
- Ensure that the Instana agent is running on the z/OS system. See Installing agent on z/OS in the Instana documentation.
- Verify that your .NET Core version is supported.
- Check support information.
Enabling .NET tracing
On z/OS systems, the CoreCLR Profiling API is not supported. As a result, automatic instrumentation through IL rewriting and native profiler attachment is not available on this platform.
Due to these architectural limitations, you must use manual instrumentation to enable tracing for .NET applications on z/OS.
Instana supports two approaches for manual instrumentation on z/OS:
- Method 1: Using Instana SDK: Use this SDK if you need only Instana monitoring as it provides direct integration and is simpler to set up.
- Method 2: Using OpenTelemetry SDK: Use this SDK if you need vendor-neutral instrumentation or flexibility to switch between different observability backends.
Method 1: Using Instana SDK
Use the Instana Tracing SDK to create custom spans and traces.
To enable tracing by using the Instana SDK, complete the following steps:
- Add the
Instana.Tracing.Core.SdkNuGet package to your project. -
Create custom spans in your application code:
using Instana.Tracing.Sdk.Spans; // Create an entry span for incoming requests using (var span = CustomSpan.Create(SpanType.ENTRY, "operation-name")) { span.SetServiceName("your-service-name"); span.SetEndpointName("endpoint-name"); span.SetData("custom.key", "custom-value"); // Your application logic here } // Create an intermediate span for internal operations using (var span = CustomSpan.Create(SpanType.INTERMEDIATE, "internal-operation")) { span.SetServiceName("your-service-name"); span.SetEndpointName("operation-name"); // Your internal logic here } -
Optional: Configure the Instana tracer in your application startup code (typically in
Program.cs) to set default service and endpoint names that are displayed in traces:using Instana.Tracing.Sdk; // Configure Instana Tracer TracerConfiguration.ServiceName = "your-service-name"; TracerConfiguration.EndpointName = "your-endpoint-name"; - Deploy and start the application. Generate traffic to the application endpoints.
-
Verify that traces are being collected:
- Go to Applications > Services in the Instana UI.
- Locate the service name to view its traces and metrics.
For more information about Instana .NET Core Tracing SDK, see .NET or .NET Core Tracing SDK.
Method 2: Using OpenTelemetry SDK
Use the OpenTelemetry SDK with OTLP exporter to send traces to Instana.
Before you use the OpenTelemetry SDK, configure the Instana agent to accept OpenTelemetry data by enabling the following configuration in the agent configuration file <agent-root-path>/agent/etc/instana/configuration.yaml:
# Enable OpenTelemetry
com.instana.plugin.opentelemetry:
grpc:
enabled: true
http:
enabled: true
# Enable .NET Core AutoTracing
com.instana.plugin.netcore:
tracing:
enabled: true
To enable tracing by using the OpenTelemetry SDK, complete the following steps:
-
Add the required OpenTelemetry NuGet packages to your project:
OpenTelemetry.Extensions.HostingOpenTelemetry.Exporter.OpenTelemetryProtocolOpenTelemetry.Exporter.Console(if console-based logging is required)OpenTelemetry.Instrumentation.AspNetCore(for ASP.NET Core web applications)OpenTelemetry.Instrumentation.Http(for HTTP client instrumentation)
-
Configure OpenTelemetry in your application startup code (typically in
Program.cs):using OpenTelemetry.Resources; using OpenTelemetry.Trace; var builder = WebApplication.CreateBuilder(args); // Configure OpenTelemetry builder.Services.AddOpenTelemetry() .ConfigureResource(resource => { resource.AddService( serviceName: "your-service-name", serviceVersion: "1.0.0", serviceInstanceId: Environment.ProcessId.ToString()); }) .WithTracing(tracing => { tracing .AddSource("your-service-name") .AddAspNetCoreInstrumentation() .AddHttpClientInstrumentation() .AddOtlpExporter(options => { // Configure OTLP endpoint to point to Instana Agent options.Endpoint = new Uri("http://localhost:4317"); }); }); -
Create custom spans by using OpenTelemetry ActivitySource:
using System.Diagnostics; // Create an ActivitySource private static readonly ActivitySource ActivitySource = new ActivitySource("your-service-name", "1.0.0"); // Create custom spans using (var activity = ActivitySource.StartActivity("operation-name")) { activity?.SetTag("custom.key", "custom-value"); activity?.SetTag("operation.type", "business-logic"); // Your application logic here activity?.AddEvent(new ActivityEvent("Operation completed")); } - Deploy and start the application. Generate traffic to the application endpoints.
-
Verify that traces are being collected:
- Go to Applications > Services in the Instana UI.
- Locate the service name to view its traces and metrics.