ApiToolkit.Net
2.1.2
dotnet add package ApiToolkit.Net --version 2.1.2
NuGet\Install-Package ApiToolkit.Net -Version 2.1.2
<PackageReference Include="ApiToolkit.Net" Version="2.1.2" />
<PackageVersion Include="ApiToolkit.Net" Version="2.1.2" />
<PackageReference Include="ApiToolkit.Net" />
paket add ApiToolkit.Net --version 2.1.2
#r "nuget: ApiToolkit.Net, 2.1.2"
#addin nuget:?package=ApiToolkit.Net&version=2.1.2
#tool nuget:?package=ApiToolkit.Net&version=2.1.2
<div align="center">
.NET Core SDK
APIToolkit .NET SDK is a middleware that can be used to monitor HTTP requests. It is provides additional functionalities on top of the open telemetry instrumentation which creates a custom span for each request capturing details about the request including request, response bodies errors and outgoing requests.
</div>
Table of Contents
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.
SDK Configuration
The SDK allows you to capture the request and response bodies, errors, outgoing requests and more.
eg:
using ApiToolkit.Net;
// Initialize the APItoolkit client
var config = new Config
{
Debug = false,
Tags = new List<string> { "environment: production", "region: us-east-1" },
ServiceVersion: "v2.0",
};
var client = await APIToolkit.NewClient(config);
// END Initialize the APItoolkit client
// Register the middleware to use the initialized client
app.Use(async (context, next) =>
{
var apiToolkit = new APIToolkit(next, client);
await apiToolkit.InvokeAsync(context);
});
# app.UseEndpoint(..)
# other middleware and logic
# ...
- Please make sure the APItoolkit middleware is added before
UseEndpoint
and other middleware are initialized. - The
{ENTER_YOUR_API_KEY_HERE}
demo string should be replaced with the API key generated from the APItoolkit dashboard.
<br />
To learn more configuration options (redacting fields, error reporting, outgoing requests, etc.), please read this SDK documentation.
Contributing and Help
To contribute to the development of this SDK or request help from the community and our team, kindly do any of the following:
- Read our Contributors Guide.
- Join our community Discord Server.
- Create a new issue in this repository.
License
This repository is published under the MIT license.
<div align="center">
<a href="https://apitoolkit.io?utm_campaign=devrel&utm_medium=github&utm_source=sdks_readme" target="_blank" rel="noopener noreferrer"><img src="https://github.com/apitoolkit/.github/blob/main/images/icon.png?raw=true" width="40" /></a>
</div>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Microsoft.AspNetCore.Hosting (>= 2.2.7)
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.AspNetCore.Http.Extensions (>= 2.2.0)
- Microsoft.AspNetCore.Routing (>= 2.2.2)
- Microsoft.AspNetCore.TestHost (>= 6.0.0)
- Microsoft.NET.Test.Sdk (>= 17.6.2)
- Newtonsoft.Json (>= 13.0.3)
- NUnit (>= 3.13.3)
- System.Diagnostics.DiagnosticSource (>= 9.0.0)
-
net7.0
- Microsoft.AspNetCore.Hosting (>= 2.2.7)
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.AspNetCore.Http.Extensions (>= 2.2.0)
- Microsoft.AspNetCore.Routing (>= 2.2.2)
- Microsoft.AspNetCore.TestHost (>= 6.0.0)
- Microsoft.NET.Test.Sdk (>= 17.6.2)
- Newtonsoft.Json (>= 13.0.3)
- NUnit (>= 3.13.3)
- System.Diagnostics.DiagnosticSource (>= 9.0.0)
-
net8.0
- Microsoft.AspNetCore.Hosting (>= 2.2.7)
- Microsoft.AspNetCore.Http (>= 2.2.2)
- Microsoft.AspNetCore.Http.Extensions (>= 2.2.0)
- Microsoft.AspNetCore.Routing (>= 2.2.2)
- Microsoft.AspNetCore.TestHost (>= 6.0.0)
- Microsoft.NET.Test.Sdk (>= 17.6.2)
- Newtonsoft.Json (>= 13.0.3)
- NUnit (>= 3.13.3)
- System.Diagnostics.DiagnosticSource (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.