End to end setup
In this example, we're setting up an example project that:
- has tracing enabled
- exposes an endpoint to collect user data
- creates and produces message into Kafka
- processes messages 6 times while simulating a failure condition
- simulates a succeeding condition at the end
Enable tracing across entire binary
While KP produces spans, it has no knowledge on where the spans need to be sent and in which format. We expect libary user to set that up.
In this example we're setting up jaeger traces to send to tempo.
Start all dependencies that you need
Here's a sample docker-compose.yaml that starts the dependencies that the demo requires.
Setup tracing such that trace-ids are exposed to the user
Here's tracing setup that exposes traceparent header via response headers.
Produce a message with traces
Producing a message is as simple as calling .Produce
with a request context as a first parameters and the message as second parameter.
Configuring worker to fail multiple times
Configure worker with retries, deadletters and tracing as shown
Execution
Simply enter into v2/examples/full
directory and simply run docker-compose up
or docker compose up
and wait for docker compose ps sleep
command to indicate the container has exited (it'll take about 90 seconds)
Once docker compose logs web
command indicates the server is listening, open the link in the browser and submit an email. Click on the link and refresh after a few seconds for traces to arrive.