/// <summary> /// Initializes a new instance of the <see cref="CrashTelemetry" /> class. /// </summary> /// <param name="crash">The crash.</param> internal CrashTelemetry(CrashData crash) { this.Data = crash ?? new CrashData(); if (this.Data.headers == null) { this.Data.headers = new CrashDataHeaders(); } this.headers = new CrashTelemetryHeaders(this.Data.headers); this.adapterThreads = new AdapterList<CrashTelemetryThread, CrashDataThread>( new List<CrashTelemetryThread>(), this.Data.threads, threadPublic => threadPublic == null ? null : threadPublic.Data, threadPrivate => threadPrivate == null ? null : new CrashTelemetryThread(threadPrivate)); this.adapterThreads.SyncPrivateToPublic(); this.adapterBinaries = new AdapterList<CrashTelemetryBinary, CrashDataBinary>( new List<CrashTelemetryBinary>(), this.Data.binaries, binaryPublic => binaryPublic == null ? null : binaryPublic.Data, binaryPrivate => binaryPrivate == null ? null : new CrashTelemetryBinary(binaryPrivate)); this.adapterBinaries.SyncPrivateToPublic(); this.context = new TelemetryContext(new Dictionary<string, string>(), new Dictionary<string, string>()); this.Attachments = new Attachments(); }
/// <summary> /// Initializes a new instance of the <see cref="MetricTelemetry"/> class with empty /// properties. /// </summary> public MetricTelemetry() { this.Data = new MetricData(); this.Metric = new DataPoint(); this.context = new TelemetryContext(this.Data.properties, new Dictionary<string, string>()); // We always have a single 'metric'. this.Data.metrics.Add(this.Metric); }
/// <summary> /// Initializes a new instance of the <see cref="RequestTelemetry"/> class. /// </summary> public RequestTelemetry() { this.Data = new RequestData(); this.context = new TelemetryContext(this.Data.properties, new Dictionary<string, string>()); // Initialize required fields this.Id = WeakConcurrentRandom.Instance.Next().ToString(CultureInfo.InvariantCulture); this.ResponseCode = "200"; this.Success = true; }
public void OperationIsNotNullByDefaultToPreventNullReferenceExceptionsInUserCode() { var context = new TelemetryContext(); Assert.NotNull(context.Operation); }
public void InstrumentationKeySetterThrowsArgumentNullExceptionWhenValueIsNullToPreventNullReferenceExceptionsLater() { var context = new TelemetryContext(); Assert.Throws <ArgumentNullException>(() => context.InstrumentationKey = null); }
public void SerializeWritesCopiedComponentContext() { var context = new TelemetryContext(); context.Component.Version = "Test Value"; string json = CopyAndSerialize(context); Assert.Contains("\"" + ContextTagKeys.Keys.ApplicationVersion + "\":\"Test Value\"", json, StringComparison.OrdinalIgnoreCase); }
/// <summary> /// Initializes a new instance of the <see cref="ExceptionTelemetry"/> class with empty properties. /// </summary> public ExceptionTelemetry() { this.Data = new ExceptionData(); this.context = new TelemetryContext(this.Data.properties, new Dictionary <string, string>()); this.HandledAt = default(ExceptionHandledAt); }
/// <summary> /// Initializes a new instance of the <see cref="SessionStateTelemetry"/> class. /// </summary> public SessionStateTelemetry() { this.Data = new SessionStateData(); this.context = new TelemetryContext(new Dictionary<string, string>(), new Dictionary<string, string>()); }
/// <summary> /// Initializes a new instance of the <see cref="SessionStateTelemetry"/> class. /// </summary> public SessionStateTelemetry() { this.Data = new SessionStateData(); this.context = new TelemetryContext(new Dictionary <string, string>(), new Dictionary <string, string>()); }
public void InstrumentationKeySetterThrowsArgumentNullExceptionWhenValueIsNullToPreventNullReferenceExceptionsLater() { var context = new TelemetryContext(); Assert.Throws<ArgumentNullException>(() => context.InstrumentationKey = null); }
public void ConstructorInitializesTagsWithThreadSafeDictionaryObjects() { var context = new TelemetryContext(); Assert.IsType<SnapshottingDictionary<string, string>>(context.Tags); }
public void InstrumentationKeyIsNotNullByDefaultToPreventNullReferenceExceptionsInUserCode() { var context = new TelemetryContext(); Assert.NotNull(context.InstrumentationKey); }
private static string CopyAndSerialize(TelemetryContext source) { // Create a copy of the source context to verify that Serialize writes property values stored in tags // dictionary even if their context objects (User, Location, etc) haven't been initialized yet. var target = new TelemetryContext(); target.Initialize(source, source.InstrumentationKey); using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture)) { ((IJsonSerializable)target).Serialize(new JsonWriter(stringWriter)); return stringWriter.ToString(); } }
public void SerializeWritesCopiedSessionContext() { var context = new TelemetryContext(); context.Session.Id = "Test Value"; string json = CopyAndSerialize(context); Assert.Contains("\"" + ContextTagKeys.Keys.SessionId + "\":\"Test Value\"", json, StringComparison.OrdinalIgnoreCase); }
public void SerializeWritesCopiedLocationContext() { var context = new TelemetryContext(); context.Location.Ip = "1.2.3.4"; string json = CopyAndSerialize(context); Assert.Contains("\"" + ContextTagKeys.Keys.LocationIp + "\":\"1.2.3.4\"", json, StringComparison.OrdinalIgnoreCase); }
public void InternalIsNotNullByDefaultToPreventNullReferenceExceptionInUserCode() { TelemetryContext context = new TelemetryContext(); Assert.NotNull(context.Internal); }
/// <summary> /// Initializes a new instance of the <see cref="PageViewTelemetry"/> class. /// </summary> public PageViewTelemetry() { this.Data = new PageViewData(); this.context = new TelemetryContext(this.Data.properties, new Dictionary<string, string>()); }
internal void Initialize(TelemetryContext source, string instrumentationKey) { Property.Initialize(ref this.instrumentationKey, instrumentationKey); if (source.tags != null && source.tags.Count > 0) { Utils.CopyDictionary(source.tags, this.Tags); } }
public void InitializeCopiesTags() { string tagName = "TestTag"; string tagValue = "TestValue"; var source = new TelemetryContext { Tags = { { tagName, tagValue } } }; var target = new TelemetryContext(); target.Initialize(source, source.InstrumentationKey); Assert.Equal(tagValue, target.Tags[tagName]); }
/// <summary> /// Initializes a new instance of the <see cref="TraceTelemetry"/> class. /// </summary> public TraceTelemetry() { this.Data = new MessageData(); this.context = new TelemetryContext(this.Data.properties, new Dictionary<string, string>()); }
/// <summary> /// Initializes a new instance of the <see cref="ExceptionTelemetry"/> class with empty properties. /// </summary> public ExceptionTelemetry() { this.Data = new ExceptionData(); this.context = new TelemetryContext(this.Data.properties, new Dictionary<string, string>()); this.HandledAt = default(ExceptionHandledAt); }
/// <summary> /// Initializes a new instance of the <see cref="DependencyTelemetry"/> class. /// </summary> public DependencyTelemetry() { this.Data = new RemoteDependencyData() { kind = DataPointType.Aggregation }; this.context = new TelemetryContext(this.Data.properties, new Dictionary<string, string>()); this.Data.dependencyKind = BondDependencyKind.Other; }
public void InitializeSetsTelemetryInstrumentationKeyFromArgument() { var source = new TelemetryContext { InstrumentationKey = "TestValue" }; var target = new TelemetryContext(); target.Initialize(source, "OtherTestValue"); Assert.Equal("OtherTestValue", target.InstrumentationKey); }
public void ConstructorInitializesTagsWithThreadSafeDictionaryObjects() { var context = new TelemetryContext(); Assert.IsType <SnapshottingDictionary <string, string> >(context.Tags); }
public void InitializeDoesNotOverrideTelemetryInstrumentationKey() { var source = new TelemetryContext { InstrumentationKey = "SourceValue" }; var target = new TelemetryContext { InstrumentationKey = "TargetValue" }; target.Initialize(source, source.InstrumentationKey); Assert.Equal("TargetValue", target.InstrumentationKey); }
public void InitializeDoesNotOverwriteTags() { string tagName = "TestTag"; var source = new TelemetryContext { Tags = { { tagName, "Source Value" } } }; var target = new TelemetryContext { Tags = { { tagName, "Target Value" } } }; target.Initialize(source, source.InstrumentationKey); Assert.Equal("Target Value", target.Tags[tagName]); }