當前位置: 首頁>>代碼示例>>C#>>正文


C# DataContracts.TelemetryContext類代碼示例

本文整理匯總了C#中Microsoft.ApplicationInsights.DataContracts.TelemetryContext的典型用法代碼示例。如果您正苦於以下問題:C# TelemetryContext類的具體用法?C# TelemetryContext怎麽用?C# TelemetryContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TelemetryContext類屬於Microsoft.ApplicationInsights.DataContracts命名空間,在下文中一共展示了TelemetryContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DependencyTelemetry

 /// <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);
     this.Data.dependencyKind = BondDependencyKind.Other;
     this.Id = Convert.ToBase64String(BitConverter.GetBytes(WeakConcurrentRandom.Instance.Next()));
 }
開發者ID:ZeoAlliance,項目名稱:ApplicationInsights-dotnet,代碼行數:10,代碼來源:DependencyTelemetry.cs

示例2: Initialize

 public void Initialize(TelemetryContext context)
 {
     context.User.Id = Environment.UserName;
     context.Session.Id = Guid.NewGuid().ToString();
     context.Device.OperatingSystem = Environment.OSVersion.ToString();
     context.Device.Language = CultureInfo.CurrentCulture.DisplayName;
 }
開發者ID:chiccorosso,項目名稱:Sdl-Community,代碼行數:7,代碼來源:UserSessionInitializer.cs

示例3: InitializeSetsSdkVersionPropertyOfGivenTelemetry

        public void InitializeSetsSdkVersionPropertyOfGivenTelemetry()
        {
            var initializer = new SdkVersionPropertyContextInitializer();
            var telemetryContext = new TelemetryContext();
            initializer.Initialize(telemetryContext);

            Assert.NotNull(telemetryContext.Internal.SdkVersion);
        }
開發者ID:JoseCarlosMM,項目名稱:ApplicationInsights-dotnet,代碼行數:8,代碼來源:SdkVersionPropertyContextInitializerTest.cs

示例4: WriteTelemetryContext

 public static void WriteTelemetryContext(IJsonWriter json, TelemetryContext context)
 {
     if (context != null)
     {
         json.WriteProperty("iKey", context.InstrumentationKey);
         json.WriteProperty("tags", context.Tags);
     }
 }
開發者ID:ZeoAlliance,項目名稱:ApplicationInsights-dotnet,代碼行數:8,代碼來源:Telemetry.cs

示例5: Initialize

        /// <summary>
        /// Initializes the given <see cref="T:Microsoft.ApplicationInsights.DataContracts.TelemetryContext"/>.
        /// </summary>
        public void Initialize(TelemetryContext context)
        {
            if (context == null)
                return;

            if (string.IsNullOrWhiteSpace(context.Component.Version))
                context.Component.Version = _applicationVersion;
        }
開發者ID:alancameronwills,項目名稱:SLAB_AppInsights,代碼行數:11,代碼來源:ApplicationVersionContextInitializer.cs

示例6: Initialize

        /// <summary>
        /// Initializes the given <see cref="T:Microsoft.ApplicationInsights.DataContracts.TelemetryContext"/>.
        /// </summary>
        public void Initialize(TelemetryContext context)
        {
            if (context == null)
                return;

            if (string.IsNullOrWhiteSpace(context.Device.OperatingSystem))
                context.Device.OperatingSystem = _osVersion.Value;
        }
開發者ID:alancameronwills,項目名稱:SLAB_AppInsights,代碼行數:11,代碼來源:OsVersionContextInitializer.cs

示例7: Initialize

 /// <summary>
 /// Adds a telemetry property for the version of SDK.
 /// </summary>
 public void Initialize(TelemetryContext context)
 {
     var version = LazyInitializer.EnsureInitialized(ref this.sdkVersion, this.GetAssemblyVersion);
     if (string.IsNullOrEmpty(context.Internal.SdkVersion))
     {
         context.Internal.SdkVersion = version;
     }
 }
開發者ID:Assaf-Neufeld,項目名稱:ApplicationInsights-dotnet,代碼行數:11,代碼來源:SdkVersionPropertyContextInitializer.cs

示例8: MetricTelemetry

        /// <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);
        }
開發者ID:jwChung,項目名稱:ApplicationInsights-dotnet,代碼行數:13,代碼來源:MetricTelemetry.cs

示例9: InitializeDoesNotOverrideTelemetryInstrumentationKey

        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);
        }
開發者ID:ZeoAlliance,項目名稱:ApplicationInsights-dotnet,代碼行數:9,代碼來源:TelemetryContextTest.cs

示例10: RequestTelemetry

        /// <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>());
            this.Id = Convert.ToBase64String(BitConverter.GetBytes(WeakConcurrentRandom.Instance.Next()));

            this.ResponseCode = "200";
            this.Success = true;
        }
開發者ID:iusafaro,項目名稱:ApplicationInsights-dotnet,代碼行數:12,代碼來源:RequestTelemetry.cs

示例11: InitializeSetsTelemetryInstrumentationKeyFromArgument

        public void InitializeSetsTelemetryInstrumentationKeyFromArgument()
        {
            var source = new TelemetryContext { InstrumentationKey = "TestValue" };
            var target = new TelemetryContext();

            target.Initialize(source, "OtherTestValue");

            Assert.Equal("OtherTestValue", target.InstrumentationKey);
        }
開發者ID:ZeoAlliance,項目名稱:ApplicationInsights-dotnet,代碼行數:9,代碼來源:TelemetryContextTest.cs

示例12: RequestTelemetry

        /// <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.Context.Operation.Id = WeakConcurrentRandom.Instance.Next().ToString(CultureInfo.InvariantCulture);
            this.ResponseCode = "200";
            this.Success = true;
        }
開發者ID:JoseCarlosMM,項目名稱:ApplicationInsights-dotnet,代碼行數:13,代碼來源:RequestTelemetry.cs

示例13: InitializeDoesNotOverwriteTags

        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]);
        }
開發者ID:ZeoAlliance,項目名稱:ApplicationInsights-dotnet,代碼行數:10,代碼來源:TelemetryContextTest.cs

示例14: Initialize

 public void Initialize(TelemetryContext context)
 {
     context.User.Id = Environment.UserName;
     context.Session.Id = Guid.NewGuid().ToString("D");
     context.Device.Id = Environment.MachineName;
     context.Device.RoleInstance = Environment.MachineName;
     context.Device.OperatingSystem = Environment.OSVersion.ToString();
     context.Component.Version = typeof(SessionInitializer).Assembly.GetName().Version.ToString();
     context.Device.RoleName = Assembly.GetEntryAssembly().GetName().Name;
 }
開發者ID:joyhui,項目名稱:NuGet.Jobs,代碼行數:10,代碼來源:SessionInitializer.cs

示例15: ContextInitializerDoesNotOverrideMachineName

        public void ContextInitializerDoesNotOverrideMachineName()
        {
            var source = new DomainNameRoleInstanceContextInitializer();
            var telemetryContext = new TelemetryContext();
            telemetryContext.Device.RoleInstance = "Test";

            source.Initialize(telemetryContext);

            Assert.Equal("Test", telemetryContext.Device.RoleInstance);
        }
開發者ID:jango2015,項目名稱:ApplicationInsights-aspnet5,代碼行數:10,代碼來源:DomainNameRoleInstanceContextInitializerTests.cs


注:本文中的Microsoft.ApplicationInsights.DataContracts.TelemetryContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。