diff --git a/prometheus-net.SystemMetrics.sln b/prometheus-net.SystemMetrics.sln index aef2b37..c36e0f7 100644 --- a/prometheus-net.SystemMetrics.sln +++ b/prometheus-net.SystemMetrics.sln @@ -1,13 +1,15 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29503.13 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34309.116 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prometheus.SystemMetrics", "src\Prometheus.SystemMetrics\Prometheus.SystemMetrics.csproj", "{C65859B3-4125-4594-A6BF-8917C1549E16}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prometheus.SystemMetrics.Example", "src\Prometheus.SystemMetrics.Example\Prometheus.SystemMetrics.Example.csproj", "{C965DA91-6C2A-4D62-B32C-DA42CA5A6146}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prometheus.SystemMetrics.Tests", "src\Prometheus.SystemMetrics.Tests\Prometheus.SystemMetrics.Tests.csproj", "{D76966FB-8E1F-40F7-B47B-D2AC03927906}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prometheus.SystemMetrics.Tests", "src\Prometheus.SystemMetrics.Tests\Prometheus.SystemMetrics.Tests.csproj", "{D76966FB-8E1F-40F7-B47B-D2AC03927906}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Prometheus.SystemMetrics.Example.AOT", "src\Prometheus.SystemMetrics.Example.AOT\Prometheus.SystemMetrics.Example.AOT.csproj", "{FF2F4C3A-A4CF-4ACB-8828-60967517E163}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -27,6 +29,10 @@ Global {D76966FB-8E1F-40F7-B47B-D2AC03927906}.Debug|Any CPU.Build.0 = Debug|Any CPU {D76966FB-8E1F-40F7-B47B-D2AC03927906}.Release|Any CPU.ActiveCfg = Release|Any CPU {D76966FB-8E1F-40F7-B47B-D2AC03927906}.Release|Any CPU.Build.0 = Release|Any CPU + {FF2F4C3A-A4CF-4ACB-8828-60967517E163}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF2F4C3A-A4CF-4ACB-8828-60967517E163}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF2F4C3A-A4CF-4ACB-8828-60967517E163}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF2F4C3A-A4CF-4ACB-8828-60967517E163}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Prometheus.SystemMetrics.Example.AOT/Dockerfile b/src/Prometheus.SystemMetrics.Example.AOT/Dockerfile new file mode 100644 index 0000000..f4c1737 --- /dev/null +++ b/src/Prometheus.SystemMetrics.Example.AOT/Dockerfile @@ -0,0 +1,29 @@ +#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. + +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +USER app +WORKDIR /app +EXPOSE 8080 + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +# Install clang/zlib1g-dev dependencies for publishing to native +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + clang zlib1g-dev +ARG BUILD_CONFIGURATION=Release +WORKDIR /src +COPY ["src/Prometheus.SystemMetrics.Example.AOT/Prometheus.SystemMetrics.Example.AOT.csproj", "src/Prometheus.SystemMetrics.Example.AOT/"] +RUN dotnet restore "./src/Prometheus.SystemMetrics.Example.AOT/./Prometheus.SystemMetrics.Example.AOT.csproj" +COPY . . +WORKDIR "/src/src/Prometheus.SystemMetrics.Example.AOT" +RUN dotnet build "./Prometheus.SystemMetrics.Example.AOT.csproj" -c $BUILD_CONFIGURATION -o /app/build + +FROM build AS publish +ARG BUILD_CONFIGURATION=Release +RUN dotnet publish "./Prometheus.SystemMetrics.Example.AOT.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=true + +FROM mcr.microsoft.com/dotnet/runtime-deps:8.0 AS final +WORKDIR /app +EXPOSE 8080 +COPY --from=publish /app/publish . +ENTRYPOINT ["./Prometheus.SystemMetrics.Example.AOT"] \ No newline at end of file diff --git a/src/Prometheus.SystemMetrics.Example.AOT/Program.cs b/src/Prometheus.SystemMetrics.Example.AOT/Program.cs new file mode 100644 index 0000000..02debd7 --- /dev/null +++ b/src/Prometheus.SystemMetrics.Example.AOT/Program.cs @@ -0,0 +1,23 @@ +using Prometheus; +using Prometheus.SystemMetrics; + +var builder = WebApplication.CreateSlimBuilder(args); + +var services = builder.Services; +services.AddSystemMetrics(); + +var app = builder.Build(); + +if (app.Environment.IsDevelopment()) +{ + app.UseDeveloperExceptionPage(); +} + +app.UseRouting(); +app.MapMetrics(); +app.MapGet("/", async context => +{ + context.Response.Redirect("/metrics"); +}); + +app.Run(); diff --git a/src/Prometheus.SystemMetrics.Example.AOT/Prometheus.SystemMetrics.Example.AOT.csproj b/src/Prometheus.SystemMetrics.Example.AOT/Prometheus.SystemMetrics.Example.AOT.csproj new file mode 100644 index 0000000..aee45b4 --- /dev/null +++ b/src/Prometheus.SystemMetrics.Example.AOT/Prometheus.SystemMetrics.Example.AOT.csproj @@ -0,0 +1,22 @@ + + + + net8.0 + enable + enable + true + true + Linux + ..\.. + + + + + + + + + + + + diff --git a/src/Prometheus.SystemMetrics.Example.AOT/Properties/launchSettings.json b/src/Prometheus.SystemMetrics.Example.AOT/Properties/launchSettings.json new file mode 100644 index 0000000..e8520f0 --- /dev/null +++ b/src/Prometheus.SystemMetrics.Example.AOT/Properties/launchSettings.json @@ -0,0 +1,24 @@ +{ + "profiles": { + "http": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "todos", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5017" + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/todos", + "environmentVariables": { + "ASPNETCORE_HTTP_PORTS": "8080" + }, + "publishAllPorts": true + } + }, + "$schema": "http://json.schemastore.org/launchsettings.json" +} \ No newline at end of file diff --git a/src/Prometheus.SystemMetrics.Example.AOT/appsettings.Development.json b/src/Prometheus.SystemMetrics.Example.AOT/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/src/Prometheus.SystemMetrics.Example.AOT/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/Prometheus.SystemMetrics.Example.AOT/appsettings.json b/src/Prometheus.SystemMetrics.Example.AOT/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/src/Prometheus.SystemMetrics.Example.AOT/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}