Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0dac827923 | ||
|
|
8338e26b88 | ||
|
|
4fd1741556 | ||
|
|
6011fb347d | ||
|
|
331c5c59e2 | ||
|
|
b3afb2b7d2 |
@@ -44,8 +44,23 @@ jobs:
|
||||
username: ${{ secrets.SSH_USERNAME }}
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
script: |
|
||||
cd altgen
|
||||
|
||||
echo 'SeqOptions__ServerUrl=http://seq:80' >> .env
|
||||
echo 'SeqOptions__ApiKeyHeader=X-Seq-ApiKey' >> .env
|
||||
echo 'SeqOptions__ApiKey=${{ secrets.SEQ_API_KEY }}' >> .env
|
||||
|
||||
docker stop api.altgen.stevanfreeborn.com
|
||||
docker rm api.altgen.stevanfreeborn.com
|
||||
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/api.altgen.stevanfreeborn.com:${{ needs.build.outputs.version }}
|
||||
docker run --restart always -d -p 7778:8080 --name api.altgen.stevanfreeborn.com ${{ secrets.DOCKERHUB_USERNAME }}/api.altgen.stevanfreeborn.com:${{ needs.build.outputs.version }}
|
||||
docker run \
|
||||
--env-file .env \
|
||||
--restart always \
|
||||
-d \
|
||||
-p 7778:8080 \
|
||||
--name api.altgen.stevanfreeborn.com \
|
||||
--network seq-network \
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/api.altgen.stevanfreeborn.com:${{ needs.build.outputs.version }}
|
||||
|
||||
rm .env
|
||||
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.12.0" />
|
||||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.12.0" />
|
||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.0" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace AltGen.API.Common;
|
||||
|
||||
class Instrumentation : IDisposable
|
||||
{
|
||||
internal const string ActivitySourceName = "AltGen.API";
|
||||
internal const string ActivitySourceVersion = "1.0.0";
|
||||
|
||||
public Instrumentation()
|
||||
{
|
||||
ActivitySource = new ActivitySource(ActivitySourceName, ActivitySourceVersion);
|
||||
}
|
||||
|
||||
public ActivitySource ActivitySource { get; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
ActivitySource.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace AltGen.API.Common;
|
||||
|
||||
internal sealed class SeqOptions
|
||||
{
|
||||
public string ServerUrl { get; set; } = string.Empty;
|
||||
public string ApiKeyHeader { get; set; } = string.Empty;
|
||||
public string ApiKey { get; set; } = string.Empty;
|
||||
public bool IsEnabled => !string.IsNullOrWhiteSpace(ServerUrl) && !string.IsNullOrWhiteSpace(ApiKeyHeader) && !string.IsNullOrWhiteSpace(ApiKey);
|
||||
public string LogEndpoint => $"{ServerUrl}/ingest/otlp/v1/logs";
|
||||
public string TraceEndpoint => $"{ServerUrl}/ingest/otlp/v1/traces";
|
||||
public string AuthHeader => $"{ApiKeyHeader}={ApiKey}";
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
namespace AltGen.API.Common;
|
||||
|
||||
static class WebAppBuilderExtensions
|
||||
{
|
||||
public static WebApplicationBuilder AddTelemetry(this WebApplicationBuilder builder)
|
||||
{
|
||||
var seq = new SeqOptions();
|
||||
builder.Configuration.GetSection(nameof(SeqOptions)).Bind(seq);
|
||||
|
||||
if (seq.IsEnabled is false)
|
||||
{
|
||||
return builder;
|
||||
}
|
||||
|
||||
builder.Services.AddSingleton<Instrumentation>();
|
||||
|
||||
builder.Services.AddOpenTelemetry()
|
||||
.ConfigureResource(resource =>
|
||||
{
|
||||
resource.AddService(Instrumentation.ActivitySourceName, Instrumentation.ActivitySourceVersion);
|
||||
resource.AddAttributes(new Dictionary<string, object>
|
||||
{
|
||||
["service.name"] = Instrumentation.ActivitySourceName,
|
||||
["service.version"] = Instrumentation.ActivitySourceVersion,
|
||||
["service.instance.id"] = Environment.MachineName,
|
||||
["service.namespace"] = "stevesbot",
|
||||
["service.environment"] = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? "production",
|
||||
});
|
||||
})
|
||||
.WithLogging(lb => lb.AddOtlpExporter(o =>
|
||||
{
|
||||
o.Protocol = OtlpExportProtocol.HttpProtobuf;
|
||||
o.Endpoint = new Uri(seq.LogEndpoint);
|
||||
o.Headers = seq.AuthHeader;
|
||||
}))
|
||||
.WithTracing(tb =>
|
||||
{
|
||||
tb.AddSource(Instrumentation.ActivitySourceName);
|
||||
tb.AddAspNetCoreInstrumentation();
|
||||
tb.AddHttpClientInstrumentation();
|
||||
tb.AddOtlpExporter(o =>
|
||||
{
|
||||
o.Protocol = OtlpExportProtocol.HttpProtobuf;
|
||||
o.Endpoint = new Uri(seq.TraceEndpoint);
|
||||
o.Headers = seq.AuthHeader;
|
||||
});
|
||||
});
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
using System.Globalization;
|
||||
using System.Threading.RateLimiting;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.AddTelemetry();
|
||||
|
||||
builder.Services.AddProblemDetails();
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
global using System.ComponentModel.DataAnnotations;
|
||||
global using System.Diagnostics.CodeAnalysis;
|
||||
global using System.Globalization;
|
||||
global using System.Reflection;
|
||||
global using System.Text;
|
||||
global using System.Text.Json;
|
||||
global using System.Text.Json.Serialization;
|
||||
global using System.Threading.RateLimiting;
|
||||
|
||||
global using AltGen.API.Common;
|
||||
global using AltGen.API.Generate;
|
||||
global using AltGen.API.Generate.Providers;
|
||||
global using AltGen.API.Generate.Providers.Gemini;
|
||||
|
||||
global using Microsoft.AspNetCore.Mvc;
|
||||
global using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
global using OpenTelemetry.Exporter;
|
||||
global using OpenTelemetry.Logs;
|
||||
global using OpenTelemetry.Resources;
|
||||
global using OpenTelemetry.Trace;
|
||||
@@ -4,7 +4,7 @@
|
||||
<AssemblyTitle>AltGen.Console</AssemblyTitle>
|
||||
<Product>AltGen.Console</Product>
|
||||
<Description>A command-line interface for AltGen</Description>
|
||||
<Version>0.0.0</Version>
|
||||
<Version>0.0.1</Version>
|
||||
<Authors>Stevan Freeborn</Authors>
|
||||
<OutputType>Exe</OutputType>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [versionize](https://github.com/versionize/versionize) for commit guidelines.
|
||||
|
||||
<a name="0.0.1"></a>
|
||||
## [0.0.1](https://www.github.com/StevanFreeborn/alt-gen/releases/tag/v0.0.1) (2025-04-05)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* use GetSettingsPath when checking if settings exists ([b3afb2b](https://www.github.com/StevanFreeborn/alt-gen/commit/b3afb2b7d2a3582f4f303ba7fa7dca093a144725))
|
||||
|
||||
<a name="0.0.0"></a>
|
||||
## [0.0.0](https://www.github.com/StevanFreeborn/alt-gen/releases/tag/v0.0.0) (2025-03-29)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ class AppSettingsManager(IFileSystem fileSystem) : IAppSettingsManager
|
||||
|
||||
public bool AppSettingsExist()
|
||||
{
|
||||
return _fileSystem.Path.Exists(SettingsFileName);
|
||||
return _fileSystem.Path.Exists(GetSettingsPath());
|
||||
}
|
||||
|
||||
public async Task<AppSettings> GetAppSettingsAsync()
|
||||
|
||||
Reference in New Issue
Block a user