Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace OpenTelemetry.Exporter.AzureMonitor.Models
{
public partial class AvailabilityData : OpenTelemetry.Exporter.AzureMonitor.Models.MonitorDomain
{
public AvailabilityData(int version, string id, string name, string duration, bool success) { }
public AvailabilityData(int version, string id, string name, string duration, bool success) : base (default(int)) { }
public string Duration { get { throw null; } }
public string Id { get { throw null; } }
public System.Collections.Generic.IDictionary<string, double> Measurements { get { throw null; } }
Expand All @@ -30,7 +30,6 @@ public AvailabilityData(int version, string id, string name, string duration, bo
public System.Collections.Generic.IDictionary<string, string> Properties { get { throw null; } }
public string RunLocation { get { throw null; } set { } }
public bool Success { get { throw null; } }
public int Version { get { throw null; } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct ContextTagKeys : System.IEquatable<OpenTelemetry.Exporter.AzureMonitor.Models.ContextTagKeys>
Expand Down Expand Up @@ -96,12 +95,11 @@ public AvailabilityData(int version, string id, string name, string duration, bo
}
public partial class MessageData : OpenTelemetry.Exporter.AzureMonitor.Models.MonitorDomain
{
public MessageData(int version, string message) { }
public MessageData(int version, string message) : base (default(int)) { }
public System.Collections.Generic.IDictionary<string, double> Measurements { get { throw null; } }
public string Message { get { throw null; } }
public System.Collections.Generic.IDictionary<string, string> Properties { get { throw null; } }
public OpenTelemetry.Exporter.AzureMonitor.Models.SeverityLevel? SeverityLevel { get { throw null; } set { } }
public int Version { get { throw null; } }
}
public partial class MetricDataPoint
{
Expand All @@ -117,10 +115,9 @@ public MetricDataPoint(string name, double value) { }
}
public partial class MetricsData : OpenTelemetry.Exporter.AzureMonitor.Models.MonitorDomain
{
public MetricsData(int version, System.Collections.Generic.IEnumerable<OpenTelemetry.Exporter.AzureMonitor.Models.MetricDataPoint> metrics) { }
public MetricsData(int version, System.Collections.Generic.IEnumerable<OpenTelemetry.Exporter.AzureMonitor.Models.MetricDataPoint> metrics) : base (default(int)) { }
public System.Collections.Generic.IList<OpenTelemetry.Exporter.AzureMonitor.Models.MetricDataPoint> Metrics { get { throw null; } }
public System.Collections.Generic.IDictionary<string, string> Properties { get { throw null; } }
public int Version { get { throw null; } }
}
public partial class MonitorBase
{
Expand All @@ -130,24 +127,23 @@ public MonitorBase() { }
}
public partial class MonitorDomain
{
public MonitorDomain() { }
public string Test { get { throw null; } set { } }
public MonitorDomain(int version) { }
public int Version { get { throw null; } }
}
public partial class PageViewData : OpenTelemetry.Exporter.AzureMonitor.Models.MonitorDomain
{
public PageViewData(int version, string id, string name) { }
public PageViewData(int version, string id, string name) : base (default(int)) { }
public string Duration { get { throw null; } set { } }
public string Id { get { throw null; } }
public System.Collections.Generic.IDictionary<string, double> Measurements { get { throw null; } }
public string Name { get { throw null; } }
public System.Collections.Generic.IDictionary<string, string> Properties { get { throw null; } }
public string ReferredUri { get { throw null; } set { } }
public string Url { get { throw null; } set { } }
public int Version { get { throw null; } }
}
public partial class PageViewPerfData : OpenTelemetry.Exporter.AzureMonitor.Models.MonitorDomain
{
public PageViewPerfData(int version, string id, string name) { }
public PageViewPerfData(int version, string id, string name) : base (default(int)) { }
public string DomProcessing { get { throw null; } set { } }
public string Duration { get { throw null; } set { } }
public string Id { get { throw null; } }
Expand All @@ -159,11 +155,10 @@ public PageViewPerfData(int version, string id, string name) { }
public string ReceivedResponse { get { throw null; } set { } }
public string SentRequest { get { throw null; } set { } }
public string Url { get { throw null; } set { } }
public int Version { get { throw null; } }
}
public partial class RemoteDependencyData : OpenTelemetry.Exporter.AzureMonitor.Models.MonitorDomain
{
public RemoteDependencyData(int version, string name, string duration) { }
public RemoteDependencyData(int version, string name, string duration) : base (default(int)) { }
public string Data { get { throw null; } set { } }
public string Duration { get { throw null; } }
public string Id { get { throw null; } set { } }
Expand All @@ -174,11 +169,10 @@ public RemoteDependencyData(int version, string name, string duration) { }
public bool? Success { get { throw null; } set { } }
public string Target { get { throw null; } set { } }
public string Type { get { throw null; } set { } }
public int Version { get { throw null; } }
}
public partial class RequestData : OpenTelemetry.Exporter.AzureMonitor.Models.MonitorDomain
{
public RequestData(int version, string id, string duration, bool success, string responseCode) { }
public RequestData(int version, string id, string duration, bool success, string responseCode) : base (default(int)) { }
public string Duration { get { throw null; } }
public string Id { get { throw null; } }
public System.Collections.Generic.IDictionary<string, double> Measurements { get { throw null; } }
Expand All @@ -188,7 +182,6 @@ public RequestData(int version, string id, string duration, bool success, string
public string Source { get { throw null; } set { } }
public bool Success { get { throw null; } }
public string Url { get { throw null; } set { } }
public int Version { get { throw null; } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct SeverityLevel : System.IEquatable<OpenTelemetry.Exporter.AzureMonitor.Models.SeverityLevel>
Expand Down Expand Up @@ -229,21 +222,19 @@ internal TelemetryErrorDetails() { }
}
public partial class TelemetryEventData : OpenTelemetry.Exporter.AzureMonitor.Models.MonitorDomain
{
public TelemetryEventData(int version, string name) { }
public TelemetryEventData(int version, string name) : base (default(int)) { }
public System.Collections.Generic.IDictionary<string, double> Measurements { get { throw null; } }
public string Name { get { throw null; } }
public System.Collections.Generic.IDictionary<string, string> Properties { get { throw null; } }
public int Version { get { throw null; } }
}
public partial class TelemetryExceptionData : OpenTelemetry.Exporter.AzureMonitor.Models.MonitorDomain
{
public TelemetryExceptionData(int version) { }
public TelemetryExceptionData(int version, System.Collections.Generic.IEnumerable<OpenTelemetry.Exporter.AzureMonitor.Models.TelemetryExceptionDetails> exceptions) : base (default(int)) { }
public System.Collections.Generic.IList<OpenTelemetry.Exporter.AzureMonitor.Models.TelemetryExceptionDetails> Exceptions { get { throw null; } }
public System.Collections.Generic.IDictionary<string, double> Measurements { get { throw null; } }
public string ProblemId { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, string> Properties { get { throw null; } }
public OpenTelemetry.Exporter.AzureMonitor.Models.SeverityLevel? SeverityLevel { get { throw null; } set { } }
public int Version { get { throw null; } }
}
public partial class TelemetryExceptionDetails
{
Expand All @@ -258,14 +249,14 @@ public TelemetryExceptionDetails(string message) { }
}
public partial class TelemetryItem
{
public TelemetryItem(string name, System.DateTimeOffset time) { }
public TelemetryItem(string name, string time) { }
public OpenTelemetry.Exporter.AzureMonitor.Models.MonitorBase Data { get { throw null; } set { } }
public string InstrumentationKey { get { throw null; } set { } }
public string Name { get { throw null; } }
public float? SampleRate { get { throw null; } set { } }
public string Sequence { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, string> Tags { get { throw null; } }
public System.DateTimeOffset Time { get { throw null; } }
public string Time { get { throw null; } }
public int? Version { get { throw null; } set { } }
}
public partial class TrackResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Collections.Generic;
using Azure.Core;
using OpenTelemetry.Exporter.AzureMonitor.Models;

namespace OpenTelemetry.Exporter.AzureMonitor
{
internal partial class ApplicationInsightsRestClient
{
internal HttpMessage CreateTrackRequest(IEnumerable<TelemetryItem> body)
{
var message = _pipeline.CreateMessage();
var request = message.Request;
request.Method = RequestMethod.Post;
var uri = new RawRequestUriBuilder();
uri.AppendRaw(host, false);
uri.AppendRaw("/v2", false);
uri.AppendPath("/track", false);
request.Uri = uri;
request.Headers.Add("Content-Type", "application/json");
request.Headers.Add("Accept", "application/json");
using var content = new NDJsonWriter();
foreach (var item in body)
{
content.JsonWriter.WriteObjectValue(item);
content.WriteNewLine();
}
request.Content = RequestContent.Create(content.ToBytes());
return message;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core.Pipeline;

using OpenTelemetry.Exporter.AzureMonitor.ConnectionString;
Expand All @@ -20,7 +21,7 @@ namespace OpenTelemetry.Exporter.AzureMonitor
{
internal class AzureMonitorTransmitter
{
private readonly ApplicationInsightsRestClient serviceRestClient;
private readonly ApplicationInsightsRestClient applicationInsightsRestClient;
private readonly AzureMonitorExporterOptions options;
private readonly string instrumentationKey;

Expand All @@ -45,7 +46,7 @@ public AzureMonitorTransmitter(AzureMonitorExporterOptions exporterOptions)
ConnectionStringParser.GetValues(exporterOptions.ConnectionString, out this.instrumentationKey, out string ingestionEndpoint);

options = exporterOptions;
serviceRestClient = new ApplicationInsightsRestClient(new ClientDiagnostics(options), HttpPipelineBuilder.Build(options), endpoint: ingestionEndpoint);
applicationInsightsRestClient = new ApplicationInsightsRestClient(new ClientDiagnostics(options), HttpPipelineBuilder.Build(options), host: ingestionEndpoint);
}

internal async ValueTask<int> AddBatchActivityAsync(Batch<Activity> batchActivity, bool async, CancellationToken cancellationToken)
Expand All @@ -70,11 +71,12 @@ internal async ValueTask<int> AddBatchActivityAsync(Batch<Activity> batchActivit

if (async)
{
response = await this.serviceRestClient.TrackAsync(telemetryItems, cancellationToken).ConfigureAwait(false);
// TODO: RequestFailedException is thrown when http response is not equal to 200 or 206. Implement logic to catch exception.
response = await this.applicationInsightsRestClient.TrackAsync(telemetryItems, cancellationToken).ConfigureAwait(false);
}
else
{
response = this.serviceRestClient.TrackAsync(telemetryItems, cancellationToken).Result;
response = this.applicationInsightsRestClient.TrackAsync(telemetryItems, cancellationToken).Result;
}

// TODO: Handle exception, check telemetryItems has items
Expand All @@ -83,7 +85,7 @@ internal async ValueTask<int> AddBatchActivityAsync(Batch<Activity> batchActivit

private static TelemetryItem GeneratePartAEnvelope(Activity activity)
{
TelemetryItem telemetryItem = new TelemetryItem(PartA_Name_Mapping[activity.GetTelemetryType()], activity.StartTimeUtc);
TelemetryItem telemetryItem = new TelemetryItem(PartA_Name_Mapping[activity.GetTelemetryType()], activity.StartTimeUtc.ToString(CultureInfo.InvariantCulture));
ExtractRoleInfo(activity.GetResource(), out var roleName, out var roleInstance);
telemetryItem.Tags[ContextTagKeys.AiCloudRole.ToString()] = roleName;
telemetryItem.Tags[ContextTagKeys.AiCloudRoleInstance.ToString()] = roleInstance;
Expand Down

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

Loading