Skip to content

Commit

Permalink
Azure Monitor Exporter - Update codegen (#14895)
Browse files Browse the repository at this point in the history
* Update codegen

* Addressing PR Comments
  • Loading branch information
rajkumar-rangaraj authored Sep 9, 2020
1 parent 0781669 commit 006a3c1
Show file tree
Hide file tree
Showing 46 changed files with 501 additions and 1,641 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ internal async ValueTask<int> AddBatchActivityAsync(Batch<Activity> batchActivit
return 0;
}

List<TelemetryEnvelope> telemetryItems = new List<TelemetryEnvelope>();
TelemetryEnvelope telemetryItem;
List<TelemetryItem> telemetryItems = new List<TelemetryItem>();
TelemetryItem telemetryItem;

foreach (var activity in batchActivity)
{
telemetryItem = GeneratePartAEnvelope(activity);
telemetryItem.IKey = this.instrumentationKey;
telemetryItem.InstrumentationKey = this.instrumentationKey;
telemetryItem.Data = GenerateTelemetryData(activity);
telemetryItems.Add(telemetryItem);
}
Expand All @@ -79,24 +79,23 @@ internal async ValueTask<int> AddBatchActivityAsync(Batch<Activity> batchActivit
return response.Value.ItemsAccepted.GetValueOrDefault();
}

private static TelemetryEnvelope GeneratePartAEnvelope(Activity activity)
private static TelemetryItem GeneratePartAEnvelope(Activity activity)
{
// TODO: Get TelemetryEnvelope name changed in swagger
TelemetryEnvelope envelope = new TelemetryEnvelope(PartA_Name_Mapping[activity.GetTelemetryType()], activity.StartTimeUtc);
TelemetryItem telemetryItem = new TelemetryItem(PartA_Name_Mapping[activity.GetTelemetryType()], activity.StartTimeUtc);
// TODO: Validate if Azure SDK has common function to generate role instance
envelope.Tags[ContextTagKeys.AiCloudRoleInstance.ToString()] = "testRoleInstance";
telemetryItem.Tags[ContextTagKeys.AiCloudRoleInstance.ToString()] = "testRoleInstance";

envelope.Tags[ContextTagKeys.AiOperationId.ToString()] = activity.TraceId.ToHexString();
telemetryItem.Tags[ContextTagKeys.AiOperationId.ToString()] = activity.TraceId.ToHexString();
if (activity.Parent != null)
{
envelope.Tags[ContextTagKeys.AiOperationParentId.ToString()] = activity.Parent.SpanId.ToHexString();
telemetryItem.Tags[ContextTagKeys.AiOperationParentId.ToString()] = activity.Parent.SpanId.ToHexString();
}

// TODO: "ai.location.ip"
// TODO: Handle exception
envelope.Tags[ContextTagKeys.AiInternalSdkVersion.ToString()] = SdkVersionUtils.SdkVersion;
telemetryItem.Tags[ContextTagKeys.AiInternalSdkVersion.ToString()] = SdkVersionUtils.SdkVersion;

return envelope;
return telemetryItem;
}

private MonitorBase GenerateTelemetryData(Activity activity)
Expand Down Expand Up @@ -127,7 +126,7 @@ private MonitorBase GenerateTelemetryData(Activity activity)
}
else if (telemetryType == TelemetryType.Dependency)
{
var dependency = new RemoteDependencyData(2, activity.DisplayName, activity.Duration)
var dependency = new RemoteDependencyData(2, activity.DisplayName, activity.Duration.ToString("c", CultureInfo.InvariantCulture))
{
Id = activity.Context.SpanId.ToHexString()
};
Expand Down
16 changes: 0 additions & 16 deletions sdk/monitor/OpenTelemetry.Exporter.AzureMonitor/src/Base.cs

This file was deleted.

16 changes: 0 additions & 16 deletions sdk/monitor/OpenTelemetry.Exporter.AzureMonitor/src/Domain.cs

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 006a3c1

Please sign in to comment.