internal static List <TelemetryItem> Convert(Batch <Activity> batchActivity, Resource resource, string instrumentationKey) { List <TelemetryItem> telemetryItems = new List <TelemetryItem>(); TelemetryItem telemetryItem; foreach (var activity in batchActivity) { MonitorBase telemetryData = new MonitorBase(); var monitorTags = EnumerateActivityTags(activity); telemetryItem = TelemetryPartA.GetTelemetryItem(activity, ref monitorTags, resource, instrumentationKey); switch (activity.GetTelemetryType()) { case TelemetryType.Request: telemetryData.BaseType = Telemetry_Base_Type_Mapping[TelemetryType.Request]; telemetryData.BaseData = TelemetryPartB.GetRequestData(activity, ref monitorTags); break; case TelemetryType.Dependency: telemetryData.BaseType = Telemetry_Base_Type_Mapping[TelemetryType.Dependency]; telemetryData.BaseData = TelemetryPartB.GetRemoteDependencyData(activity, ref monitorTags); break; } telemetryItem.Data = telemetryData; telemetryItems.Add(telemetryItem); } return(telemetryItems); }
internal static RequestData GetRequestData(Activity activity, ref TagEnumerationState monitorTags) { string url = null; AddActivityLinksToPartCTags(activity.Links, ref monitorTags.PartCTags); switch (monitorTags.activityType) { case PartBType.Http: url = monitorTags.PartBTags.GetRequestUrl(); break; case PartBType.Messaging: url = AzMonList.GetTagValue(ref monitorTags.PartBTags, SemanticConventions.AttributeMessagingUrl)?.ToString(); break; } var requestName = TelemetryPartA.GetOperationName(activity, ref monitorTags.PartBTags); var statusCode = AzMonList.GetTagValue(ref monitorTags.PartBTags, SemanticConventions.AttributeHttpStatusCode)?.ToString() ?? "0"; var success = activity.GetStatus().StatusCode != StatusCode.Error; var request = new RequestData(2, activity.Context.SpanId.ToHexString(), activity.Duration.ToString("c", CultureInfo.InvariantCulture), success, statusCode) { Name = requestName, Url = url, }; AddPropertiesToTelemetry(request.Properties, ref monitorTags.PartCTags); return(request); }
internal static List <TelemetryItem> Convert(Batch <LogRecord> batchLogRecord, string instrumentationKey) { List <TelemetryItem> telemetryItems = new List <TelemetryItem>(); TelemetryItem telemetryItem; foreach (var logRecord in batchLogRecord) { telemetryItem = TelemetryPartA.GetTelemetryItem(logRecord, instrumentationKey); telemetryItem.Data = new MonitorBase { BaseType = Telemetry_Base_Type_Mapping[TelemetryType.Message], BaseData = TelemetryPartB.GetMessageData(logRecord), }; telemetryItems.Add(telemetryItem); } return(telemetryItems); }