Skip to content

Commit 3732ad7

Browse files
committed
Add interceptors package with useful typed Goa interceptor functions
- Add Trace Stream family of interceptor functions which allow for tracing of individual messages sent on bidirectional, client to server, and server to client streams. - Fix typos in several READMEs. [ ] Add tests for the interceptor functions.
1 parent 6799825 commit 3732ad7

File tree

9 files changed

+425
-48
lines changed

9 files changed

+425
-48
lines changed

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ Clue covers the following topics:
3030
downstream dependencies for testing.
3131
* Debugging: the [debug](debug/) package makes it possible to troubleshoot
3232
and profile services at runtime.
33+
* Interceptors: the [interceptors](interceptors/) package provides a set of
34+
helpful Goa interceptors.
3335

34-
Clue's goal is to provide all the anciallary functionality required to efficiently
36+
Clue's goal is to provide all the ancillary functionality required to efficiently
3537
operate a microservice style architecture including instrumentation, logging,
3638
debugging and health checks. Clue is not a framework and does not provide
3739
functionality that is already available in the standard library or in other
@@ -175,7 +177,7 @@ metricExporter, err := otlpmetricgrpc.New(
175177
```
176178

177179
These exporters can then be used to configure Clue:
178-
180+
179181
```go
180182
// Configure OpenTelemetry.
181183
cfg := clue.NewConfig(ctx, "service", "1.0.0", metricExporter, spanExporter)
@@ -190,27 +192,27 @@ HTTP clients can be instrumented using the Clue `log` and OpenTelemetry `otelhtt
190192
import (
191193
"context"
192194
"net/http"
193-
"net/http/httptrace"
195+
"net/http/httptrace"
194196

195-
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
197+
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
196198
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttptrace"
197199
"goa.design/clue/log"
198200
)
199201

200202
// ...
201203
httpc := &http.Client{
202204
Transport: log.Client(
203-
otelhttp.NewTransport(
204-
http.DefaultTransport,
205-
otelhttp.WithClientTrace(func(ctx context.Context) *httptrace.ClientTrace {
206-
return otelhttptrace.NewClientTrace(ctx)
207-
}),
208-
),
205+
otelhttp.NewTransport(
206+
http.DefaultTransport,
207+
otelhttp.WithClientTrace(func(ctx context.Context) *httptrace.ClientTrace {
208+
return otelhttptrace.NewClientTrace(ctx)
209+
}),
210+
),
209211
),
210212
}
211213
```
212214

213-
Similarly, gRPC clients can be instrumented using the Clue `log` and OpenTelemtry `otelgrpc` packages.
215+
Similarly, gRPC clients can be instrumented using the Clue `log` and OpenTelemetry `otelgrpc` packages.
214216

215217
```go
216218
import (
@@ -265,7 +267,7 @@ handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
265267
if _, err := w.Write([]byte("Hello, World!")); err != nil {
266268
log.Errorf(ctx, err, "failed to write response")
267269
}
268-
})
270+
})
269271
```
270272

271273
## Goa

debug/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ query parameter. The path, query parameter name and value can be customized by
2222
passing options to the `MountDebugLogEnabler` function.
2323

2424
Note that for the debug log state to take effect, HTTP servers must use handlers
25-
returned by the HTTP function and gRPC servers must make use of the
25+
returned by the HTTP function and gRPC servers must make use of the
2626
UnaryInterceptor or StreamInterceptor interceptors. Also note that gRPC
2727
services must expose an HTTP endpoint to control the debug log state.
2828

@@ -116,4 +116,4 @@ With this setup, requests made to the HTTP servers of each service of the form
116116
`/debug?debug-logs=on` turn on debug logs and requests of the form
117117
`/debug?debug-logs=off` turns them back off. Requests made to `/debug/pprof/`
118118
return the pprof package index page while a request to `/debug/pprof/profile`
119-
profile the service for 30s.
119+
profile the service for 30s.

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module goa.design/clue
22

3-
go 1.22.0
3+
go 1.22.7
44

5-
toolchain go1.23.2
5+
toolchain go1.23.5
66

77
require (
88
github.com/aws/smithy-go v1.22.2
@@ -20,19 +20,19 @@ require (
2020
go.opentelemetry.io/otel/sdk v1.34.0
2121
go.opentelemetry.io/otel/sdk/metric v1.34.0
2222
go.opentelemetry.io/otel/trace v1.34.0
23-
goa.design/goa/v3 v3.19.1
23+
goa.design/goa/v3 v3.19.2-rc1.0.20250205231826-8035d6986989
2424
golang.org/x/term v0.28.0
2525
golang.org/x/tools v0.29.0
2626
google.golang.org/genproto v0.0.0-20241015192408-796eee8c2d53
27-
google.golang.org/grpc v1.69.4
27+
google.golang.org/grpc v1.70.0
2828
google.golang.org/protobuf v1.36.4
2929
)
3030

3131
require (
3232
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
3333
github.com/davecgh/go-spew v1.1.1 // indirect
3434
github.com/dimfeld/httppath v0.0.0-20170720192232-ee938bf73598 // indirect
35-
github.com/go-chi/chi/v5 v5.1.0 // indirect
35+
github.com/go-chi/chi/v5 v5.2.0 // indirect
3636
github.com/go-logr/stdr v1.2.2 // indirect
3737
github.com/google/uuid v1.6.0 // indirect
3838
github.com/gorilla/websocket v1.5.3 // indirect

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
66
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
77
github.com/dimfeld/httppath v0.0.0-20170720192232-ee938bf73598 h1:MGKhKyiYrvMDZsmLR/+RGffQSXwEkXgfLSA08qDn9AI=
88
github.com/dimfeld/httppath v0.0.0-20170720192232-ee938bf73598/go.mod h1:0FpDmbrt36utu8jEmeU05dPC9AB5tsLYVVi+ZHfyuwI=
9-
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
10-
github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
9+
github.com/go-chi/chi/v5 v5.2.0 h1:Aj1EtB0qR2Rdo2dG4O94RIU35w2lvQSj6BRA4+qwFL0=
10+
github.com/go-chi/chi/v5 v5.2.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
1111
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
1212
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
1313
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
@@ -67,8 +67,8 @@ go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU
6767
go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4=
6868
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
6969
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
70-
goa.design/goa/v3 v3.19.1 h1:jpV3LEy7YANzPMwm++Lu17RoThRJgXrPxdEM0A1nlOE=
71-
goa.design/goa/v3 v3.19.1/go.mod h1:astNE9ube0YCxqq7DQkt1MtLxB/b3kRPEFkEZovcO2I=
70+
goa.design/goa/v3 v3.19.2-rc1.0.20250205231826-8035d6986989 h1:VFTZNWLuL2tdveOBHpsEmxvu9PJNrjLH9dvs6KvfieI=
71+
goa.design/goa/v3 v3.19.2-rc1.0.20250205231826-8035d6986989/go.mod h1:YFTHST5DUS9dPdL42h3o/Wtdb9VU6tKbytBxc5hOeLU=
7272
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
7373
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
7474
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
@@ -89,8 +89,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f h1:
8989
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:Ic02D47M+zbarjYYUlK57y316f2MoN0gjAwI3f2S95o=
9090
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI=
9191
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50=
92-
google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A=
93-
google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4=
92+
google.golang.org/grpc v1.70.0 h1:pWFv03aZoHzlRKHWicjsZytKAiYCtNS0dHbXnIdq7jQ=
93+
google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40RmcJSQw=
9494
google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM=
9595
google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
9696
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

go.work

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
go 1.22.0
1+
go 1.22.7
2+
3+
toolchain go1.23.5
24

35
use (
46
.

0 commit comments

Comments
 (0)