Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@oas-tools/oas-telemetry
Advanced tools
This package exports an Express middleware that traces requests and responses of an Express application using OpenTelemetry.
OAS Telemetry offers an express middleware designed for collecting telemetry data using Open Telemetry in applications built using the OpenAPI Specification (OAS). This middleware allows developers to easily incorporate telemetry functionality into their APIs.
OAS Telemetry provides a set of endpoints that can be accessed to perform various actions related to telemetry data, such as starting and stopping data collection, resetting telemetry data, listing collected data, and searching for specific telemetry records. These endpoints can be easily integrated into an Express.js application, providing developers with a convenient way to manage and analyze telemetry data.
Additionally, OAS Telemetry offers customization options, allowing developers to configure the telemetry middleware according to their specific requirements.
Overall, OAS Telemetry will serve as a valuable tool for developers looking to gain insights into the operation and performance of their OAS-based APIs, enabling them to monitor, debug, and optimize their applications effectively.
To use the middelware add this two lines in your index.js (ESM):
import oasTelemetry from 'oas-telemetry';
import {readFileSync} from 'fs';
app.use(oasTelemetry({
spec : readFileSync('./spec/oas.yaml',{ encoding: 'utf8', flag: 'r' })
}))
You can also customize the telemetry configuration by passing options to the middleware function. For example:
const customTelemetryConfig = {
exporter: myCustomExporter,
spec: /* OAS content in json or yaml */
};
app.use(oasTelemetry(customTelemetryConfig));
You can access the telemetry UI in the endpoint /telemetry
OAS Telemetry middleware adds the following endpoints to your Express application:
import oasTelemetry from '@oas-tools/oas-telemetry';
import express from 'express';
const app = express();
const port = 3000;
const spec = { "paths": {
"/api/v1/pets": {
"get": {
"summary": "Get pets",
"responses":{
"200": {
"description": "Success"
}
}
}
}
}
}
app.use(oasTelemetry({
spec : JSON.stringify(spec)
}))
app.use(express.json());
app.get("/api/v1/pets", (req, res) => {
res.send([{ name: "rocky"},{ name: "pikachu"}]);
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
console.log(`Telemetry portal available at http://localhost:${port}/telemetry`);
});
let oasTelemetry = require('@oas-tools/oas-telemetry');
let express = require('express');
const app = express();
const port = 3000;
const spec = { "paths": {
"/api/v1/pets": {
"get": {
"summary": "Get pets",
"responses":{
"200": {
"description": "Success"
}
}
}
}
}
}
app.use(oasTelemetry({
spec : JSON.stringify(spec)
}))
app.use(express.json());
app.get("/api/v1/pets", (req, res) => {
res.send([{ name: "rocky"},{ name: "pikachu"}]);
});
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
console.log(`Telemetry portal available at http://localhost:${port}/telemetry`);
});
FAQs
This package exports an Express middleware that traces requests and responses of an Express application using OpenTelemetry.
We found that @oas-tools/oas-telemetry demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.