Skip to content

Latest commit

 

History

History
40 lines (32 loc) · 2.16 KB

README.md

File metadata and controls

40 lines (32 loc) · 2.16 KB

Otel Demo

otel-demo

This is a demo application that implements an asynchronous calculator. It consts of a "controller" microservice that handles connect-go (gRPC) requests and a "worker" microservice that is implemented as a google cloud function. The controller microservice schedules work to the worker microservice via google Pubsub. The worker microservice receives a calculation request via pubsub, performs the calculation and returns the response back to the controller via pubsub. The controller them stores the result to a Cloud SQL postgres database.

This demo shows how to use OpenTelemetry in a Go application that is running on GCP. It demonstrates the usage of middleware to seamlessly propagate context across services and how to use the OpenTelemetry SDK to create custom spans. It implements a middleware for google Pubsub that transfers the trace context in the message metadata.

Slides

Talk: https://www.youtube.com/watch?v=5rjTdA6BM1E

You can find the slides for this talk here

Architecture

flowchart TD
    CUSTOMER[Customer] ==>|1. Calculate expression| CONTROLLER(Controller)
    CONTROLLER --> |2. Store scheduled calculation with UUID| DB_STORE[(CloudSQL)]
    CONTROLLER -.-> |3. Queue Work| PUBSUB([Pubsub])
    PUBSUB -.-> |4. Get work| MATH(Math Cloud Function)
    MATH --> |5. Calculate| MATH
    MATH -.-> |6. Calculation Result|PUBSUB
    PUBSUB -.-> |7. Result ready| CONTROLLER
    CONTROLLER ---> |8. Save result| DB_STORE
Loading

Implementation Details

  1. RPC requests are recieved by the controller microservice using the connect protocol.
    • It implements the Calculate and the List methods.
  2. The controller stores the request in postgres using Gorm package
  3. The controller scheduled calculation using the Pubsub library.
  4. The math worker is implemented as a GCP Cloud Function. It receives the calculation request via Pubsub and returns the result via Pubsub.
  5. The controller receives the result via Pubsub and stores it in postgres.