- .NET SDK Telemetry Documentation
The .NET SDK telemetry can be disabled using the following environment variable:
DOTNET_CLI_TELEMETRY_OPTOUT: Set to1,true, oryesto opt-out of telemetry collection- Example:
export DOTNET_CLI_TELEMETRY_OPTOUT=1(Linux/macOS) - Example:
set DOTNET_CLI_TELEMETRY_OPTOUT=1(Windows) - Note: this value is defaulted to
trueon non-Microsoft-provided builds of the .NET SDK (e.g. those provided by our Linux Distro partners, through Source Build, etc.)
- Example:
-
DOTNET_NOLOGO: Set totrueto hide .NET welcome and telemetry messages on first run- Values:
true,1, oryesto mute messages - Values:
false,0, ornoto allow messages - Default:
false(messages are displayed) - Note: This flag does not affect telemetry collection itself
- Values:
-
DOTNET_CLI_TELEMETRY_SESSIONID: Seeds the initial telemetry session ID- When set, the CLI uses this value instead of generating a new GUID for the first
TelemetryClientcreated in the process - This is useful for correlating multiple
dotnetinvocations that belong to the same CI workflow, job, or higher-level user session - If not set, the CLI generates a new GUID per process as before
- When set, the CLI uses this value instead of generating a new GUID for the first
-
COPILOT_AGENT_SESSION_ID: Supplies the executing Copilot session ID forCopilotAgentSessionId. It does not replace the SDK's own session ID or enable telemetry. -
DOTNET_CLI_TELEMETRY_DISABLE_TRACE_EXPORT: Set to1,true, oryesto disable exporting trace telemetry to Azure Monitor (both persistence and upload). Metrics/OTLP export and the local disk log are unaffected. This does not disable telemetry collection itself — useDOTNET_CLI_TELEMETRY_OPTOUTfor that. -
DOTNET_CLI_TELEMETRY_STORAGE_PATH: Overrides the base directory used by Azure Monitor to persist trace telemetry (see Telemetry Delivery). Defaults toTelemetryStorageServiceunder the .NET user profile folder (e.g.~/.dotnet/TelemetryStorageService). Azure creates its own partitioned subdirectories. -
DOTNET_CLI_TELEMETRY_LOG_PATH: When set, trace telemetry activities are also written to this path as a local JSON log (used for diagnostics and testing). This does not affect Azure Monitor delivery.
-
Default Behavior:
- For Microsoft official builds: Telemetry is enabled by default (opt-out model)
- For non-Microsoft builds: Telemetry is disabled by default (controlled by
MICROSOFT_ENABLE_TELEMETRYcompile flag)
-
Connection String: Telemetry data is sent to Application Insights with instrumentation key:
74cc1c9e-3e6e-4d05-b3fc-dde9101d0254
In addition to the default Application Insights exporter, the SDK can also export telemetry via the OpenTelemetry Protocol (OTLP). The OTLP exporter is enabled when either of the following conditions is met:
-
The SDK-specific
DOTNET_CLI_TELEMETRY_ENABLE_EXPORTERenvironment variable is set to1,true, oryes, or -
Any of the standard OpenTelemetry OTLP exporter environment variables are set:
OTEL_EXPORTER_OTLP_ENDPOINT,OTEL_EXPORTER_OTLP_TRACES_ENDPOINT,OTEL_EXPORTER_OTLP_METRICS_ENDPOINTOTEL_EXPORTER_OTLP_PROTOCOL,OTEL_EXPORTER_OTLP_TRACES_PROTOCOL,OTEL_EXPORTER_OTLP_METRICS_PROTOCOLOTEL_EXPORTER_OTLP_HEADERS,OTEL_EXPORTER_OTLP_TRACES_HEADERS,OTEL_EXPORTER_OTLP_METRICS_HEADERSOTEL_EXPORTER_OTLP_TIMEOUT,OTEL_EXPORTER_OTLP_TRACES_TIMEOUT,OTEL_EXPORTER_OTLP_METRICS_TIMEOUT
and of course the overall OTel SDK disablement flag OTEL_SDK_DISABLED must not be
true
When the OTLP exporter is enabled, all standard OpenTelemetry OTLP environment variables (endpoint, protocol, headers, timeout, etc.) are honored by the OpenTelemetry SDK's OtlpExporterOptions to configure the export destination.
The CLI uses Azure Monitor OpenTelemetry Exporter 1.9.0 or later for trace serialization, persistent storage,
and delivery. TelemetryClient registers the exporter through
AddAzureMonitorTraceExporter, which installs Azure's shutdown-aware batch processor.
- Local invocations. On orderly shutdown, Azure persists queued trace batches before starting a background
drain. The SDK sets
Azure.Monitor.OpenTelemetry.Exporter.ShutdownDrainBudgetMillisecondsto zero, so it does not wait for that drain on successful exits. When a command returns a nonzero exit code, the SDK temporarily sets the drain budget to 300 ms and calls trace-providerShutdown(300), giving persistence and background delivery a bounded opportunity to finish. This is a maximum requested wait, not a sleep or delivery guarantee. The previous drain setting is restored afterward; metrics retain their separate 10-ms shutdown allowance. Both managed and Native AOT entry points pass the actual command exit code. A managed fallback can therefore use a separate 300-ms trace allowance in each runtime; there is no cross-runtime deadline coordination. Normal exports before shutdown remain network-first; this is not synchronous persistence of every ended span, and abrupt termination can lose queued spans. An upload already in flight can still delay shutdown. Successful local shutdown gives the trace batch processor 100 ms to finalize persistence; the zero drain budget prevents waiting for the subsequent upload. This is long enough for a cold exporter to complete its atomic file write without reintroducing an unbounded exit delay. Failed-command persistence is subject to the 300-ms timeout. - Subsequent invocations. Azure schedules an eager background drain after a 50-ms startup delay; actual start time also depends on thread scheduling and storage work. The two-minute periodic retry timer remains. Accepted payloads are deleted; retryable failures remain for later attempts. Storage partitioning, retention, leases, and response handling belong to Azure. Blobs written directly into the storage root by the previous SDK-owned exporter are not migrated or automatically consumed by Azure's partitioned store. They are left untouched; this migration does not delete old telemetry files.
Azure names each storage sub directory from the instrumentation key, user name, process name, and
AppContext.BaseDirectory. The base directory differs between dotnet.dll and dotnet-aot, so without an
override each entry point would drain only its own backlog. The SDK sets the
Azure.Monitor.OpenTelemetry.Exporter.StorageSubDirectory AppContext value to dotnet-cli (see
Azure/azure-sdk-for-net#62997). Every entry point
for a given user then shares one sub directory and drains telemetry that the others persisted.
3. CI invocations. The SDK sets Azure.Monitor.OpenTelemetry.Exporter.DisablePersistOnShutdown to true and
calls Shutdown with a finite timeout because another invocation may never run. The default CI
wait budget is five seconds, shared across trace and metric providers. A positive
DOTNET_CLI_TELEMETRY_SHUTDOWN_TIMEOUT_MS can shorten or extend it. That value also configures Azure's
network timeout. This selects network-first shutdown, not guaranteed ingestion: retryable failures can still
be persisted, and a timeout can leave telemetry undelivered.
4. Persistent MSBuild hosts. A logger finishes a build request with nonterminal ForceFlush, allowing the
same provider to handle later builds. Locally the SDK enables
Azure.Monitor.OpenTelemetry.Exporter.PersistOnForceFlush and gives trace persistence 100 ms; process exit uses
Shutdown. CI uses a bounded network-first flush. A force-flush result is not an ingestion acknowledgment.
These Azure settings are process-wide. OTLP-enabled invocations retain bounded provider shutdown, and the trace and metric providers share the configured wait budget. This bounds provider waits, not all process-exit work. Azure's zero drain-wait setting does not control OTLP delivery. Storage failures and abnormal process termination can still cause data loss; telemetry delivery remains best-effort.
The lifecycle behavior is covered by
AzureExporterLifecycleTests
using the real exporter, isolated storage, and a controlled HTTP transport. The test-only reflection hooks
disable background drains when asserting persisted payloads and are restored after each test. The retained
CLI subprocess test checks the
production managed assembly and normal muxer entry point. Live endpoint acceptance tests are skipped unless
explicitly enabled. Set DOTNET_CLI_TELEMETRY_E2E_ENABLED=true (or 1) to send synthetic telemetry to the SDK's
fixed destination, or set DOTNET_CLI_TELEMETRY_E2E_CONNECTION_STRING to opt in with another destination.
DOTNET_CLI_TELEMETRY_E2E_RUN_ID supplies a correlation ID for
checking downstream ingestion. HTTP acceptance alone does not verify arrival in a destination table.
1.9.0 or later must be leveraged, as older versions did not work well and we requested fixes. Our requested upstream shutdown fixes are documented in azure-sdk-for-net#61818 and azure-sdk-for-net#62340. They provide lifecycle-scoped persistence rather than the public persist-only/manual-drain API proposed in azure-sdk-for-net#60838.
This pipeline only applies to trace telemetry sent to Azure Monitor. Metrics, OTLP export, and the local disk
log are unaffected. Set DOTNET_CLI_TELEMETRY_DISABLE_TRACE_EXPORT to disable it.
-
First Time Use: Telemetry is only collected after the first-time-use notice has been shown and accepted (tracked via sentinel file)
-
Event Namespace: All telemetry events are automatically prefixed with
dotnet/cli/
Performance collectors such as PerfStar can opt into CLI phase timings by enabling
the dotnet-cli-perf meter. Built-in SDK telemetry and its OTLP exporter do not
enable this collection.
| Meter | Instrument | Unit | Tag |
|---|---|---|---|
dotnet-cli-perf |
dotnet.cli.activity.duration |
s (seconds) |
activity.name |
Each completed activity from either source (dotnet-cli or dotnet-cli-perf)
records its duration, tagged by operation name. To collect activity spans, subscribe to the relevant activity source. Skipped phases emit no activity; failed invocations still record their duration.
The dotnet-cli-perf source contains these activities:
| Activity | Measured work |
|---|---|
msbuild-submission |
Synchronous MSBuild invocation, including child/server wait time. For file-based projects, covers BeginBuild through EndBuild. |
release-property-discovery |
Project/solution discovery and PackRelease / PublishRelease evaluation to choose the default configuration. |
project-selection |
Run/test project loading, evaluation when needed, and project-instance creation, including cached snapshots. |
device-discovery |
Optional restore, ComputeAvailableDevices execution, and reading its results. |
test-project-discovery |
Microsoft.Testing.Platform (MTP) outer- and inner-framework project evaluation for automatic device selection. |
test-target-framework-discovery |
MTP framework evaluation when --device is given without a target framework. |
test-environment-discovery |
MTP environment-variable support checks and properties-file preparation before a project build. |
Every telemetry event automatically includes these common properties:
| Property | Description | Example Value |
|---|---|---|
| OS Version | Operating system version | Microsoft Windows 10.0.14393 |
| OS Platform | Operating system platform | Windows, Linux, OSX |
| OS Architecture | Operating system architecture | X64, X86, Arm64 |
| Output Redirected | Whether console output is redirected | True or False |
| Runtime Id | .NET runtime identifier | win10-x64, linux-x64 |
| Product Version | .NET SDK version | 8.0.100 |
| Telemetry Profile | Custom telemetry profile (if set via env var) | Custom value or null |
| Docker Container | Whether running in Docker container | True or False |
| CI | Whether running in CI environment | True or False |
| LLM | Detected LLM/assistant environment identifiers (comma-separated) | claude, cursor, gemini, copilot, codex, aider, plandex, amp, qwen, droid, opencode, zed, kimi, openhands, goose, cline, roo, windsurf, generic_agent |
| Current Path Hash | SHA256 hash of current directory path | Hashed value |
| Machine ID | SHA256 hash of machine MAC address (or GUID if unavailable) | Hashed value |
| Machine ID Old | Legacy machine ID for compatibility | Hashed value |
| Device ID | Device identifier | Device-specific ID |
| Kernel Version | OS kernel version | Darwin 17.4.0, Linux 4.9.0 |
| Installation Type | How the SDK was installed | Installation method |
| Product Type | Type of .NET product | Product identifier |
| Libc Release | Libc release information | Libc release version |
| Libc Version | Libc version information | Libc version number |
| SessionId | Unique session identifier | GUID or CI-specific correlation identifier |
| CopilotAgentSessionId | Executing Copilot session ID, normalized to match Copilot telemetry, or not_present when unavailable |
UUID, 64-character lowercase SHA-256 digest, or not_present |
CopilotAgentSessionId lets SDK telemetry be correlated with the executing Copilot
session. When telemetry is enabled, it reads COPILOT_AGENT_SESSION_ID and follows
Copilot's normalization:
| Environment value | Telemetry value |
|---|---|
| UUID recognized by Copilot | Original string, including letter case |
| Other nonempty value | SHA-256 of the original UTF-8 bytes, as lowercase hex; no trimming or case normalization |
| Missing or empty | not_present |
A missing telemetry field means collection support is unknown, including older SDKs.
not_present means no Copilot context was observed, not proof of a human invocation.
A literal not_present environment value is hashed. Context is captured before each
event is queued, including in reused MSBuild hosts. Existing telemetry opt-out settings
and the SDK's own SessionId are unchanged.
When telemetry is enabled, the CLI asynchronously determines whether the current user is internal to Microsoft and enriches trace activities with these tags:
| Tag | Description |
|---|---|
dotnet.cli.is_microsoft_internal |
true when a probe finds Microsoft-internal evidence. It is false when detection completes without that evidence. |
dotnet.cli.microsoft_internal_source |
The probe that found the evidence. Emitted only for a positive result. |
dotnet.cli.microsoft_internal_alias |
A normalized local account alias when local identity evidence supplies one. Emitted only for a positive result outside CI. |
dotnet.cli.microsoft_internal_domain |
A normalized corporate domain when local identity evidence supplies one. Emitted only for a positive result outside CI. |
The detector first uses local OS and account evidence. Outside CI, it can also use
existing GitHub CLI, Copilot CLI, or GitHub-token environment credentials to ask GitHub
whether the authenticated account is a member of the microsoft organization. Tokens
are sent only to GitHub's API for that check; they are not cached or added to telemetry.
GitHub logins are not used as telemetry aliases. GitHub identity probes are skipped in
CI, and alias and domain tags are suppressed in CI.
The implementation of this classification is isolated in the AOT-compatible
Microsoft.DotNet.Cli.InternalMicrosoft
library. It does not reference OpenTelemetry or emit telemetry. Each detection mechanism
implements
IInternalMicrosoftDetectionProvider.
The detector filters providers by platform and CI support, groups them into ordered
stages, and owns orchestration, deadlines, result selection, and caching.
The CLI telemetry adapter maps the classification result to tags on normal CLI activities. It does not emit separate detector-health activities.
Results are cached for six hours under
~/.dotnet/internal-microsoft/detector.json (relative to the configured .NET user
profile). The cache contains the classification, source, CI mode, and timestamp. Outside
CI, it can also contain an optional local alias and domain. The cache never contains
credentials. Failed or timed-out detection is not cached. Probe execution, diagnostics,
and shutdown waiting are bounded. Detection begins after telemetry-provider construction,
is not synchronously awaited during startup, and cannot indefinitely delay command
completion. See
InternalMicrosoftDetector
and
InternalMicrosoftTelemetry
for the separate detection and telemetry integration layers.
When fired: At the end of every dotnet CLI command execution
Properties:
exitCode: The exit code of the command
Description: Tracks the completion status of any dotnet command
When fired: When CLI schema is generated or accessed
Properties:
command: The command hierarchy as a string
Description: Tracks schema generation for the CLI
When fired: For every top-level dotnet command
Properties:
verb: Top-level command name (build, restore, publish, etc.)
Measurements: Performance data (startup time, parse time, etc.)
Description: Tracks usage patterns of main dotnet commands
When fired: For subcommands and specific command options
Properties: Various depending on command (verbosity, configuration, framework, etc.)
Description: Tracks detailed command option usage
When fired: When a command is resolved through the command factory
Properties:
commandName: SHA256 hash of command namecommandResolver: Type of command resolver used
Description: Tracks how commands are resolved in the CLI
When fired: When installation success is reported
Properties:
exeName: Name of the install method that was used - one ofdebianpackage, a specific macOS.pkgfile name, or a specific Windows exe installer file name.
Description: Tracks successful tool installations
When fired: When unhandled exceptions occur in the main CLI
Properties:
exceptionType: Type of exceptiondetail: Exception details (sensitive message removed)
Description: Tracks unhandled exceptions for diagnostics
When fired: Once per dotnet test Microsoft.Testing.Platform run that planned at least one artifact post-processing job. Runs that plan nothing (no mergeable artifacts) emit nothing.
Properties:
jobs_planned: Number of elected test-application relaunches plannedjobs_executed: Number of jobs actually attempted (differs fromjobs_plannedonly when the run was cancelled mid-way)jobs_failed: Number of jobs that reported a failureartifact_count: Total number of input artifacts across all planned groupskinds: Semicolon-separated, sorted, distinct artifact kinds that were merged; any kind outside a fixed well-known list is reported asotherextensions: Semicolon-separated, sorted, distinct file extensions from file-extension fallback groups; any extension outside a fixed well-known list is reported asotherduration_ms: Total wall-clock time spent post-processing, in milliseconds
Description: Tracks how often artifact post-processing runs and on which shipped formats. No file paths, artifact contents, project names, or user-defined identifiers are collected — that is why unknown kinds and extensions are bucketed as other.
When fired: During template package installation
Properties:
CountOfThingsToInstall: Number of template packages being installed
Description: Tracks template package installation operations
When fired: When creating a new project from template
Properties:
language: Template language (C#, F#, VB, etc)argument-error: Whether there were argument errors ("True"/"False")framework: Framework choice (only sent for Microsoft-authored templates)template-name: SHA256 hash of template identitytemplate-short-name: SHA256 hash of template short namespackage-name: SHA256 hash of package namepackage-version: SHA256 hash of package versionis-template-3rd-party: Whether template is third-partycreate-success: Whether creation succeededauth: Authentication choice (only sent for Microsoft-authored templates)
Description: Tracks template usage and creation success
MSBuildLogger collects the
existing events below. MSBuild loads the logger from the SDK. The logger can run in the
CLI process, a child MSBuild process, or a persistent MSBuild server.
The logger creates an internal activity for each build. When trace context is available, the activity is a child of the invoking CLI trace. Server reuse changes telemetry delivery and correlation only. It does not change the listed data points or properties.
The activity remains open through logger shutdown because MSBuild emits the final build
telemetry event after BuildFinished (see
dotnet/sdk#55749).
TelemetryHostMatrixTests validates the real OTLP export path for cold and hot MSBuild
servers, in-process builds, server fallback, and telemetry opt-out. The test installs the
pinned Aspire CLI version from the repository's configured feeds, runs its dashboard on
loopback endpoints, and verifies exported events through the dashboard telemetry API.
When fired: When the Roslyn compiler output cache
is enabled and a compilation runs on the compiler server through the MSBuild Csc or Vbc task
Properties:
cachestatus: Cache lookup result:hitormissstoreresult: Cache store result:none,stored,skippedrace,skippedexists, orfailedlanguage: Compiler language:C#orVisual Basickeycomputems: Milliseconds spent computing the deterministic cache keyrestorems: Milliseconds spent attempting to restore a cached resultstorems: Milliseconds spent storing the result; omitted when no store was attemptedcompilems: Milliseconds spent compiling and emitting on a cache miss; omitted on a cache hit or when compilation failed
Description: Tracks the effectiveness and performance of the experimental Roslyn compiler output cache
When fired: When target framework is evaluated
Properties:
TargetFrameworkVersion: Target framework versionRuntimeIdentifier: Runtime identifierSelfContained: Whether self-containedUseApphost: Whether using app hostOutputType: Output type (Exe, Library, etc.)UseArtifactsOutput: Whether using artifacts outputArtifactsPathLocationType: Artifacts path location type - one ofExplicitly Specified,DirectoryBuildPropsFolder, orProjectFolder.
Description: Tracks target framework configurations
When fired: When exceptions occur in SDK-provided MSBuild tasks
Properties:
exceptionType: Exception typedetail: Exception details (message removed)
Description: Tracks exceptions in MSBuild task execution
When fired: During the Publish Target
Properties: Gathers the values of the following MSBuild Properties if they are set in the project file or via command line:
- PublishReadyToRun
- PublishSingleFile
- PublishTrimmed
- PublishAot
- PublishProtocol
Description: Tracks publish-related properties
When fired: During workload publish operations
Properties: Gathers the values of the following MSBuild Properties if they are set in the project file or via command line:
- TargetPlatformIdentifier: TargetPlatformIdentifier
- RuntimeIdentifier: RuntimeIdentifier
- BlazorWasm: _WorkloadUsesBlazorWasm
- WasmSDK: _WorkloadUsesWasmSDK
- UsesMaui: UseMaui
- UsesMobileSDKOnly: _WorkloadUsesMobileSDKOnly
- UsesOtherMobileSDK: _WorkloadUsesOther
- MonoAOT: _WorkloadUsesMonoAOT
- NativeAOT: _WorkloadUsesNativeAOT
- Interp: _WorkloadUsesInterpreter
- LibraryMode: _WorkloadUsesLibraryMode
- ResolvedRuntimePack: _MonoWorkloadRuntimePackPackageVersion
- StripILAfterAOT: _WorkloadUsesStripILAfterAOT
Description: Tracks workload-specific publish properties
When fired: During ReadyToRun compilation
Properties: Gathers the values of the following MSBuild Properties and Items if they are set in the project file or via command line:
- PublishReadyToRunUseCrossgen2: PublishReadyToRunUseCrossgen2
- Crossgen2PackVersion: ResolvedCrossgen2Pack.NuGetPackageVersion
- CompileListCount: _ReadyToRunCompileList->Count()
- FailedCount: _ReadyToRunCompilationFailures->Count()
Description: Tracks ReadyToRun compilation usage
See MSBuild Telemetry Documentation for details on these events.
See Container Telemetry Documentation for details.
When fired: When MSBuild project evaluation occurs during dotnet new
Properties (hashed):
ProjectPath: Project pathSdkStyleProject: Whether it's SDK-style projectStatus: Evaluation statusTargetFrameworks: Target frameworks
Measurements:
EvaluationTime: Total evaluation time in millisecondsInnerEvaluationTime: Inner evaluation time in milliseconds
Description: Tracks MSBuild evaluation performance for new projects
- Ensure that all telemetry events and properties are accurately documented
- Review and update common properties as needed
- Add new events or properties as they are introduced in the .NET SDK
- Follow the pre-existing format