-
Notifications
You must be signed in to change notification settings - Fork 38
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
Record tags inconditionally at server receive #144
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -11,10 +11,6 @@ class RackHandler | |||
PATH_INFO = Rack::PATH_INFO rescue 'PATH_INFO'.freeze | ||||
REQUEST_METHOD = Rack::REQUEST_METHOD rescue 'REQUEST_METHOD'.freeze | ||||
|
||||
DEFAULT_SERVER_RECV_TAGS = { | ||||
Trace::Span::Tag::PATH => PATH_INFO | ||||
}.freeze | ||||
|
||||
def initialize(app, config = nil) | ||||
@app = app | ||||
@config = Config.new(app, config).freeze | ||||
|
@@ -37,6 +33,11 @@ def call(env) | |||
|
||||
private | ||||
|
||||
SERVER_RECV_TAGS = { | ||||
Trace::Span::Tag::PATH => PATH_INFO, | ||||
Trace::Span::Tag::METHOD => REQUEST_METHOD | ||||
}.freeze | ||||
|
||||
def span_name(env) | ||||
"#{env[REQUEST_METHOD].to_s.downcase} #{Application.route(env)}".strip | ||||
end | ||||
|
@@ -46,23 +47,17 @@ def annotate_plugin(span, env, status, response_headers, response_body) | |||
end | ||||
|
||||
def trace!(span, zipkin_env, &block) | ||||
trace_request_information(span, zipkin_env) | ||||
span.kind = Trace::Span::Kind::SERVER | ||||
status, headers, body = yield | ||||
ensure | ||||
trace_server_information(span, zipkin_env, status) | ||||
|
||||
annotate_plugin(span, zipkin_env.env, status, headers, body) | ||||
end | ||||
|
||||
def trace_request_information(span, zipkin_env) | ||||
tags = if [email protected]_on_server_receive.empty? | ||||
# if the user specified tags to record on server receive, use these no matter what | ||||
@config.record_on_server_receive | ||||
elsif !zipkin_env.called_with_zipkin_headers? | ||||
# if the request comes from a non zipkin-enabled source record the default tags | ||||
DEFAULT_SERVER_RECV_TAGS | ||||
end | ||||
return if tags.nil? | ||||
tags.each { |annotation_key, env_key| span.record_tag(annotation_key, zipkin_env.env[env_key]) } | ||||
def trace_server_information(span, zipkin_env, status) | ||||
span.kind = Trace::Span::Kind::SERVER | ||||
span.record_tag(Trace::Span::Tag::STATUS, status) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can consider doubling this as error so the span appears red ex from java // 1xx, 2xx, and 3xx codes are not all valid, but the math is good enough vs drift and opinion
// about individual codes in the range.
if (httpStatusInt < 100 || httpStatusInt > 399) {
customizer.tag("error", String.valueOf(httpStatusInt));
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is how we are doing it in client spans:
Maybe we can have a method like this in the Span class: STATUS_ERROR_REGEXP = /\A(4.*|5.*)\z/.freeze
def record_status(status)
record_tag(Tag::STATUS, status)
record_tag(Tag::ERROR, status) if STATUS_ERROR_REGEXP.match(status)
end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||
SERVER_RECV_TAGS.each { |annotation_key, env_key| span.record_tag(annotation_key, zipkin_env.env[env_key]) } | ||||
end | ||||
end | ||||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module ZipkinTracer | ||
VERSION = '0.34.0'.freeze | ||
VERSION = '0.35.0'.freeze | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove
:record_on_server_receive
on line 11