Added initial observability
This commit is contained in:
@@ -1,4 +1,9 @@
|
|||||||
<!DOCTYPE html>
|
@using System.Text.Json
|
||||||
|
@using Elastic.Apm
|
||||||
|
@inject IApmAgent Agent
|
||||||
|
@inject IHostEnvironment Environment
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
@@ -13,6 +18,21 @@
|
|||||||
<body>
|
<body>
|
||||||
<Routes/>
|
<Routes/>
|
||||||
<script src="@Assets["_framework/blazor.web.js"]"></script>
|
<script src="@Assets["_framework/blazor.web.js"]"></script>
|
||||||
|
@if (Agent.Configuration.Enabled)
|
||||||
|
{
|
||||||
|
<script src="@Assets["elastic-apm-rum.umd.min.js"]"></script>
|
||||||
|
<script permanent>
|
||||||
|
elasticApm.init({
|
||||||
|
serviceName: 'Pushy',
|
||||||
|
serverUrl: 'https://apm.henrikml.dk',
|
||||||
|
distributedTracingOrigins: ['https://pushy.henrikml.dk'],
|
||||||
|
pageLoadTraceId: '@Agent.Tracer.CurrentTransaction?.TraceId',
|
||||||
|
pageLoadSpanId: '@Agent.Tracer.CurrentTransaction?.EnsureParentId()',
|
||||||
|
pageLoadSampled: @JsonSerializer.Serialize(Agent.Tracer?.CurrentTransaction?.IsSampled),
|
||||||
|
environment: '@Environment.EnvironmentName'
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
}
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
CreatedItems.Add(item);
|
CreatedItems.Add(item);
|
||||||
|
|
||||||
Form = new UploadForm();
|
Form = new UploadForm();
|
||||||
|
Logger.LogInformation("A new item was created!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class UploadForm
|
public sealed class UploadForm
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public interface ITextItem : IGrainWithStringKey
|
|||||||
public sealed class TextItemGrain : Grain, ITextItem, IRemindable
|
public sealed class TextItemGrain : Grain, ITextItem, IRemindable
|
||||||
{
|
{
|
||||||
private readonly IPersistentState<TextItem> _state;
|
private readonly IPersistentState<TextItem> _state;
|
||||||
|
|
||||||
private IGrainReminder? _reminder;
|
private IGrainReminder? _reminder;
|
||||||
|
|
||||||
public TextItemGrain(
|
public TextItemGrain(
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
using Elastic.Extensions.Logging;
|
||||||
|
using Elastic.Extensions.Logging.Options;
|
||||||
|
using Elastic.Transport;
|
||||||
using Pushy.Components;
|
using Pushy.Components;
|
||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
using LinkGenerator = Pushy.LinkGenerator;
|
using LinkGenerator = Pushy.LinkGenerator;
|
||||||
@@ -9,21 +12,43 @@ builder.UseOrleans(silo =>
|
|||||||
silo.UseLocalhostClustering();
|
silo.UseLocalhostClustering();
|
||||||
silo.UseRedisReminderService(conf =>
|
silo.UseRedisReminderService(conf =>
|
||||||
{
|
{
|
||||||
conf.ConfigurationOptions = ConfigurationOptions.Parse(builder.Configuration.GetConnectionString("Valkey"));
|
conf.ConfigurationOptions = ConfigurationOptions.Parse(builder.Configuration.GetConnectionString("Valkey")!);
|
||||||
});
|
});
|
||||||
|
|
||||||
silo.AddRedisGrainStorageAsDefault(options =>
|
silo.AddRedisGrainStorageAsDefault(options =>
|
||||||
{
|
{
|
||||||
options.ConfigurationOptions =
|
options.ConfigurationOptions =
|
||||||
ConfigurationOptions.Parse(builder.Configuration.GetConnectionString("Valkey"));
|
ConfigurationOptions.Parse(builder.Configuration.GetConnectionString("Valkey")!);
|
||||||
});
|
});
|
||||||
|
|
||||||
silo.AddActivityPropagation();
|
silo.AddActivityPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var transport = new TransportConfiguration(new StaticNodePool([new Uri("https://elastic-node-1.home.local:9200")]))
|
||||||
|
.Authentication(new ApiKey(builder.Configuration["Elasticsearch:ApiKey"]!));
|
||||||
|
|
||||||
|
builder.Logging.AddElasticsearch(opt =>
|
||||||
|
{
|
||||||
|
opt.IsEnabled = true;
|
||||||
|
opt.DataStream = new DataStreamNameOptions()
|
||||||
|
{
|
||||||
|
Type = "logs", DataSet = "Pushy", Namespace = "pushy"
|
||||||
|
};
|
||||||
|
opt.Transport = new DistributedTransport(transport);
|
||||||
|
});
|
||||||
|
|
||||||
builder.Services.AddScoped<LinkGenerator>();
|
builder.Services.AddScoped<LinkGenerator>();
|
||||||
|
builder.Services.AddAllElasticApm();
|
||||||
|
|
||||||
builder.Services.AddHealthChecks();
|
builder.Services.AddHealthChecks();
|
||||||
|
builder.Services.AddCors(policy =>
|
||||||
|
{
|
||||||
|
policy.AddDefaultPolicy(builder =>
|
||||||
|
{
|
||||||
|
builder.WithOrigins("https://henrikml.dk")
|
||||||
|
.AllowAnyHeader();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddRazorComponents()
|
builder.Services.AddRazorComponents()
|
||||||
@@ -35,6 +60,7 @@ builder.Services.AddResponseCompression();
|
|||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
@@ -51,6 +77,7 @@ else
|
|||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
app.UseResponseCompression();
|
app.UseResponseCompression();
|
||||||
|
|
||||||
|
app.UseCors();
|
||||||
|
|
||||||
app.MapStaticAssets();
|
app.MapStaticAssets();
|
||||||
app.UseAntiforgery();
|
app.UseAntiforgery();
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Elastic.Apm.NetCoreAll" Version="1.30.0" />
|
||||||
|
<PackageReference Include="Elastic.Extensions.Logging" Version="8.12.2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.0" />
|
||||||
<PackageReference Include="Microsoft.Orleans.Persistence.Redis" Version="8.2.0" />
|
<PackageReference Include="Microsoft.Orleans.Persistence.Redis" Version="8.2.0" />
|
||||||
<PackageReference Include="Microsoft.Orleans.Reminders.Redis" Version="8.2.0" />
|
<PackageReference Include="Microsoft.Orleans.Reminders.Redis" Version="8.2.0" />
|
||||||
|
|||||||
@@ -2,8 +2,14 @@
|
|||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning",
|
||||||
|
"Elastic.Apm": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"ElasticApm":
|
||||||
|
{
|
||||||
|
"ServerUrl": "http://apm.home.local:8200",
|
||||||
|
"TransactionNameGroups": "GET /t/*"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
Pushy/Pushy/wwwroot/elastic-apm-rum.umd.min.js
vendored
Normal file
2
Pushy/Pushy/wwwroot/elastic-apm-rum.umd.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user