Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
83b291f
initial draft for public context
harsimar Mar 3, 2026
1b65fa9
component context
harsimar Mar 4, 2026
1426546
add device version
harsimar Mar 5, 2026
f817df5
public cloud
harsimar Mar 6, 2026
13b81bb
remove context not in schema, remove metric context support, need to …
harsimar Mar 7, 2026
38e697b
p1 - add processors, will use later
harsimar Mar 10, 2026
e4a8793
more changes, figure out why logging processor doesn't work in tests …
harsimar Mar 13, 2026
485ff79
cleanup
harsimar Mar 16, 2026
eb4db4d
Add TelemetryContextLogProcessorTests and optimize TelemetryContext p…
rajkumar-rangaraj Mar 20, 2026
696acc8
Add TelemetryContext processors for Activity and Logger in Applicatio…
rajkumar-rangaraj Mar 20, 2026
2985a41
fix user agent
harsimar Mar 20, 2026
0883c23
bring back user agent & update documentation
harsimar Mar 20, 2026
888664c
Merge branch 'main' into harskaur/publicContext
harsimar Mar 23, 2026
c0abfd4
Merge branch 'main' into harskaur/publicContext
harsimar Mar 23, 2026
956a581
Remove Cloud and Component context settings from HomeController example
Copilot Mar 27, 2026
384a7c3
Replace real connection string with dummy value; remove Setting Conte…
Copilot Mar 27, 2026
7d23d45
Replace Assert.Fail with Assert.True(false, ...) for xUnit v2 compati…
Copilot Mar 27, 2026
97e9ae9
pr comments
harsimar Mar 30, 2026
4c30f54
Merge branch 'harskaur/publicContext' of https://github.com/microsoft…
harsimar Mar 30, 2026
13b1932
Merge branch 'main' into harskaur/publicContext
harsimar Mar 30, 2026
c984b3a
Merge branch 'main' into harskaur/publicContext
rajkumar-rangaraj Mar 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Device.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.DeviceContext
Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Session.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.SessionContext
Microsoft.ApplicationInsights.Extensibility.Implementation.DeviceContext
Microsoft.ApplicationInsights.Extensibility.Implementation.DeviceContext.Id.get -> string
Microsoft.ApplicationInsights.Extensibility.Implementation.DeviceContext.Id.set -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.DeviceContext.Model.get -> string
Microsoft.ApplicationInsights.Extensibility.Implementation.DeviceContext.Model.set -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.DeviceContext.OperatingSystem.get -> string
Microsoft.ApplicationInsights.Extensibility.Implementation.DeviceContext.OperatingSystem.set -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.DeviceContext.Type.get -> string
Microsoft.ApplicationInsights.Extensibility.Implementation.DeviceContext.Type.set -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.OperationContext.SyntheticSource.get -> string
Microsoft.ApplicationInsights.Extensibility.Implementation.OperationContext.SyntheticSource.set -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.SessionContext
Microsoft.ApplicationInsights.Extensibility.Implementation.SessionContext.Id.get -> string
Microsoft.ApplicationInsights.Extensibility.Implementation.SessionContext.Id.set -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.UserContext.AccountId.get -> string
Microsoft.ApplicationInsights.Extensibility.Implementation.UserContext.AccountId.set -> void
Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Component.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.ComponentContext
Microsoft.ApplicationInsights.Extensibility.Implementation.ComponentContext
Microsoft.ApplicationInsights.Extensibility.Implementation.ComponentContext.Version.get -> string
Microsoft.ApplicationInsights.Extensibility.Implementation.ComponentContext.Version.set -> void
Microsoft.ApplicationInsights.DataContracts.TelemetryContext.Cloud.get -> Microsoft.ApplicationInsights.Extensibility.Implementation.CloudContext
Microsoft.ApplicationInsights.Extensibility.Implementation.CloudContext
Microsoft.ApplicationInsights.Extensibility.Implementation.CloudContext.RoleName.get -> string
Microsoft.ApplicationInsights.Extensibility.Implementation.CloudContext.RoleName.set -> void
Microsoft.ApplicationInsights.Extensibility.Implementation.CloudContext.RoleInstance.get -> string
Microsoft.ApplicationInsights.Extensibility.Implementation.CloudContext.RoleInstance.set -> void
60 changes: 0 additions & 60 deletions BASE/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,66 +418,6 @@ Note: Setting an OpenTelemetry Sampler via `builder.SetSampler()` is currently u



### Setting Context Properties

In version 3.x, the following properties remain publicly settable on telemetry items:

**Available Context Properties:**
| Context | Properties | Notes |
|---------|-----------|-------|
| `User` | `Id`, `AuthenticatedUserId`, `UserAgent` | Be mindful of PII |
| `Operation` | `Name`| |
| `Location` | `Ip` | |
| `GlobalProperties` | (dictionary) | Custom key-value pairs |

**Example: Setting context on a telemetry item**

```csharp
var request = new RequestTelemetry
{
Name = "ProcessOrder",
Timestamp = DateTimeOffset.UtcNow,
Duration = TimeSpan.FromMilliseconds(150),
ResponseCode = "200",
Success = true
};

// Set user context (be mindful of PII)
request.Context.User.Id = userId;
request.Context.User.AuthenticatedUserId = authenticatedUserId;

// Set operation context
request.Context.Operation.Name = "ProcessOrder";

// Set location context
request.Context.Location.Ip = clientIpAddress;

// Set custom properties via GlobalProperties
request.Context.GlobalProperties["Environment"] = "Production";
request.Context.GlobalProperties["DataCenter"] = "WestUS";

telemetryClient.TrackRequest(request);
```

**Recommended: Use OpenTelemetry Resource Attributes**

For service-level context (cloud role, version, environment), the recommended approach in 3.x is to use OpenTelemetry Resource attributes, which apply to all telemetry automatically:

```csharp
configuration.ConfigureOpenTelemetryBuilder(builder =>
{
builder.ConfigureResource(r => r
.AddService(
serviceName: "OrderProcessingService", // Maps to Cloud.RoleName
serviceVersion: "1.2.3", // Maps to Application Version
serviceInstanceId: Environment.MachineName) // Maps to Cloud.RoleInstance
.AddAttributes(new Dictionary<string, object>
{
["deployment.environment"] = "Production"
}));
});
```

### Dependency Injection

In applications using Microsoft.Extensions.DependencyInjection:
Expand Down
Loading
Loading