GithubHelp home page GithubHelp logo

nuttawut503 / grpc-gateway-otel-example Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 27 KB

building gRPC Gateway and tracing requests to gRPC with Otelgrpc's OpenTelemetry-contrib

Go 98.76% Shell 1.24%

grpc-gateway-otel-example's Introduction

gRPC Gateway with Otelgrpc

Modules

This application has two services - Customer and Order

  • Customer, I added two default customers and their IDs are "A310" and "K423" each customer has credit_limit (will explain about why it exists)
  • Order, when making an order, we need a customer_id and the order_price if the order_price is more than the customer's credit_limit then the order service won't allow the order to be created. But if the order_price is less than or equal to the customer's credit_limit then the order service will create the order and return transaction_id back to the customer

For my gRPC, it has three functions

  • CustomerService; GetCustomers() get all customers' info
  • CustomerService; GetCustomerCreditLimit(), get credit_limit of a customer (customer_id is required)
  • OrderService; CreateCustomerOrder() to make an order (customer_id and the price is required) when a customer request for an order, the service will talk to the customer service to get the customer's credit_limit then check if it is ok to continue the order. If the order service allows, the customer will get a transaction_id in response else the customer will get an error and can't make the order

How to run

  • Docker or Jaeger required
# if docker
chmod +x jaeger-docker.sh
./jaeger-docker.sh
# open two terminals and run these two services individually
go run grpc-tracing/customer
go run grpc-tracing/order

Available URLs to test

  • GET localhost:8081/customers
  • POST localhost:8082/order

Example

curl localhost:8081/customers
curl localhost:8082/order \
-H 'Content-Type: application/json' \
-d '{"customerId": "A310", "price": 22}'

Visit the Jaeger UI http://localhost:16686/

grpc-gateway-otel-example's People

Contributors

nuttawut503 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.