Skip to content

Commit

Permalink
moved .AddApplicationInsightsTelemetry() up as it was causes issues t…
Browse files Browse the repository at this point in the history
…esting on github actions
  • Loading branch information
Hazzajenko committed Jul 9, 2023
1 parent 381f7d7 commit 23e59ed
Showing 1 changed file with 2 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ public record MeterServiceConfiguration(ActivitySource ActivitySource, Meter Met

public static class OpenTelemetryExtensions
{
// public const string ServiceName = "IdentityService";

// public static readonly ActivitySource ActivitySource = new(ServiceName);
// public static Meter Meter = new(ServiceName);

/// <summary>
/// This method is used to initialize the OpenTelemetry.
/// It is called from the Program class.
Expand All @@ -32,6 +27,8 @@ public static IServiceCollection InitOpenTelemetry(
MeterServiceConfiguration? meterServiceConfiguration = null
)
{
services.AddApplicationInsightsTelemetry();

var serviceName = environment.IsDevelopment()
? config["App:ServiceName"]
: GetEnvironmentVariable("APP_SERVICE_NAME");
Expand All @@ -48,22 +45,6 @@ public static IServiceCollection InitOpenTelemetry(
return services;
}

// if (meterServiceConfiguration is not null)
// {
// services.AddSingleton(meterServiceConfiguration.ActivitySource);
// services.AddSingleton(meterServiceConfiguration.Meter);
// }
// else
// {
// services.AddSingleton(new ActivitySource(serviceName));
// services.AddSingleton(new Meter(serviceName));
// }



// ActivitySource activitySource = new(serviceName);
// Meter meter = new(serviceName);

ActivitySource activitySource =
meterServiceConfiguration?.ActivitySource ?? new(serviceName);
Meter meter = meterServiceConfiguration?.Meter ?? new(serviceName);
Expand All @@ -89,15 +70,7 @@ public static IServiceCollection InitOpenTelemetry(
)
);

services.AddApplicationInsightsTelemetry();

services.AddAppMetrics();
// services.AddMetrics(
// new MetricsBuilder()
// .OutputMetrics.AsPrometheusPlainText()
// .Build());
// services.AddMetricsEndpoints(options => options.MetricsEndpointOutputFormatter = new MetricsPrometheusTextOutputFormatter());


return services;
}
Expand All @@ -115,15 +88,6 @@ string serviceName
.ConfigureResource(resource => resource.AddService(serviceName))
.AddHttpClientInstrumentation()
.AddAspNetCoreInstrumentation()
// .AddJaegerExporter(options =>
// {
// options.Endpoint = new Uri("http://localhost:14268/api/traces");
// // options.AgentHost = config["Jaeger:Host"];
// // options.AgentPort = int.Parse(config["Jaeger:Port"]);
//
// // options.Endpoint = new Uri(config["Jaeger:Endpoint"]);
// })

.AddOtlpExporter(options =>
{
options.Endpoint = new Uri("http://localhost:4317");
Expand Down Expand Up @@ -176,13 +140,6 @@ string serviceName
options.Endpoint = new Uri("http://localhost:4317");
})
.AddPrometheusExporter()
// .AddPrometheusExporter(opt =>
// {
// opt.ScrapeEndpointPath = "/metrics";
// // opt.ToString() = 9184;
// // opt.StartHttpListener = true;
// // opt.HttpListenerPrefixes = new[] { "http://+:9184/" };
// })
.AddAzureMonitorMetricExporterIfEnabled(config, applicationInsightsConnectionString);
}

Expand Down

0 comments on commit 23e59ed

Please sign in to comment.