apitoolkit-adonis v3.5.6
AdonisJS SDK
APIToolkit Adonis Middleware 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 and response bodies.
Table of Contents
Installation
Run the following command to install the adonis js package from your projects root:
npm install --save apitoolkit-adonis @opentelemetry/api @opentelemetry/auto-instrumentations-node
Setup Open Telemetry
Setting up open telemetry allows you to send traces, metrics and logs to the APIToolkit platform.
export OTEL_EXPORTER_OTLP_ENDPOINT="http://otelcol.apitoolkit.io:4317"
export OTEL_SERVICE_NAME="my-service" # Specifies the name of the service.
export OTEL_RESOURCE_ATTRIBUTES=at-project-key="<YOUR_API_KEY>" # Adds your API KEY to the resource.
export OTEL_EXPORTER_OTLP_PROTOCOL="grpc" #Specifies the protocol to use for the OpenTelemetry exporter.
export NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register"
node ace run dev server.js # starting your adonis server
HTTP Requests Monitoring
You can monitor http requests using APIToolkit's Adonis middleware, this allows you to monitor all your http requests. including headers, response time, response status code, request body, response body, etc.
First configure the apitoolkit-adonis
sdk by running the following command:
node ace configure apitoolkit-adonis
Then, register the middleware by adding the apitoolkit-adonis
client to your global middleware list in the start/kernel.js|ts
file like so:
import server from '@adonisjs/core/services/server'
import APIToolkit from 'apitoolkit-adonis'
const client = new APIToolkit()
server.use([
() => import('#middleware/container_bindings_middleware'),
() => import('#middleware/force_json_response_middleware'),
() => import('@adonisjs/cors/cors_middleware'),
() => client.middleware(),
])
Then, create an apitoolkit.js|ts
file in the /conf
directory and export the defineConfig
object with some properties like so:
import { defineConfig } from 'apitoolkit-adonis'
export default defineConfig({
captureRequestBody: true,
captureResponseBody: true,
serviceName: 'my-service',
})
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.
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago