Configuration for Windows services
Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability This functionality is generally available and ready for production usage. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability This functionality is generally available and ready for production usage. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes. The Elastic APM .NET agent enables you to trace the execution of operations in your .NET applications, sending performance metrics and errors to the Elastic APM server. Availability This functionality is generally available and ready for production usage. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
Serverless Observability
Generally available
Stack
Generally available
APM Agent .NET
Generally available
While the APM .NET Agent supports automatic transaction creation for web frameworks such as ASP.NET and ASP.NET Core, it doesn't know where the "unit of work" starts for bespoke services. Therefore, it cannot start a transaction automatically. As a result, spans, such as those for outbound HTTP requests, aren't captured, as they expect a running transaction, and no trace data is generated or exported by default.
To manually create a transaction around the appropriate unit of work for your scenario, instrument your code manually. You can start a custom transaction using the Public API. Alternatively, consider using the Elastic Distribution of OpenTelemetry for .NET, which captures all spans automatically, including those for outbound HTTP requests. The first span without a parent is considered a transaction when ingested into Elastic Observability.
Configuration for Windows services can be provided by setting environment variables for the specific Windows service in the Windows registry. With PowerShell
$environment = [string[]]@(
"ELASTIC_APM_SERVER_URL=http://localhost:8200",
"ELASTIC_APM_TRANSACTION_SAMPLE_RATE=1",
"ELASTIC_APM_ENVIRONMENT=Production",
"ELASTIC_APM_SERVICE_NAME=MyWindowsService")
Set-ItemProperty HKLM:SYSTEM\CurrentControlSet\Services\<service-name> -Name Environment -Value $environment
- define the environment variables to use for the Windows service
<service-name>is the name of the Windows service.
The service must then be restarted for the change to take effect
Restart-Service <service-name>