RichardBray / opentelemetry-node-example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Opentelemetry Node Example

This is a simple HTTP server that provides a dice roll service. It's built with TypeScript and uses the Hono server library. It also includes OpenTelemetry instrumentation for metrics and tracing.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  • Node.js (Note: OpenTelemetry currently does not support Bun and Deno)
  • npm
  • Docker

Installing

  1. Clone the repository
git clone https://github.com/yourusername/dice-roll-service.git
  1. Navigate into the cloned repository
cd dice-roll-service
  1. Install the dependencies
npm install
  1. Start the development server
npm run dev
  1. Run docker-compose to start Prometheus and Jaeger servers
docker-compose up

Now, the server is running at http://localhost:3000.

Usage

  • GET /: Returns a welcome message.
  • GET /roll?rolls=<number>: Returns the result of rolling a dice the specified number of times.

Metrics and Tracing

This project uses OpenTelemetry to collect metrics and traces. It exports metrics to a Prometheus server and traces to a Jaeger server.

You can start a Prometheus and Jaeger server using the provided Docker Compose file. Run docker-compose up to start the servers.

Prometheus will be available at http://localhost:9090 and Jaeger at http://localhost:16686.

About


Languages

Language:TypeScript 100.0%