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

fix: otel http parent propogation #3758

Merged
merged 1 commit into from
Dec 27, 2024
Merged

Conversation

markphelps
Copy link
Collaborator

Fixes issue raised in the community forum: https://community.flipt.io/t/ofrep-http-trace-context-propagation/66

It seems GRPC gateway / OTEL grpc instrumentation does not properly proxy the traceparent information via HTTP headers if present. This fixes that.

It also removes a couple deprecated method calls/setup from the OTEL/grpc projects

See: openfga/openfga#1624

Note: I used stdoutracing for demonstrating the changes before/after
Note: This also adds a new span named grpc-gateway before the grpc gateway span (ie: flipt.ofrep.OFREPService/EvaluateFlag)

Here's an example request, note the traceparent header which is used for parent span propagation:

curl --request POST \
  --url http://localhost:8080/ofrep/v1/evaluate/flags/adsfasd \
  --header 'content-type: application/json' \
  --header 'traceparent: 00-0af7651916cd43dd8448eb211c80319c-00f067aa0ba902b7-01' \
  --data '{
  "targetingKey":"foo"
}'

Before

Parent span is 000...

{
	"Name": "flipt.ofrep.OFREPService/EvaluateFlag",
	"SpanContext": {
		"TraceID": "570bf9d8a8b7c963664070d928e32a0a",
		"SpanID": "e4ab9f0a37167da9",
		"TraceFlags": "01",
		"TraceState": "",
		"Remote": false
	},
	"Parent": {
		"TraceID": "00000000000000000000000000000000",
		"SpanID": "0000000000000000",
		"TraceFlags": "00",
		"TraceState": "",
		"Remote": true
	},

After

Parent span is set correctly and traces are linked

{
	"Name": "flipt.ofrep.OFREPService/EvaluateFlag",
	"SpanContext": {
		"TraceID": "0af7651916cd43dd8448eb211c80319c",
		"SpanID": "6ec222e7bc6ad1f9",
		"TraceFlags": "01",
		"TraceState": "",
		"Remote": false
	},
	"Parent": {
		"TraceID": "0af7651916cd43dd8448eb211c80319c",
		"SpanID": "c4c833244fa22146",
		"TraceFlags": "01",
		"TraceState": "",
		"Remote": false
	},
	...
}
{
	"Name": "grpc-gateway",
	"SpanContext": {
		"TraceID": "0af7651916cd43dd8448eb211c80319c",
		"SpanID": "c4c833244fa22146",
		"TraceFlags": "01",
		"TraceState": "",
		"Remote": false
	},
	"Parent": {
		"TraceID": "0af7651916cd43dd8448eb211c80319c",
		"SpanID": "00f067aa0ba902b7",
		"TraceFlags": "01",
		"TraceState": "",
		"Remote": true
	},
	....
}

@markphelps markphelps requested a review from a team as a code owner December 27, 2024 17:03
Copy link

codecov bot commented Dec 27, 2024

Codecov Report

Attention: Patch coverage is 12.50000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 64.61%. Comparing base (7cb00e0) to head (119867a).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/cmd/http.go 0.00% 4 Missing ⚠️
cmd/flipt/main.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3758      +/-   ##
==========================================
- Coverage   64.63%   64.61%   -0.03%     
==========================================
  Files         170      170              
  Lines       17233    17241       +8     
==========================================
+ Hits        11139    11140       +1     
- Misses       5399     5406       +7     
  Partials      695      695              
Flag Coverage Δ
unittests 64.61% <12.50%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@markphelps markphelps added the automerge Used by Kodiak bot to automerge PRs label Dec 27, 2024
Copy link
Collaborator

@erka erka left a comment

Choose a reason for hiding this comment

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

niiice

@kodiakhq kodiakhq bot merged commit d3f98fb into main Dec 27, 2024
38 of 40 checks passed
@kodiakhq kodiakhq bot deleted the fix-otel-http-parent-propagation branch December 27, 2024 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Used by Kodiak bot to automerge PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants