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
6 changes: 3 additions & 3 deletions examples/net8.0/aspnetcore/TodoAppEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public static IServiceCollection AddTodoApp(this IServiceCollection services)
if (string.IsNullOrEmpty(dataDirectory) || !Path.IsPathRooted(dataDirectory))
{
var environment = serviceProvider.GetRequiredService<IHostEnvironment>();
dataDirectory = Path.Combine(environment.ContentRootPath, "App_Data");
dataDirectory = Path.Join(environment.ContentRootPath, "App_Data");
}

if (!Directory.Exists(dataDirectory))
{
Directory.CreateDirectory(dataDirectory);
}

var databaseFile = Path.Combine(dataDirectory, "TodoApp.db");
var databaseFile = Path.Join(dataDirectory, "TodoApp.db");

options.UseSqlite("Data Source=" + databaseFile);
});
Expand All @@ -45,7 +45,7 @@ public static IEndpointRouteBuilder MapTodoApp(this IEndpointRouteBuilder builde
todos.MapPost("/", async (CreateTodoItemModel model, TodoRepository repository) =>
{
var id = await repository.AddItemAsync(model.Text);
return Results.Created($"/api/items/{id}", new { Id = id });
return Results.Created($"/api/items/{id.Id}", new { Id = id });
});

todos.MapGet("/", async (TodoRepository repository) => await repository.GetItemsAsync());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,36 +29,36 @@ public class AgentOtlpExporter : ExporterSettings
public OtlpExportProtocol Protocol { get; set; }

/// <inheritdoc/>
override internal void Apply(TracerProviderBuilder builder)
internal override void Apply(TracerProviderBuilder builder)
{
if (EnableTraces == false)
if (!EnableTraces)
{
return;
}

builder.AddOtlpExporter(config => ApplyToConfig(config));
builder.AddOtlpExporter(ApplyToConfig);
}

/// <inheritdoc/>
override internal void Apply(MeterProviderBuilder builder)
internal override void Apply(MeterProviderBuilder builder)
{
if (EnableMetrics == false)
if (!EnableMetrics)
{
return;
}

builder.AddOtlpExporter(config => ApplyToConfig(config));
builder.AddOtlpExporter(ApplyToConfig);
}

/// <inheritdoc/>
override internal void Apply(OpenTelemetryLoggerOptions options)
internal override void Apply(OpenTelemetryLoggerOptions options)
{
if (EnableLogs == false)
if (!EnableLogs)
{
return;
}

options.AddOtlpExporter(config => ApplyToConfig(config));
options.AddOtlpExporter(ApplyToConfig);
}

private void ApplyToConfig(OtlpExporterOptions options)
Expand All @@ -70,7 +70,7 @@ private void ApplyToConfig(OtlpExporterOptions options)

if (Protocol != default)
{
options.Protocol = (OtlpExportProtocol)Protocol;
options.Protocol = Protocol;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ internal CloudOtlpExporter(IConfiguration configuration)
{ }

/// <inheritdoc/>
override internal void Apply(TracerProviderBuilder builder)
internal override void Apply(TracerProviderBuilder builder)
{
if (EnableTraces == false)
if (!EnableTraces)
{
return;
}
Expand All @@ -84,9 +84,9 @@ override internal void Apply(TracerProviderBuilder builder)
}

/// <inheritdoc/>
override internal void Apply(MeterProviderBuilder builder)
internal override void Apply(MeterProviderBuilder builder)
{
if (EnableMetrics == false)
if (!EnableMetrics)
{
return;
}
Expand All @@ -102,9 +102,9 @@ override internal void Apply(MeterProviderBuilder builder)
}

/// <inheritdoc/>
override internal void Apply(OpenTelemetryLoggerOptions options)
internal override void Apply(OpenTelemetryLoggerOptions options)
{
if (EnableLogs == false)
if (!EnableLogs)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ internal class GrafanaCloudConfigurationHelper
private const string PathExtensionMetrics = "/v1/metrics";
private const string PathExtensionLogs = "/v1/logs";

private string _zone;
private string _instanceId;
private string _apiKey;
private readonly string _zone;
private readonly string _instanceId;
private readonly string _apiKey;

public GrafanaCloudConfigurationHelper(string zone, string instanceId, string apiKey)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public class OtlpExporter : ExporterSettings
public OtlpExportProtocol Protocol { get; set; }

/// <inheritdoc/>
override internal void Apply(TracerProviderBuilder builder)
internal override void Apply(TracerProviderBuilder builder)
{
if (EnableTraces == false)
if (!EnableTraces)
{
return;
}
Expand All @@ -50,9 +50,9 @@ override internal void Apply(TracerProviderBuilder builder)
}

/// <inheritdoc/>
override internal void Apply(MeterProviderBuilder builder)
internal override void Apply(MeterProviderBuilder builder)
{
if (EnableMetrics == false)
if (!EnableMetrics)
{
return;
}
Expand All @@ -66,9 +66,9 @@ override internal void Apply(MeterProviderBuilder builder)
}

/// <inheritdoc/>
override internal void Apply(OpenTelemetryLoggerOptions options)
internal override void Apply(OpenTelemetryLoggerOptions options)
{
if (EnableLogs == false)
if (!EnableLogs)
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class GrafanaOpenTelemetryResourceDetector : IResourceDetector
internal const string ResourceKey_DeploymentEnvironment = "deployment.environment";
internal const string ResourceValue_DistroName = "grafana-opentelemetry-dotnet";

private GrafanaOpenTelemetrySettings _settings;
private readonly GrafanaOpenTelemetrySettings _settings;

public GrafanaOpenTelemetryResourceDetector(GrafanaOpenTelemetrySettings settings)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Grafana.OpenTelemetry
{
internal abstract class InstrumentationInitializer
{
public static InstrumentationInitializer[] Initializers = GetDefaults();
public static readonly InstrumentationInitializer[] Initializers = GetDefaults();

public abstract Instrumentation Id { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static ResourceBuilder AddGrafanaResource(this ResourceBuilder resourceBu
serviceName: settings.ServiceName,
serviceVersion: settings.ServiceVersion,
serviceInstanceId: serviceInstanceIdProvided ? settings.ServiceInstanceId : null,
autoGenerateServiceInstanceId: serviceInstanceIdProvided == false);
autoGenerateServiceInstanceId: !serviceInstanceIdProvided);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Grafana.OpenTelemetry
{
internal abstract class ResourceDetectorInitializer
{
public static ResourceDetectorInitializer[] Initializers = new ResourceDetectorInitializer[]
public static readonly ResourceDetectorInitializer[] Initializers = new ResourceDetectorInitializer[]
{
#if !NETSTANDARD
new AWSEBSDetectorInitializer(),
Expand All @@ -36,7 +36,7 @@ internal abstract class ResourceDetectorInitializer
#endif
};

abstract public ResourceDetector Id { get; }
public abstract ResourceDetector Id { get; }

public void Initialize(TracerProviderBuilder builder)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFrameworks Condition="$([System.OperatingSystem]::IsWindows())">$(TargetFrameworks);net481</TargetFrameworks>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public void BuildDefault()
});

var logger = loggerFactory.CreateLogger<OpenTelemetryLoggerOptionsExtensionsTest>();

logger.LogInformation("This is a test log message.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ namespace Grafana.OpenTelemetry.Tests
{
public class TracerProviderExtensionsTest
{
private static ActivitySource activitySource = new ActivitySource(typeof(TracerProviderExtensionsTest).Name);
private static readonly ActivitySource activitySource = new(typeof(TracerProviderExtensionsTest).Name);

[Fact]
public void EnableDefaultInstrumentations()
{
Sdk
.CreateTracerProviderBuilder()
.UseGrafana()
.Build();
Sdk.CreateTracerProviderBuilder()
.UseGrafana()
.Build();
}

[Fact]
Expand All @@ -38,7 +37,7 @@ public void StandardResourceAttributes()
.AddSource(activitySource.Name)
.Build();

var span = activitySource.StartActivity("root");
using var span = activitySource.StartActivity("root");
span.Stop();
span.Dispose();

Expand Down Expand Up @@ -89,7 +88,7 @@ public void CustomResourceAttributes()
.AddSource(activitySource.Name)
.Build();

var span = activitySource.StartActivity("root");
using var span = activitySource.StartActivity("root");
span.Stop();
span.Dispose();

Expand Down Expand Up @@ -129,7 +128,7 @@ public void OverrideResourceAttributes()
.AddSource(activitySource.Name)
.Build();

var span = activitySource.StartActivity("root");
using var span = activitySource.StartActivity("root");
span.Stop();
span.Dispose();

Expand Down Expand Up @@ -164,7 +163,7 @@ public void OverrideResourceAttributesEnvironment()
.AddSource(activitySource.Name)
.Build();

var span = activitySource.StartActivity("root");
using var span = activitySource.StartActivity("root");
span.Stop();
span.Dispose();

Expand Down
Loading