Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasArdal committed Aug 7, 2024
1 parent e290d35 commit 625a3ea
Show file tree
Hide file tree
Showing 89 changed files with 75,568 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: ['https://elmah.io/', 'https://elmah.io/pricing/']
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- name: Install dependencies
run: dotnet restore

- name: Check vulnerable NuGet packages
uses: elmahio/github-check-vulnerable-nuget-packages-action@v1

- name: Build
run: dotnet build --configuration Release --no-restore

- name: Test
run: dotnet test --no-restore --verbosity normal

- name: Pack
run: dotnet pack --configuration Release src/Elmah.Io.OpenTelemetry/Elmah.Io.OpenTelemetry.csproj /p:Version=5.2.${{ github.run_number }}-pre

- name: Install dotnet-validate
run: dotnet tool install --global dotnet-validate --version 0.0.1-preview.304

- name: Validate
run: dotnet-validate package local src/Elmah.Io.OpenTelemetry/bin/Release/Elmah.Io.OpenTelemetry.5.2.${{ github.run_number }}-pre.nupkg

- name: Push
run: dotnet nuget push src/Elmah.Io.OpenTelemetry/bin/Release/Elmah.Io.OpenTelemetry.5.2.${{ github.run_number }}-pre.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
if: ${{ github.event_name == 'push' }}
48 changes: 48 additions & 0 deletions Elmah.Io.OpenTelemetry.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.34916.146
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{97E4DE5D-EADB-4BC3-9E41-BB3D64727B43}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Elmah.Io.OpenTelemetry", "src\Elmah.Io.OpenTelemetry\Elmah.Io.OpenTelemetry.csproj", "{AA4617C1-358B-4AE8-84EA-B35CE929DEFD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{15109CDB-981A-4549-81A3-F8DF2E84C40D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{8382E0E0-FBC5-4371-B52C-B727F4DB840A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elmah.Io.OpenTelemetry.AspNetCore80", "samples\Elmah.Io.OpenTelemetry.AspNetCore80\Elmah.Io.OpenTelemetry.AspNetCore80\Elmah.Io.OpenTelemetry.AspNetCore80.csproj", "{4184CE4E-FEBC-4FD9-9F16-16DCC971008A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elmah.Io.OpenTelemetry.Test", "test\Elmah.Io.OpenTelemetry.Test\Elmah.Io.OpenTelemetry.Test.csproj", "{24F07B79-A127-4B2E-839E-312591B0435E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AA4617C1-358B-4AE8-84EA-B35CE929DEFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AA4617C1-358B-4AE8-84EA-B35CE929DEFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA4617C1-358B-4AE8-84EA-B35CE929DEFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA4617C1-358B-4AE8-84EA-B35CE929DEFD}.Release|Any CPU.Build.0 = Release|Any CPU
{4184CE4E-FEBC-4FD9-9F16-16DCC971008A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4184CE4E-FEBC-4FD9-9F16-16DCC971008A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4184CE4E-FEBC-4FD9-9F16-16DCC971008A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4184CE4E-FEBC-4FD9-9F16-16DCC971008A}.Release|Any CPU.Build.0 = Release|Any CPU
{24F07B79-A127-4B2E-839E-312591B0435E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{24F07B79-A127-4B2E-839E-312591B0435E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{24F07B79-A127-4B2E-839E-312591B0435E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{24F07B79-A127-4B2E-839E-312591B0435E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{AA4617C1-358B-4AE8-84EA-B35CE929DEFD} = {97E4DE5D-EADB-4BC3-9E41-BB3D64727B43}
{4184CE4E-FEBC-4FD9-9F16-16DCC971008A} = {8382E0E0-FBC5-4371-B52C-B727F4DB840A}
{24F07B79-A127-4B2E-839E-312591B0435E} = {15109CDB-981A-4549-81A3-F8DF2E84C40D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DB967E9E-470E-43CF-9A71-356CA7B8DDE4}
EndGlobalSection
EndGlobal
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Elmah.Io.OpenTelemetry
Logging to elmah.io from OpenTelemetry

Log to [elmah.io](https://elmah.io/) from OpenTelemetry.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Elmah.Io.OpenTelemetry\Elmah.Io.OpenTelemetry.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@page
@model ErrorModel
@{
ViewData["Title"] = "Error";
}

<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}

<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;

namespace Elmah.Io.OpenTelemetry.AspNetCore80.Pages
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

private readonly ILogger<ErrorModel> _logger;

public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}

<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Elmah.Io.OpenTelemetry.AspNetCore80.Pages
{
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;

public IndexModel(ILogger<IndexModel> logger)
{
_logger = logger;
}

public void OnGet()
{
// This won't get logged since Default LogLevel is set to Warning in Program.cs
_logger.LogInformation("Request to the frontpage");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@page
@model PrivacyModel
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>

<p>Use this page to detail your site's privacy policy.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Elmah.Io.OpenTelemetry.AspNetCore80.Pages
{
public class PrivacyModel : PageModel
{
private readonly ILogger<PrivacyModel> _logger;

public PrivacyModel(ILogger<PrivacyModel> logger)
{
_logger = logger;
}

public void OnGet()
{
_logger.LogWarning("Someone is looking at the privacy page");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - Elmah.Io.OpenTelemetry.AspNetCore80</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/Elmah.Io.OpenTelemetry.AspNetCore80.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-page="/Index">Elmah.Io.OpenTelemetry.AspNetCore80</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>

<footer class="border-top footer text-muted">
<div class="container">
&copy; 2024 - Elmah.Io.OpenTelemetry.AspNetCore80 - <a asp-area="" asp-page="/Privacy">Privacy</a>
</div>
</footer>

<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>

@await RenderSectionAsync("Scripts", required: false)
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */

a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}

a {
color: #0077cc;
}

.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}

.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}

.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}

.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}

button.accept-policy {
font-size: 1rem;
line-height: inherit;
}

.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@using Elmah.Io.OpenTelemetry.AspNetCore80
@namespace Elmah.Io.OpenTelemetry.AspNetCore80.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}
Loading

0 comments on commit 625a3ea

Please sign in to comment.