@get-tomo/tomo-deno-telemetry-sdk
v0.1.28
Published
Droppable SDK to initialize to instrument Deno applications. It collects traces and sends them to the specified collector URL. It follows the OpenTelemetry specification.
Maintainers
Readme
Tomo Deno Telemetry SDK
A simple SDK for adding OpenTelemetry-based tracing to your Deno applications.
Installation
Import the SDK and Deno's standard HTTP server:
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import TomoDenoTelemetry from "https://esm.sh/@get-tomo/tomo-deno-telemetry-sdk@latest";Usage
- Initialize the Telemetry SDK:
const tomoDenoTelemetry = new TomoDenoTelemetry({
debug: false,
apiKey: "your-api-key",
serviceName: "your-service-name",
serviceVersion: "your-service-version",
collectorUrl: "your-collector-url",
});- Wrap the Deno
servefunction (optional, for tracing HTTP requests):
const wrappedServe = tomoDenoTelemetry.wrapServe(serve);- Use
wrappedServeinstead of default Deno's serve:
wrappedServe(async (req) => {
const response = await fetch(
"https://jsonplaceholder.typicode.com/posts/1",
{
method: "GET",
headers: { "Accept": "application/json" },
}
);
const data = await response.json();
return new Response(data, {
status: 200,
headers: { "Content-Type": "text/plain" },
});
});Features
- Automatic tracing for HTTP server requests (when using
wrapServe) - Automatic tracing of outgoing HTTP requests
- Easy integration with OpenTelemetry-compatible collectors
Configuration
debug: Enable/Disable console debugging (required)apiKey: Your telemetry API key (required)serviceName: Name of your service (required)serviceVersion: Version of your service (required)collectorUrl: URL of your OpenTelemetry collector (required)
License
MIT
