本文整理汇总了C#中ITelemetry类的典型用法代码示例。如果您正苦于以下问题:C# ITelemetry类的具体用法?C# ITelemetry怎么用?C# ITelemetry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITelemetry类属于命名空间,在下文中一共展示了ITelemetry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnInitializeTelemetry
/// <summary>
/// Implements initialization logic.
/// </summary>
/// <param name="platformContext">Http context.</param>
/// <param name="requestTelemetry">Request telemetry object associated with the current request.</param>
/// <param name="telemetry">Telemetry item to initialize.</param>
protected override void OnInitializeTelemetry(HttpContext platformContext, RequestTelemetry requestTelemetry, ITelemetry telemetry)
{
if (string.IsNullOrEmpty(telemetry.Context.Operation.SyntheticSource))
{
if (platformContext != null)
{
var request = platformContext.GetRequest();
if (request != null && !string.IsNullOrEmpty(request.UserAgent))
{
// We expect customers to configure telemetry initializer before they add it to active configuration
// So we will not protect fiterPatterns array with locks (to improve perf)
foreach (string pattern in this.filterPatterns)
{
if (!string.IsNullOrWhiteSpace(pattern) &&
request.UserAgent.IndexOf(pattern, StringComparison.OrdinalIgnoreCase) != -1)
{
telemetry.Context.Operation.SyntheticSource = "Bot";
return;
}
}
}
}
}
}
开发者ID:Microsoft,项目名称:ApplicationInsights-dotnet-server,代码行数:31,代码来源:SyntheticUserAgentTelemetryInitializer.cs
示例2: Initialize
/// <summary>
/// Initializes the given <see cref="Microsoft.ApplicationInsights.Channel.ITelemetry"/>.
/// </summary>
public void Initialize(ITelemetry telemetry)
{
if (String.IsNullOrWhiteSpace(telemetry.Context.Component.Version))
{
telemetry.Context.Component.Version = _applicationVersion.Value;
}
}
示例3: Initialize
/// <summary>
/// Sets <see cref="ITelemetry.Timestamp"/> to <see cref="DateTimeOffset.Now"/>.
/// </summary>
public void Initialize(ITelemetry telemetry)
{
if (telemetry.Timestamp == default(DateTimeOffset))
{
telemetry.Timestamp = Clock.Instance.Time;
}
}
示例4: Initialize
/// <summary>
/// Initializes/Adds operation id to the existing telemetry item.
/// </summary>
/// <param name="telemetryItem">Target telemetry item to add operation id.</param>
public void Initialize(ITelemetry telemetryItem)
{
var itemContext = telemetryItem.Context.Operation;
if (string.IsNullOrEmpty(itemContext.ParentId) || string.IsNullOrEmpty(itemContext.Id) || string.IsNullOrEmpty(itemContext.Name))
{
var parentContext = AsyncLocalHelpers.GetCurrentOperationContext();
if (parentContext != null)
{
if (string.IsNullOrEmpty(itemContext.ParentId)
&& !string.IsNullOrEmpty(parentContext.ParentOperationId))
{
itemContext.ParentId = parentContext.ParentOperationId;
}
if (string.IsNullOrEmpty(itemContext.Id)
&& !string.IsNullOrEmpty(parentContext.RootOperationId))
{
itemContext.Id = parentContext.RootOperationId;
}
if (string.IsNullOrEmpty(itemContext.Name)
&& !string.IsNullOrEmpty(parentContext.RootOperationName))
{
itemContext.Name = parentContext.RootOperationName;
}
}
}
}
开发者ID:ZeoAlliance,项目名称:ApplicationInsights-dotnet,代码行数:33,代码来源:OperationCorrelationTelemetryInitializer.cs
示例5: Process
/// <summary>
/// Process a collected telemetry item.
/// </summary>
/// <param name="item">A collected Telemetry item.</param>
public void Process(ITelemetry item)
{
if (this.SamplingPercentage < 100.0 - 1.0E-12)
{
// set sampling percentage on telemetry item, current codebase assumes it is the only one updating SamplingPercentage.
var samplingSupportingTelemetry = item as ISupportSampling;
if (samplingSupportingTelemetry != null)
{
samplingSupportingTelemetry.SamplingPercentage = this.SamplingPercentage;
}
if (!this.IsSampledIn(item))
{
if (TelemetryChannelEventSource.Log.IsVerboseEnabled)
{
TelemetryChannelEventSource.Log.ItemSampledOut(item.ToString());
}
return;
}
}
this.Next.Process(item);
}
示例6: OnInitializeTelemetry
protected override void OnInitializeTelemetry(HttpContext platformContext, RequestTelemetry requestTelemetry, ITelemetry telemetry)
{
if (string.IsNullOrEmpty(telemetry.Context.Operation.Id))
{
telemetry.Context.Operation.Id = requestTelemetry.Id;
}
}
示例7: Initialize
public void Initialize(ITelemetry telemetry)
{
if (HttpContext.Current == null) return;
var requestId = HttpContext.Current.Items[Constants.RequestIdKey];
if (requestId == null || !string.IsNullOrEmpty(telemetry.Context.Operation.Id)) return;
telemetry.Context.Operation.Id = requestId as string;
}
开发者ID:dementeddevil,项目名称:Orchard-Azure-Application-Insights,代码行数:7,代码来源:WebOperationIdTelemetryInitializer.cs
示例8: Initialize
public void Initialize(ITelemetry telemetry)
{
try
{
var context = this.httpContextAccessor.HttpContext;
if (context == null)
{
//TODO: Diagnostics!
return;
}
if (context.RequestServices == null)
{
//TODO: Diagnostics!
return;
}
var request = context.RequestServices.GetService<RequestTelemetry>();
if (request == null)
{
//TODO: Diagnostics!
return;
}
this.OnInitializeTelemetry(context, request, telemetry);
}
catch (Exception exp)
{
//TODO: Diagnostics!
Debug.WriteLine(exp);
}
}
示例9: Initialize
/// <summary>
/// Base implementation of the initialization method.
/// </summary>
/// <param name="telemetry">Telemetry item to initialize.</param>
public void Initialize(ITelemetry telemetry)
{
try
{
var platformContext = this.ResolvePlatformContext();
if (platformContext == null)
{
WebEventSource.Log.WebTelemetryInitializerNotExecutedOnNullHttpContext();
return;
}
if (platformContext.GetRequest() == null)
{
return;
}
var requestTelemetry = platformContext.ReadOrCreateRequestTelemetryPrivate();
this.OnInitializeTelemetry(platformContext, requestTelemetry, telemetry);
}
catch (Exception exc)
{
WebEventSource.Log.WebTelemetryInitializerFailure(
this.GetType().FullName,
exc.ToInvariantString());
}
}
示例10: Initialize
/// <summary>
/// Populates <see cref="ITelemetry.Sequence"/> with unique ID and sequential number.
/// </summary>
public void Initialize(ITelemetry telemetry)
{
if (string.IsNullOrEmpty(telemetry.Sequence))
{
telemetry.Sequence = this.stablePrefix + Interlocked.Increment(ref this.currentNumber);
}
}
示例11: Initialize
/// <summary>
/// Initializes the given <see cref="Microsoft.ApplicationInsights.Channel.ITelemetry"/>.
/// </summary>
/// <param name="telemetry"></param>
public void Initialize(ITelemetry telemetry)
{
if (String.IsNullOrWhiteSpace(telemetry.Context.Session.Id))
{
telemetry.Context.Session.Id = _sessionId.Value;
}
}
示例12: Send
public void Send(ITelemetry item)
{
lock ( lockobj )
{
items.Add(item);
}
}
示例13: Initialize
/// <summary>
/// Initializes the given <see cref="Microsoft.ApplicationInsights.Channel.ITelemetry"/>.
/// </summary>
public void Initialize(ITelemetry telemetry)
{
if (String.IsNullOrWhiteSpace(telemetry.Context.Device.OperatingSystem))
{
telemetry.Context.Device.OperatingSystem = _osVersion.Value;
}
}
示例14: Car
public Car(ITelemetry telemetry, int carIdx)
{
this.telemetry = telemetry;
this.carIdx = carIdx;
this.driver = telemetry.SessionData.DriverInfo.CompetingDrivers[carIdx];
this.Details = new CarDetails(telemetry, carIdx);
}
示例15: Initialize
public void Initialize(ITelemetry telemetry)
{
var telemetryWithProperties = telemetry as ISupportProperties;
if (telemetryWithProperties == null) return;
// If already set, nothing to do.
if (telemetryWithProperties.Properties.ContainsKey(Constants.ShellNameKey)) return;
// Below algorithm copied from OrchardLog4netLogger.
var ctx = HttpContext.Current;
if (ctx == null)
return;
var runningShellTable = HostContainer.Resolve<IRunningShellTable>();
if (runningShellTable == null)
return;
var shellSettings = runningShellTable.Match(new HttpContextWrapper(ctx));
if (shellSettings == null)
return;
var orchardHost = HostContainer.Resolve<IOrchardHost>();
if (orchardHost == null)
return;
var shellContext = orchardHost.GetShellContext(shellSettings);
if (shellContext == null || shellContext.Settings == null)
return;
telemetryWithProperties.Properties[Constants.ShellNameKey] = shellContext.Settings.Name;
}
开发者ID:dementeddevil,项目名称:Orchard-Azure-Application-Insights,代码行数:32,代码来源:ShellNameTelemetryInitializer.cs