mirror of
https://github.com/davegallant/rfd-fyi.git
synced 2025-08-07 09:02:27 +00:00
Add manual honeycomb trace
This commit is contained in:
8
Makefile
8
Makefile
@@ -16,7 +16,7 @@ help:
|
|||||||
## backend: Build and run the backend from source
|
## backend: Build and run the backend from source
|
||||||
backend:
|
backend:
|
||||||
@cd backend && go run .
|
@cd backend && go run .
|
||||||
.PHONY: server
|
.PHONY: backend
|
||||||
|
|
||||||
|
|
||||||
## frontend: Build and run the frontend from source
|
## frontend: Build and run the frontend from source
|
||||||
@@ -26,6 +26,10 @@ frontend:
|
|||||||
|
|
||||||
## up: Build and run in docker compose
|
## up: Build and run in docker compose
|
||||||
up:
|
up:
|
||||||
@if [ -e .env ]; then echo "Missing file: .env"; fi
|
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
.PHONY: up
|
.PHONY: up
|
||||||
|
|
||||||
|
## teardown: Teardown docker
|
||||||
|
teardown:
|
||||||
|
docker compose down
|
||||||
|
.PHONY: teardown
|
||||||
|
@@ -5,12 +5,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
"go.opentelemetry.io/otel"
|
||||||
)
|
)
|
||||||
|
|
||||||
// @title RFD FYI API
|
// @title RFD FYI API
|
||||||
@@ -74,6 +76,11 @@ func respondWithJSON(w http.ResponseWriter, code int, payload interface{}) {
|
|||||||
// @Router /topics [get]
|
// @Router /topics [get]
|
||||||
// @Success 200 {array} Topic
|
// @Success 200 {array} Topic
|
||||||
func (a *App) listTopics(w http.ResponseWriter, r *http.Request) {
|
func (a *App) listTopics(w http.ResponseWriter, r *http.Request) {
|
||||||
|
tracer := otel.Tracer(os.Getenv("OTEL_SERVICE_NAME"))
|
||||||
|
ctx := r.Context()
|
||||||
|
ctx, span := tracer.Start(ctx, "list-topics")
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
if time.Since(a.LastRefresh).Minutes() > 1 {
|
if time.Since(a.LastRefresh).Minutes() > 1 {
|
||||||
a.refreshTopics()
|
a.refreshTopics()
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user