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

Improvements for jaegertracing #62

Merged
merged 2 commits into from
Dec 18, 2021
Merged

Improvements for jaegertracing #62

merged 2 commits into from
Dec 18, 2021

Conversation

ont
Copy link
Contributor

@ont ont commented Oct 6, 2021

Changes:

  • fixed http.status_code value. Now it is always correct. Ugly workaround removed.
  • middleware code more readable.
  • simplified ResponseDumper version instead of bodyDumpResponseWriter
  • added tags for client real IP and X-Request-ID header
  • replace span.SetTag with span.LogKV for values with big cardinality (it can be discussed)

Changes:
- fixed http.status_code value. Now it is always correct. Ugly
  workaround removed.
- middleware code more readable.
- simplified ResponseDumper version instead of bodyDumpResponseWriter
- added tags for client real IP and X-Request-ID header
- replace span.SetTag with span.LogKV for values with big cardinality.
Copy link
Contributor

@lammel lammel left a comment

Choose a reason for hiding this comment

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

Due to a little lack of knowledge for jaegertracing the questions might seems a little strange, just based on code review here.

}

// echo request_id back in response
c.Response().Header().Set(echo.HeaderXRequestID, requestID)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually something that the RequestID middleware handles.
Is there es specific reason it is required for jaegertracing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No there is no specific reason for doing it in jaegertracing.

@@ -128,82 +129,101 @@ func TraceWithConfig(config TraceConfig) echo.MiddlewareFunc {

req := c.Request()
opname := "HTTP " + req.Method + " URL: " + c.Path()
realIP := c.RealIP()
requestID := getRequestID(c) // request-id generated by reverse-proxy
Copy link
Contributor

Choose a reason for hiding this comment

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

Is a request ID required for jaeger tracing?
It looks like it would be compatible with the request ID middleware here (same as below)

Copy link
Contributor Author

@ont ont Dec 16, 2021

Choose a reason for hiding this comment

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

Request id logged into opentracing tags below:

sp.SetTag("request_id", requestID)

It is much easier than write custom RequestIDHandler for request-id middleware.

Tags are essential for searching opentracing traces later.

@@ -18,6 +18,7 @@ import (
type mockSpan struct {
tracer opentracing.Tracer
tags map[string]interface{}
logs map[string]interface{}
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason to separate tags and logs?
The name logs seems a little misleading here. Seems like only body and error message are put there currently.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opentracing has two separate concepts: tags and logs. In fact the logs are more complicated: it is timestamped packs for key-values pairs but for simplification here it is written as simple map[string]interface{}. Because tags and logs can both have same keys they are separated.

- dump limit for huge request/response bodies
- responseDumper is now private
@codecov
Copy link

codecov bot commented Dec 18, 2021

Codecov Report

Merging #62 (66536cb) into master (4d116ee) will increase coverage by 4.05%.
The diff coverage is 98.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #62      +/-   ##
==========================================
+ Coverage   55.41%   59.46%   +4.05%     
==========================================
  Files           8        8              
  Lines         462      671     +209     
==========================================
+ Hits          256      399     +143     
- Misses        186      251      +65     
- Partials       20       21       +1     
Impacted Files Coverage Δ
jaegertracing/jaegertracing.go 54.73% <98.48%> (+7.96%) ⬆️
jaegertracing/response_dumper.go 100.00% <100.00%> (ø)
zipkintracing/tracing.go 63.73% <0.00%> (-5.02%) ⬇️
pprof/pprof.go 100.00% <0.00%> (ø)
prometheus/prometheus.go 51.94% <0.00%> (+2.50%) ⬆️
casbin/casbin.go 89.13% <0.00%> (+4.51%) ⬆️
zipkintracing/response_writer.go 21.27% <0.00%> (+5.27%) ⬆️
session/session.go 100.00% <0.00%> (+10.52%) ⬆️

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 4d116ee...66536cb. Read the comment docs.

@lammel lammel merged commit 2722c78 into labstack:master Dec 18, 2021
@lammel
Copy link
Contributor

lammel commented Dec 18, 2021

Thanks @ont for your contribution.
Merged.

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.

2 participants