Skip to content

Add instructions how to integrate with opentelemetry #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ They are similar, but GRPC-WEB target is to be as close to GRPC as possible, whi
web-friendly: it has better client libraries, better web semantics:
content-type is `application/json` instead of `application/grpc-web+json`, error codes are just normal http codes
instead of being sent in headers, errors are output in the body of the response JSON-encoded, it supports GET-requests,
etc (you can also read this [blog post describing why ConnectRPC is better](https://buf.build/blog/connect-a-better-grpc)).
etc (you can also read
this [blog post describing why ConnectRPC is better](https://buf.build/blog/connect-a-better-grpc)).

Both protocols support encoding data in Protobuf and JSON.
JSON is more web-friendly, but it requires having some component in the middle, providing JSON → Protobuf
Expand Down Expand Up @@ -109,6 +110,31 @@ val httpServer: Resource[IO, org.http4s.server.Server] = {
httpServer.use(_ => IO.never).unsafeRunSync()
```

### Tip: GRPC Opentelemetry integration

Since the library creates a separate "fake" grpc server, traffic going through it won't be captured by the
instrumentation of the main grpc server.

Here is how you can integrate the Opentelemetry with the Connect-RPC server:

```scala
val grpcServices: Seq[io.grpc.ServiceDefinition] = ??? // Your GRPC service(s)
val grpcOtel : GrpcOpenTelemetry = ??? // GrpcOpenTelemetry instance

ConnectRpcHttpRoutes.create[IO](
grpcServices,
Configuration.default
// Configure the server to use the same opentelemetry instance as the main server
.withServerConfigurator { sb =>
grpcOtel.configureServerBuilder(sb)
sb
}
)
```

This will make sure that all the traffic going through the Connect-RPC server will be captured by the same
opentelemetry.

## Development

### Running Connect-RPC conformance tests
Expand Down