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:Convert custom setting value to string for startup log #1109

Merged
merged 2 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Git diff: https://github.com/DataDog/dd-trace-rb/compare/v0.37.0...v0.38.0
- Kafka integration (#1070) (@tjwp)
- Span#set_tags (#1081) (@DocX)
- retry_count tag for Sidekiq jobs (#1089) (@elyalvarado)
- Startup environment log (#1104)
- Startup environment log (#1104, #1109)
- DD_SITE and DD_API_KEY configuration (#1107)

### Changed
Expand Down
4 changes: 3 additions & 1 deletion lib/ddtrace/diagnostics/environment_logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ def instrumented_integrations_settings
integration.configuration.to_h.flat_map do |setting, value|
next [] if setting == :tracer # Skip internal Ruby objects

[[:"integration_#{name}_#{setting}", value]]
# Convert value to a string to avoid custom #to_json
# handlers possibly causing errors.
[[:"integration_#{name}_#{setting}", value.to_s]]
end
end]
end
Expand Down
16 changes: 12 additions & 4 deletions spec/ddtrace/diagnostics/environment_logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,19 @@
context 'with integration-specific settings' do
let(:options) { { service_name: 'my-http' } }

it { is_expected.to include integration_http_analytics_enabled: false }
it { is_expected.to include integration_http_analytics_sample_rate: 1.0 }
it { is_expected.to include integration_http_analytics_enabled: 'false' }
it { is_expected.to include integration_http_analytics_sample_rate: '1.0' }
it { is_expected.to include integration_http_service_name: 'my-http' }
it { is_expected.to include integration_http_distributed_tracing: true }
it { is_expected.to include integration_http_split_by_domain: false }
it { is_expected.to include integration_http_distributed_tracing: 'true' }
it { is_expected.to include integration_http_split_by_domain: 'false' }
end

context 'with a complex setting value' do
let(:options) { { service_name: Class.new } }

it 'converts to a string' do
is_expected.to include integration_http_service_name: start_with('#<Class:')
end
end
end

Expand Down