mirror of
https://github.com/hanzoai/o11y.git
synced 2026-10-15 12:58:33 +00:00
Full rebrand of the SigNoz observability platform: - Go module: github.com/SigNoz/signoz → github.com/hanzoai/o11y - Frontend: @signozhq/* → @hanzo/o11y-*, posthog-js → @hanzo/insights - Docker: signoz/* → ghcr.io/hanzoai/o11y* - ClickHouse → Hanzo Datastore (hanzoai/datastore) - Env vars: SIGNOZ_* → HANZO_* - DB tables: signoz_* → o11y_* - All branding, URLs, docs updated - 2172 files changed
101 lines
2.2 KiB
Go
101 lines
2.2 KiB
Go
package implservices
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/hanzoai/o11y/pkg/http/binding"
|
|
"github.com/hanzoai/o11y/pkg/http/render"
|
|
"github.com/hanzoai/o11y/pkg/modules/services"
|
|
"github.com/hanzoai/o11y/pkg/types/authtypes"
|
|
"github.com/hanzoai/o11y/pkg/types/servicetypes/servicetypesv1"
|
|
"github.com/hanzoai/o11y/pkg/valuer"
|
|
)
|
|
|
|
type handler struct {
|
|
Module services.Module
|
|
}
|
|
|
|
func NewHandler(m services.Module) services.Handler {
|
|
return &handler{
|
|
Module: m,
|
|
}
|
|
}
|
|
|
|
func (h *handler) Get(rw http.ResponseWriter, req *http.Request) {
|
|
claims, err := authtypes.ClaimsFromContext(req.Context())
|
|
if err != nil {
|
|
render.Error(rw, err)
|
|
return
|
|
}
|
|
|
|
var in servicetypesv1.Request
|
|
if err := binding.JSON.BindBody(req.Body, &in); err != nil {
|
|
render.Error(rw, err)
|
|
return
|
|
}
|
|
|
|
orgUUID, err := valuer.NewUUID(claims.OrgID)
|
|
if err != nil {
|
|
render.Error(rw, err)
|
|
return
|
|
}
|
|
out, err := h.Module.Get(req.Context(), orgUUID, &in)
|
|
if err != nil {
|
|
render.Error(rw, err)
|
|
return
|
|
}
|
|
render.Success(rw, http.StatusOK, out)
|
|
}
|
|
|
|
func (h *handler) GetTopOperations(rw http.ResponseWriter, req *http.Request) {
|
|
claims, err := authtypes.ClaimsFromContext(req.Context())
|
|
if err != nil {
|
|
render.Error(rw, err)
|
|
return
|
|
}
|
|
|
|
var in servicetypesv1.OperationsRequest
|
|
if err := binding.JSON.BindBody(req.Body, &in); err != nil {
|
|
render.Error(rw, err)
|
|
return
|
|
}
|
|
|
|
orgUUID, err := valuer.NewUUID(claims.OrgID)
|
|
if err != nil {
|
|
render.Error(rw, err)
|
|
return
|
|
}
|
|
out, err := h.Module.GetTopOperations(req.Context(), orgUUID, &in)
|
|
if err != nil {
|
|
render.Error(rw, err)
|
|
return
|
|
}
|
|
render.Success(rw, http.StatusOK, out)
|
|
}
|
|
|
|
func (h *handler) GetEntryPointOperations(rw http.ResponseWriter, req *http.Request) {
|
|
claims, err := authtypes.ClaimsFromContext(req.Context())
|
|
if err != nil {
|
|
render.Error(rw, err)
|
|
return
|
|
}
|
|
|
|
var in servicetypesv1.OperationsRequest
|
|
if err := binding.JSON.BindBody(req.Body, &in); err != nil {
|
|
render.Error(rw, err)
|
|
return
|
|
}
|
|
|
|
orgUUID, err := valuer.NewUUID(claims.OrgID)
|
|
if err != nil {
|
|
render.Error(rw, err)
|
|
return
|
|
}
|
|
out, err := h.Module.GetEntryPointOperations(req.Context(), orgUUID, &in)
|
|
if err != nil {
|
|
render.Error(rw, err)
|
|
return
|
|
}
|
|
render.Success(rw, http.StatusOK, out)
|
|
}
|