Skip to content

🧪 Proof of Concept for a Web API made with .NET 8 (LTS) and ASP.NET Core 8.0

License

Notifications You must be signed in to change notification settings

apitoolkit/Dotnet.Samples.AspNetCore.WebApi

 
 

Repository files navigation

🧪 Web API made with .NET 8 (LTS) and ASP.NET Core 8.0

Status

.NET CI Build Status CodeFactor Maintainability Codacy Badge Codacy Badge

Manifesto

"Nobody should start to undertake a large project. You start with a small trivial project, and you should never expect it to get large. If you do, you'll just overdesign and generally think it is more important than it likely is at that stage. Or worse, you might be scared away by the sheer size of the work you envision. So start small, and think about the details. Don't think about some big picture and fancy design. If it doesn't solve some fairly immediate need, it's almost certainly over-designed. And don't expect people to jump in and help you. That's not how these things work. You need to get something half-way useful first, and then others will say "hey, that almost works for me", and they'll get involved in the project." — Linus Torvalds

About

Proof of Concept for a Web API made with ASP.NET Core 8.0 targeting .NET 8 inspired by the official guide: Create a web API with ASP.NET Core.

Start

dotnet watch run --project Dotnet.Samples.AspNetCore.WebApi/Dotnet.Samples.AspNetCore.WebApi.csproj

Documentation

https://localhost:9000/swagger/index.html

API Documentation

Credits

The solution has been coded using Visual Studio Code with the C# Dev Kit extension.

Terms

All trademarks, registered trademarks, service marks, product names, company names, or logos mentioned on this repository are the property of their respective owners. All usage of such terms herein is for identification purposes only and constitutes neither an endorsement nor a recommendation of those items. Furthermore, the use of such terms is intended to be for educational and informational purposes only.

Installation

Kindly run the command below to install the package:

dotnet add package ApiToolkit.Net

Setup OpenTelemetry

Run the following command to install the OpenTelemetry auto instrumentation for .NET:

# Download the bash script
curl -sSfL https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/latest/download/otel-dotnet-auto-install.sh -O

# Install core files
sh ./otel-dotnet-auto-install.sh

# Enable execution for the instrumentation script
chmod +x $HOME/.otel-dotnet-auto/instrument.sh

# Setup the instrumentation for the current shell session
. $HOME/.otel-dotnet-auto/instrument.sh

OpenTelemetry Configuration

After installating .NET autoinstrumentation packages, you can configure the OpenTelemetry instrumentation by setting the following environment variables:

export OTEL_EXPORTER_OTLP_ENDPOINT="http://otelcol.apitoolkit.io:4317" # Specifies the endpoint to send the traces to.
export OTEL_DOTNET_AUTO_TRACES_ADDITIONAL_SOURCES="APItoolkit.HTTPInstrumentation" # The apitoolkit instrumentation  activity resource.
export OTEL_SERVICE_NAME="my-service" # Specifies the name of the service.
export OTEL_RESOURCE_ATTRIBUTES="at-project-key={ENTER_YOUR_API_KEY_HERE}" # Adds your API KEY to the resource.
export OTEL_EXPORTER_OTLP_PROTOCOL="grpc" # Specifies the protocol to use for the OpenTelemetry exporter.

After setting the environment variables, build and run your application and you should see the logs, traces and metrics in the APIToolkit dashboard.

About

🧪 Proof of Concept for a Web API made with .NET 8 (LTS) and ASP.NET Core 8.0

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%