<PackageReference Include="Microsoft.ApplicationInsights" Version="2.23.0" />

Microsoft.ApplicationInsights.DataContracts.TelemetryContext

public sealed class TelemetryContext
Represents a context for sending telemetry to the Application Insights service. Learn more
public const long FlagDropIdentifiers = 2097152

Value for the flag that indicates that server should not store IP address from incoming events.

public CloudContext Cloud { get; }

Gets the object describing the cloud tracked by this TelemetryContext.

public ComponentContext Component { get; }

Gets the object describing the component tracked by this TelemetryContext.

public DeviceContext Device { get; }

Gets the object describing the device tracked by this TelemetryContext.

public long Flags { get; set; }

Gets or sets flags which controls events priority and endpoint behavior.

public IDictionary<string, string> GlobalProperties { get; }

Gets a dictionary of application-defined property values which are global in scope. Future SDK versions could serialize this separately from the item level properties. Learn more

public string InstrumentationKey { get; set; }

Gets or sets the default instrumentation key for all ITelemetry objects logged in this TelemetryContext.

public LocationContext Location { get; }

Gets the object describing a location tracked by this TelemetryContext.

public OperationContext Operation { get; }

Gets the object describing a operation tracked by this TelemetryContext. Learn more

public IDictionary<string, string> Properties { get; }

Gets a dictionary of application-defined property values. Learn more

public SessionContext Session { get; }

Gets the object describing a user session tracked by this TelemetryContext.

public UserContext User { get; }

Gets the object describing a user tracked by this TelemetryContext.

Initializes a new instance of the TelemetryContext class.

public void StoreRawObject(string key, object rawObject, bool keepForInitializationOnly = true)

Stores the raw object against the key specified. Use this to store raw objects from data collectors so that TelemetryInitializers can access them to extract additional details to enrich telemetry. Objects stored through this method are not automatically serialized and sent to the backend. They are shared (i.e not cloned) if multiple sinks are configured, so sinks should treat them as read-only.

public bool TryGetRawObject(string key, out object rawObject)

Returns the raw object with the given key. Objects retrieved here are not automatically serialized and sent to the backend. They are shared (i.e not cloned) if multiple sinks are configured, so sinks should treat them as read-only.