Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cyprinus12138/otelgin
OpenTelemetry trace & metric instrumentation as Gin Middleware
https://github.com/cyprinus12138/otelgin
gin gin-gonic gin-middleware http http-server metrics opentelemetry-go tracer
Last synced: about 1 month ago
JSON representation
OpenTelemetry trace & metric instrumentation as Gin Middleware
- Host: GitHub
- URL: https://github.com/cyprinus12138/otelgin
- Owner: Cyprinus12138
- License: apache-2.0
- Created: 2024-03-26T17:41:52.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-04-13T07:34:01.000Z (7 months ago)
- Last Synced: 2024-09-28T18:20:54.382Z (about 2 months ago)
- Topics: gin, gin-gonic, gin-middleware, http, http-server, metrics, opentelemetry-go, tracer
- Language: Go
- Homepage:
- Size: 52.7 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Go OpenTelemetry Gonic-gin Trace & Metrics Instrumentation
[![ci](https://github.com/Cyprinus12138/otelgin/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/Cyprinus12138/otelgin/actions/workflows/go.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/Cyprinus12138/otelgin)](https://goreportcard.com/report/github.com/Cyprinus12138/otelgin)
[![Documentation](https://godoc.org/github.com/Cyprinus12138/otelgin?status.svg)](https://pkg.go.dev/mod/github.com/Cyprinus12138/otelgin)It is an OpenTelemetry (OTel) trace & metric instrumentation for http server implement with Gonic-gin. [Gin Web Framework](https://gin-gonic.com/).
## Install
```bash
$ go get github.com/Cyprinus12138/otelgin
```## Usage
Metrics are reported based on [Semantic Conventions for HTTP Metrics](https://opentelemetry.io/docs/specs/semconv/http/http-metrics/#http-server) :
1. `http.server.request.duration`
2. `http.server.request.body.size`
3. `http.server.response.body.size`
4. `http.server.active_requests`### Plugin as a middleware
[Example Server](https://github.com/Cyprinus12138/otelgin/blob/main/example/server.go)
```go
r := gin.New()
r.Use(otelgin.Middleware("my-server"))
```