feat: logging

This commit is contained in:
Anatoly Antonov 2025-03-26 17:44:05 +03:00
parent 778d5ef146
commit fe5e40162b
10 changed files with 151 additions and 75 deletions

View file

@ -34,14 +34,14 @@ func (c *codeRecorder) WriteHeader(status int) {
//
// Get available satellites.
//
// GET /satellite
// GET /api/v1/satellite
func (s *Server) handleGetSatellitesRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
statusWriter := &codeRecorder{ResponseWriter: w}
w = statusWriter
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("GetSatellites"),
semconv.HTTPRequestMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/satellite"),
semconv.HTTPRouteKey.String("/api/v1/satellite"),
}
// Start a span for this request.
@ -164,14 +164,14 @@ func (s *Server) handleGetSatellitesRequest(args [0]string, argsEscaped bool, w
//
// Get available stations.
//
// GET /station
// GET /api/v1/station
func (s *Server) handleGetStationsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
statusWriter := &codeRecorder{ResponseWriter: w}
w = statusWriter
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("GetStations"),
semconv.HTTPRequestMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/station"),
semconv.HTTPRouteKey.String("/api/v1/station"),
}
// Start a span for this request.
@ -294,14 +294,14 @@ func (s *Server) handleGetStationsRequest(args [0]string, argsEscaped bool, w ht
//
// Get current subscriptions.
//
// GET /subscription
// GET /api/v1/subscription
func (s *Server) handleGetSubscriptionsRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
statusWriter := &codeRecorder{ResponseWriter: w}
w = statusWriter
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("GetSubscriptions"),
semconv.HTTPRequestMethodKey.String("GET"),
semconv.HTTPRouteKey.String("/subscription"),
semconv.HTTPRouteKey.String("/api/v1/subscription"),
}
// Start a span for this request.
@ -424,14 +424,14 @@ func (s *Server) handleGetSubscriptionsRequest(args [0]string, argsEscaped bool,
//
// Subscribe to a given station.
//
// POST /satellite/subscribe
// POST /api/v1/satellite/subscribe
func (s *Server) handleSubscribeSatelliteRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
statusWriter := &codeRecorder{ResponseWriter: w}
w = statusWriter
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("SubscribeSatellite"),
semconv.HTTPRequestMethodKey.String("POST"),
semconv.HTTPRouteKey.String("/satellite/subscribe"),
semconv.HTTPRouteKey.String("/api/v1/satellite/subscribe"),
}
// Start a span for this request.
@ -573,14 +573,14 @@ func (s *Server) handleSubscribeSatelliteRequest(args [0]string, argsEscaped boo
//
// Subscribe to a given station.
//
// POST /station/subscribe
// POST /api/v1/station/subscribe
func (s *Server) handleSubscribeStationRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
statusWriter := &codeRecorder{ResponseWriter: w}
w = statusWriter
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("SubscribeStation"),
semconv.HTTPRequestMethodKey.String("POST"),
semconv.HTTPRouteKey.String("/station/subscribe"),
semconv.HTTPRouteKey.String("/api/v1/station/subscribe"),
}
// Start a span for this request.
@ -722,14 +722,14 @@ func (s *Server) handleSubscribeStationRequest(args [0]string, argsEscaped bool,
//
// Remove subscription by subscription ID.
//
// DELETE /subscription
// DELETE /api/v1/subscription
func (s *Server) handleUnsubscribeRequest(args [0]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) {
statusWriter := &codeRecorder{ResponseWriter: w}
w = statusWriter
otelAttrs := []attribute.KeyValue{
otelogen.OperationID("Unsubscribe"),
semconv.HTTPRequestMethodKey.String("DELETE"),
semconv.HTTPRouteKey.String("/subscription"),
semconv.HTTPRouteKey.String("/api/v1/subscription"),
}
// Start a span for this request.