3.5.6 • Published 7 months ago

apitoolkit-adonis v3.5.6

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

APItoolkit's Logo APItoolkit's Logo

AdonisJS SDK

APItoolkit SDK npm.io npm.io Join Discord Server APItoolkit Docs

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',
})

!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:

License

This repository is published under the MIT license.


3.5.6

7 months ago

3.5.5

7 months ago

3.5.3

7 months ago

3.5.2

7 months ago

3.5.1

7 months ago

3.5.0

7 months ago

3.1.6

11 months ago

2.2.2

11 months ago

3.1.3

1 year ago

3.1.2

1 year ago

3.1.1

1 year ago

3.1.0

1 year ago

3.1.4

12 months ago

2.2.1

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

2.2.0

1 year ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.3

2 years ago

2.1.0

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago