-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add support for logEntry->traceSampled field extraction. #297
Conversation
Fixed Travis |
@@ -643,7 +647,8 @@ def write(chunk) | |||
# Propagate these if necessary. Note that we don't want to | |||
# override these keys in the JSON we've just parsed. | |||
preserved_keys.each do |key| | |||
record_json[key] ||= record[key] if record.key?(key) | |||
record_json[key] ||= record[key] if | |||
record.key?(key) && !record_json.key?(key) |
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.
||=
should take care of this, unless you are trying to preserve nil
values...
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.
The problem with ||=
is that it changed a boolean from false
to true
... which is what we want to avoid. We only want to override it if it's not present in the JSON.
$ irb
2.4.3 :001 > var = false
=> false
2.4.3 :002 > var ||= true
=> true
test/plugin/base_test.rb
Outdated
assert_equal expected_value, entry[log_entry_field], | ||
"Index #{index} failed. #{expected_value} is expected" \ | ||
" for #{log_entry_field} field." | ||
if default_value.nil? |
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.
I think you should be able to just use assert_equal_with_default
here, even when the default is nil
, since proto values will never produce nil
.
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.
Changed.
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.
PTAL
@@ -643,7 +647,8 @@ def write(chunk) | |||
# Propagate these if necessary. Note that we don't want to | |||
# override these keys in the JSON we've just parsed. | |||
preserved_keys.each do |key| | |||
record_json[key] ||= record[key] if record.key?(key) | |||
record_json[key] ||= record[key] if | |||
record.key?(key) && !record_json.key?(key) |
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.
The problem with ||=
is that it changed a boolean from false
to true
... which is what we want to avoid. We only want to override it if it's not present in the JSON.
$ irb
2.4.3 :001 > var = false
=> false
2.4.3 :002 > var ||= true
=> true
test/plugin/base_test.rb
Outdated
assert_equal expected_value, entry[log_entry_field], | ||
"Index #{index} failed. #{expected_value} is expected" \ | ||
" for #{log_entry_field} field." | ||
if default_value.nil? |
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.
Changed.
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.
LGTM
…tion demo. This commit sets the new sampling decision field that is recognized by the Stackdriver Logging agent, "logging.googleapis.com/traceSampled", in the Log4j log correlation demo. The sampling decision field was added in GoogleCloudPlatform/fluent-plugin-google-cloud#297.
…log entries This commit sets the new sampling decision field that is recognized by the Stackdriver Logging agent, "logging.googleapis.com/traceSampled". The sampling decision field was added in GoogleCloudPlatform/fluent-plugin-google-cloud#297, and it won't be available until the new version of fluent-plugin-google-cloud is used in GKE.
…log entries (#168) This commit sets the new sampling decision field that is recognized by the Stackdriver Logging agent, "logging.googleapis.com/traceSampled". The sampling decision field was added in GoogleCloudPlatform/fluent-plugin-google-cloud#297, and it won't be available until the new version of fluent-plugin-google-cloud is used in GKE.
…tion demo. (#179) This commit sets the new sampling decision field that is recognized by the Stackdriver Logging agent, "logging.googleapis.com/traceSampled", in the Log4j log correlation demo. The sampling decision field was added in GoogleCloudPlatform/fluent-plugin-google-cloud#297.
…log entries (#168) This commit sets the new sampling decision field that is recognized by the Stackdriver Logging agent, "logging.googleapis.com/traceSampled". The sampling decision field was added in GoogleCloudPlatform/fluent-plugin-google-cloud#297, and it won't be available until the new version of fluent-plugin-google-cloud is used in GKE.
…log entries (#168) This commit sets the new sampling decision field that is recognized by the Stackdriver Logging agent, "logging.googleapis.com/traceSampled". The sampling decision field was added in GoogleCloudPlatform/fluent-plugin-google-cloud#297, and it won't be available until the new version of fluent-plugin-google-cloud is used in GKE.
No description provided.