Skip to content

Sample Golang app to demonstrace OpenTelemetry instrumentation

Notifications You must be signed in to change notification settings

SigNoz/sample-golang-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bookstore REST API using Gin and Gorm

Read this article on understand how to build a sample golang app using Gin and Gorm.

Note:

If you are using the without-instrumentation branch to instrument the app following the blog post present here, after you are done with making the necessary changes in the main.go file, run:

go mod tidy

to download the required packages and populate the go.sum file.

To run and configure app to send data to SigNoz:

For SigNoz Cloud:

SERVICE_NAME=goApp INSECURE_MODE=false OTEL_EXPORTER_OTLP_HEADERS=signoz-access-token=<SIGNOZ-INGESTION-TOKEN> OTEL_EXPORTER_OTLP_ENDPOINT=ingest.{region}.signoz.cloud:443 go run main.go
  • Update <SIGNOZ-INGESTION-TOKEN> with the ingestion token provided by SigNoz
  • Update ingest.{region}.signoz.cloud:443 with the ingestion endpoint of your region. Refer to the table below for the same.
Region Endpoint
US ingest.us.signoz.cloud:443
IN ingest.in.signoz.cloud:443
EU ingest.eu.signoz.cloud:443

For SigNoz OSS:

SERVICE_NAME=goApp INSECURE_MODE=true OTEL_EXPORTER_OTLP_ENDPOINT=<IP of SigNoz backend>:4317 go run main.go
  • <IP of SigNoz backend:4317> should be without http/https scheme. Eg localhost:4317.

This runs the gin application at port 8090. Try accessing API at http://localhost:8090/books

Below are the apis available to play around. The API calls will generate telemetry data which will be sent to SigNoz which can be viewed at <IP of SigNoz backend>:3000

GET    /books                    
GET    /books/:id               
POST   /books                    
PATCH  /books/:id                
DELETE /books/:id                

The OpenTelemetry registry is the best place to discover instrumentation packages. It will include packages outside of this project.

The following instrumentation packages are provided for popular Go packages and use-cases.

Instrumentation Package Metrics Traces
github.com/astaxie/beego
github.com/aws/aws-sdk-go-v2
github.com/bradfitz/gomemcache
github.com/emicklei/go-restful
github.com/gin-gonic/gin
github.com/go-kit/kit
github.com/gocql/gocql
github.com/gorilla/mux
github.com/labstack/echo
github.com/Shopify/sarama
go.mongodb.org/mongo-driver
google.golang.org/grpc
gopkg.in/macaron.v1
host
net/http
net/http/httptrace
runtime

Follow Opentelemetry docs for examples on latest otel releases: Opentelemetry-go

About

Sample Golang app to demonstrace OpenTelemetry instrumentation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages