Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Boost RPC API to capture parent trace contexts #771

Merged
merged 2 commits into from
Sep 7, 2022

Conversation

kylehuntsman
Copy link
Contributor

@kylehuntsman kylehuntsman commented Sep 7, 2022

This PR enables the ability for Opencensus or OpenTelemtry span contexts passed into Boost RPC client calls to be captured by Boost RPC server, nesting Boost RPC traces under the parent span passed to a given RPC method. Fixes #769.

filecoin-project/go-jsonrpc already handles span contexts, but does so with Opencensus (OC) while boost is using Opentelemetry (OT). OC and OT trace spans are not compatible. However, OT has an OC API wrapper they call a bridge that allows us to use our OT tracer as the default OC tracer. This PR creates that bridge and sets up the default OC tracer to our OT tracer.

Client Side

filecoin-project/go-jsonrpc/client.go handles the given context and starts a new span from it called api.call. It puts this span context into a property on the request called Meta.SpanContext.

Server Side

filecoin-project/go-jsonrpc/handler.go then looks for Meta.SpanContext in the request object and decodes it into a SpanContext, starting a new span with it.

Additionally...

  • booster-http was not being built with make build/all, so I added it to make build/all and make push/all.

@@ -195,6 +195,10 @@ func (sm *BoostAPI) BoostDagstoreListShards(ctx context.Context) ([]api.Dagstore
}

func (sm *BoostAPI) BoostDagstorePiecesContainingMultihash(ctx context.Context, mh multihash.Multihash) ([]cid.Cid, error) {
ctx, span := tracing.Tracer.Start(ctx, "Boost.BoostDagstorePiecesContainingMultihash")
Copy link
Member

@nonsense nonsense Sep 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: our span names are a bit too long, we should figure a scheme to shorten them.

@nonsense nonsense merged commit 15a28c6 into main Sep 7, 2022
@kylehuntsman kylehuntsman deleted the kylehuntsman/tracing-context branch September 13, 2022 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Marshal/Unmarshal tracing context in Boost/Lotus JSON-RPC
2 participants