@monoscopetech/adonis
v1.1.1
Published
<div align="center">
Downloads
140
Readme
AdonisJS SDK
Monoscope 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 @monoscopetech/adonis @opentelemetry/api @opentelemetry/auto-instrumentations-nodeSetup Open Telemetry
Setting up open telemetry allows you to send traces, metrics and logs to the Monoscope platform. Add the following enviroment variables.
OTEL_EXPORTER_OTLP_ENDPOINT="http://otelcol.apitoolkit.io:4317"
OTEL_SERVICE_NAME="my-service" # Specifies the name of the service.
OTEL_RESOURCE_ATTRIBUTES=at-project-key="<YOUR_API_KEY>" # Adds your API KEY to the resource.
OTEL_EXPORTER_OTLP_PROTOCOL="grpc" #Specifies the protocol to use for the OpenTelemetry exporter.HTTP Requests Monitoring
You can monitor http requests using Monoscope'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 @monoscopetech/adonis sdk by running the following command:
node ace configure @monoscopetech/adonisThen, register the middleware by adding the @monoscopetech/adonis client to your global middleware list in the start/kernel.js|ts file like so:
import '@opentelemetry/auto-instrumentations-node/register'
import server from '@adonisjs/core/services/server'
import Monoscope from '@monoscopetech/adonis'
const client = new Monoscope()
server.use([
() => import('#middleware/container_bindings_middleware'),
() => import('#middleware/force_json_response_middleware'),
() => import('@adonisjs/cors/cors_middleware'),
() => client.middleware(),
])Then, create an monoscope.js|ts file in the /conf directory and export the defineConfig object with some properties like so:
import { defineConfig } from '@monoscopetech/adonis'
export default defineConfig({
captureRequestBody: true,
captureResponseBody: true,
serviceName: 'my-service',
})[!IMPORTANT]
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.
