xmidt-org / golang-money

This is the Go implementation of Money
Apache License 2.0
14 stars 10 forks source link

completing golang_money #39

Closed githubsands closed 2 years ago

githubsands commented 6 years ago

[WIP] Overall Refactor, some general changes and additions for a working distributed tracing library that are revolve around two main components. A client side transactor for making out bound requests and a server side alice style decorator for handling inbound request. A go routine is used to communicate http trackers to transactor types for outbound request.

As of now the alice style decorator has four main states that are chosen through options.

(1) Starter: To be used on edge servers. This injects a tracker and starts the spanning graph (2) Subtracer: To be used on non edge servers. Creates a new child span id from an extracted tracker and continues the spanning graph.
(3) Ender: To be used on servers that do not need to inject trackers into requests. (4) Default/Off

Changes:

spanner.go

Decoupled Spanner from HTTPTracker by injecting a SpanDecoder into a HTTPTracker using func StartHTTPTracker. This opened the doors to unit test HTTPTracker individually.

Changed the Spanner interface is to be populated with a SubTrace and Starter

Removed all spanner.go details into httpspanner.go

httpspanner.go

Spanner components are migrated here so they can be easily differed between the spanner interface and httpspanner objects and methods.

New func StartHTTPTracker

tracker.go

Changed:

MoneyHeader to MoneyTraceHeader = X-Money-Trace
MoneySpansHeader = X-Money-Span NOTE: this is to abide by http.Set, the function does not keep capital letters. I know this may not be the same as how RDK sends X-money headers. Please comment if change needed.

Removes pointer from HTTPTracker’s mutex.

Added error handling for tracker and http functions.

NewHTTPTracker was created to decouple a tracker creation from a Spanner’s Start. This opened the door to individually unit test tracker methods.

Changes func Start to func SubTrace to more closely defines what this function does.

func HTTPTracker returns a httpTracker.

Changes func Spans to func SpansList so there is no confusion whether this functions purpose is spanmap objects or span strings.

Changs Lists to SpanLists

func Map and func SpansMaps to make use of spanMaps.

Includes func InjectTracker inside func DecorateTransactor so trackers can be injected to outbound request.

trace.go

func Result turns a Result object into a concatenated string of a span’s fields.

Renames SubTrace to doSubTrace.

httpspanneroptions.go

A place where spanner options are defined.

httpspanner.go

Moves all old spanner objects here but the spanner interface.

httpspannercontainers.go

Httpspanner containers are objects that are needed to fulfill a specific httpspanner option.

httpspannerprocesses.go

Where processes are defined for each option. This was made to specifically manage the decorator's size as it grows. Each option has a container that holds its process.

http.go

func ExtractTracker whose purpose is to quickly extract a tracker from a request.

func InjectTracker to quickly inject a tracker into a request

migrates simpleResponseWriter as well as header constants.

func WriteMoneySpansHeader: writes a Span’s Result to a header.

func checkHeaderForMoneyTrace: checks if a header has a MoneyHeader returns a bool.

func checkHeaderForMoneySpan: checks if a header has a MoneySpan returns a bool.

transactionoptions.go

Migrates spanfowardingoptions here. This is where future options should be placed.

Other:

test coverage includes run_test.sh + travis update. documentation

To do:

codecov[bot] commented 6 years ago

Codecov Report

Merging #39 into master will increase coverage by 8.67%. The diff coverage is 71.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #39      +/-   ##
==========================================
+ Coverage   67.95%   76.62%   +8.67%     
==========================================
  Files           4        7       +3     
  Lines         181      338     +157     
==========================================
+ Hits          123      259     +136     
- Misses         55       67      +12     
- Partials        3       12       +9
Impacted Files Coverage Δ
span.go 92.85% <100%> (+1.36%) :arrow_up:
trace.go 96.07% <33.33%> (-3.93%) :arrow_down:
httpspannerprocesses.go 60% <60%> (ø)
httpspanneroptions.go 64.1% <64.1%> (ø)
http.go 65.62% <65.62%> (ø)
tracker.go 69.89% <72.15%> (+64.12%) :arrow_up:
httpspanner.go 76.19% <76.19%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1b3ac61...9ca03cd. Read the comment docs.

CLAassistant commented 5 years ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


githubsands seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.