Skip to content

Commit

Permalink
Added Jaeger instrumentation. (#8)
Browse files Browse the repository at this point in the history
* Added Jaeger instrumentation.
  • Loading branch information
DerekStrickland committed Oct 21, 2020
1 parent 4280cf7 commit 4a3934f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 73 deletions.
13 changes: 9 additions & 4 deletions client/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@ package client

import (
"fmt"
"log"
"net/http"

hckit "github.com/hashicorp-demoapp/go-hckit"
"github.com/hashicorp-demoapp/product-api-go/data/model"
)

// HTTP contains all client details
type HTTP struct {
client *http.Client
baseURL string
}

// NewHTTP creates a new HTTP client
func NewHTTP(baseURL string) *HTTP {
return &HTTP{baseURL}
c := &http.Client{Transport: hckit.TracingRoundTripper{Proxied: http.DefaultTransport}}
return &HTTP{c, baseURL}
}

// GetCoffees retrieves a list of coffees
func (h *HTTP) GetCoffees() ([]model.Coffee, error) {
resp, err := http.Get(fmt.Sprintf("%s/coffees", h.baseURL))
log.Print("INFO: Executing GetCoffees")
resp, err := h.client.Get(fmt.Sprintf("%s/coffees", h.baseURL))
if err != nil {
return nil, err
}
Expand All @@ -35,7 +40,7 @@ func (h *HTTP) GetCoffees() ([]model.Coffee, error) {

// GetCoffee retrieves a single coffee
func (h *HTTP) GetCoffee(coffeeID int) (*model.Coffee, error) {
resp, err := http.Get(fmt.Sprintf("%s/coffees/%d", h.baseURL, coffeeID))
resp, err := h.client.Get(fmt.Sprintf("%s/coffees/%d", h.baseURL, coffeeID))
if err != nil {
return nil, err
}
Expand All @@ -51,7 +56,7 @@ func (h *HTTP) GetCoffee(coffeeID int) (*model.Coffee, error) {

// GetIngredientsForCoffee retrieves a list of ingredients that go into a particular coffee
func (h *HTTP) GetIngredientsForCoffee(coffeeID int) ([]model.Ingredient, error) {
resp, err := http.Get(fmt.Sprintf("%s/coffees/%d/ingredients", h.baseURL, coffeeID))
resp, err := h.client.Get(fmt.Sprintf("%s/coffees/%d/ingredients", h.baseURL, coffeeID))
if err != nil {
return nil, err
}
Expand Down
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ module github.com/hashicorp-demoapp/product-api-go
go 1.13

require (
github.com/cucumber/gherkin-go/v11 v11.0.0
github.com/codahale/hdrhistogram v0.9.0 // indirect
github.com/cucumber/godog v0.9.0
github.com/cucumber/messages-go/v10 v10.0.3
github.com/cucumber/messages-go/v11 v11.1.1
github.com/cucumber/messages-go/v12 v12.1.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fsnotify/fsnotify v1.4.7
github.com/go-sql-driver/mysql v1.4.1 // indirect
github.com/gorilla/mux v1.7.3
github.com/hashicorp-demoapp/go-hckit v0.0.1
github.com/hashicorp/go-hclog v0.10.0
github.com/jinzhu/gorm v1.9.11 // indirect
github.com/jmoiron/sqlx v1.2.0
github.com/lib/pq v1.2.0
github.com/mattn/go-sqlite3 v1.11.0 // indirect
github.com/nicholasjackson/env v0.5.0
github.com/stretchr/testify v1.5.1
github.com/uber/jaeger-client-go v2.25.0+incompatible // indirect
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
go.opentelemetry.io/otel v0.2.0
go.opentelemetry.io/otel/exporter/metric/prometheus v0.2.0
golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 // indirect
Expand Down
Loading

0 comments on commit 4a3934f

Please sign in to comment.