@@ -18,6 +18,7 @@ import (
1818
1919 "github.com/Masterminds/semver/v3"
2020 "github.com/hasura/gotel"
21+ "github.com/hasura/gotel/otelutils"
2122 "github.com/hasura/ndc-sdk-go/v2/schema"
2223 "github.com/prometheus/client_golang/prometheus/promhttp"
2324 "go.opentelemetry.io/otel/attribute"
@@ -132,7 +133,7 @@ func NewServer[Configuration any, State any](
132133 return nil , err
133134 }
134135
135- ctx = NewContextLogger (ctx , telemetry .Logger )
136+ ctx = otelutils . NewContextWithLogger (ctx , telemetry .Logger )
136137
137138 configuration , err := connector .ParseConfiguration (ctx , options .Configuration )
138139 if err != nil {
@@ -165,7 +166,7 @@ func NewServer[Configuration any, State any](
165166
166167// GetCapabilities get the connector's capabilities. Implement a handler for the /capabilities endpoint, GET method.
167168func (s * Server [Configuration , State ]) GetCapabilities (w http.ResponseWriter , r * http.Request ) {
168- logger := GetLogger (r .Context ())
169+ logger := gotel . GetLogger (r .Context ())
169170
170171 capabilities := s .connector .GetCapabilities (s .configuration )
171172 if capabilities == nil {
@@ -181,7 +182,7 @@ func (s *Server[Configuration, State]) GetCapabilities(w http.ResponseWriter, r
181182
182183// Health checks the health of the connector. Implement a handler for the /health endpoint, GET method.
183184func (s * Server [Configuration , State ]) Health (w http.ResponseWriter , r * http.Request ) {
184- logger := GetLogger (r .Context ())
185+ logger := gotel . GetLogger (r .Context ())
185186 if err := s .connector .HealthCheck (r .Context (), s .configuration , s .state ); err != nil {
186187 s .writeError (w , logger , err )
187188
@@ -193,7 +194,7 @@ func (s *Server[Configuration, State]) Health(w http.ResponseWriter, r *http.Req
193194
194195// GetSchema implements a handler for the /schema endpoint, GET method.
195196func (s * Server [Configuration , State ]) GetSchema (w http.ResponseWriter , r * http.Request ) {
196- logger := GetLogger (r .Context ())
197+ logger := gotel . GetLogger (r .Context ())
197198
198199 schemaResult , err := s .connector .GetSchema (r .Context (), s .configuration , s .state )
199200 if err != nil {
@@ -216,7 +217,7 @@ func (s *Server[Configuration, State]) GetSchema(w http.ResponseWriter, r *http.
216217// Query implements a handler for the /query endpoint, POST method that executes a query.
217218func (s * Server [Configuration , State ]) Query (w http.ResponseWriter , r * http.Request ) {
218219 startTime := time .Now ()
219- logger := GetLogger (r .Context ())
220+ logger := gotel . GetLogger (r .Context ())
220221 span := trace .SpanFromContext (r .Context ())
221222
222223 var body schema.QueryRequest
@@ -263,7 +264,7 @@ func (s *Server[Configuration, State]) Query(w http.ResponseWriter, r *http.Requ
263264// QueryExplain implements a handler for the /query/explain endpoint, POST method that explains a query by creating an execution plan.
264265func (s * Server [Configuration , State ]) QueryExplain (w http.ResponseWriter , r * http.Request ) {
265266 startTime := time .Now ()
266- logger := GetLogger (r .Context ())
267+ logger := gotel . GetLogger (r .Context ())
267268 span := trace .SpanFromContext (r .Context ())
268269
269270 var body schema.QueryRequest
@@ -317,7 +318,7 @@ func (s *Server[Configuration, State]) MutationExplain( //nolint:dupl
317318 r * http.Request ,
318319) {
319320 startTime := time .Now ()
320- logger := GetLogger (r .Context ())
321+ logger := gotel . GetLogger (r .Context ())
321322 span := trace .SpanFromContext (r .Context ())
322323
323324 var body schema.MutationRequest
@@ -376,7 +377,7 @@ func (s *Server[Configuration, State]) Mutation( //nolint:dupl
376377 r * http.Request ,
377378) {
378379 startTime := time .Now ()
379- logger := GetLogger (r .Context ())
380+ logger := gotel . GetLogger (r .Context ())
380381 span := trace .SpanFromContext (r .Context ())
381382
382383 var body schema.MutationRequest
@@ -451,12 +452,17 @@ func (s *Server[Configuration, State]) unmarshalBodyJSON(
451452
452453 err := json .NewDecoder (requestReader ).Decode (body )
453454 if err != nil {
454- writeJson (w , GetLogger (r .Context ()), http .StatusUnprocessableEntity , schema.ErrorResponse {
455- Message : "failed to decode json request body" ,
456- Details : map [string ]any {
457- "cause" : err .Error (),
455+ writeJson (
456+ w ,
457+ gotel .GetLogger (r .Context ()),
458+ http .StatusUnprocessableEntity ,
459+ schema.ErrorResponse {
460+ Message : "failed to decode json request body" ,
461+ Details : map [string ]any {
462+ "cause" : err .Error (),
463+ },
458464 },
459- } )
465+ )
460466
461467 counter .Add (r .Context (), 1 , metric .WithAttributes (
462468 failureStatusAttribute ,
@@ -481,7 +487,7 @@ func (s *Server[Configuration, State]) validateMaxBodySize(
481487
482488 err := fmt .Errorf ("request body size exceeded %d MB(s)" , s .options .ServerMaxBodyMegabytes )
483489
484- writeJson (w , GetLogger (r .Context ()), http .StatusUnprocessableEntity , schema.ErrorResponse {
490+ writeJson (w , gotel . GetLogger (r .Context ()), http .StatusUnprocessableEntity , schema.ErrorResponse {
485491 Message : err .Error (),
486492 Details : map [string ]any {},
487493 })
0 commit comments