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

Enable extraction of http/unix adapter config from transport_options proc #1932

Merged

Conversation

ivoanjo
Copy link
Member

@ivoanjo ivoanjo commented Mar 7, 2022

As documented in the getting started guide (https://docs.datadoghq.com/tracing/setup_overview/setup/ruby/#configuring-the-transport-layer), one way of configuring ddtrace is to provide a proc as the tracing.transport_options configuration setting.

Up until now, the AgentSettingsResolver class effectively "gave up" when it saw one of these procs, and just included it the proc in its AgentSettings output.

This meant that:

a) If there were any invalid or conflicting settings, we could not detect or warn about them

b) We were in the dark on what settings actually were going to be used, since the proc could do anything it wanted. The AgentSettings object could be completely used or completely ignored.

c) It was hard to provide alternative transport implementations, because they may not be able to implement the full adapter configuration API expected by the user code. For instance, this is needed to implement unix domain socket support in the new profiler libddprof-based transport.

To fix this, I've implemented a very minimalistic approach: Inside the AgentSettingsResolver we try to execute the transport_options proc and see if all it does is configure an http or unix adapter. If so, success, we get its configuration and
no longer need to deal with the proc.

If the proc tries to do anything fancier (extra transport configuration or using a test or custom adapter), we just give up and retain the previous behavior.

Worst case, the previous behavior is retained exactly. Best case, we are able to parse the configuration correctly, and are able to do the usual validations and include it in the AgentSettings object.

Finally, yes, this does add more complexity to the AgentSettingsResolver but I claim that this complexity was already there, and now I've exposed it where it should be.

(P.s.: This relies on the refactoring in #1931)

@ivoanjo ivoanjo requested a review from a team March 7, 2022 15:58
ivoanjo added a commit that referenced this pull request Mar 7, 2022
…ise error

In #1932 we did the
groundwork required to support parsing the unix domain socket
configuration from a c.tracing.transport_options configuration.

Thus, we can now support unix domain sockets configured by the user
without any other change (assuming that PR is merged before this
commit is).

The `transport_configuration_proc` can still contain weird transport
configurations, but if that's the case, we just ignore them and
print a warning. This is because we don't support every setting
a user may provide in that proc.

Worst case, for customers with a really custom config, is that
the profiler won't be able to report data, and the customer will need
to reach out to support for help updating it. (But we won't raise
an exception or stop the profiler from starting).
@ivoanjo ivoanjo requested a review from lloeki March 7, 2022 16:44
@delner delner added core Involves Datadog core libraries dev/refactor Involves refactoring existing components labels Mar 18, 2022
@delner delner added this to the 1.0.0.beta2 milestone Mar 18, 2022
Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

We reviewed these PRs together, and the consensus we reached was that we should try to remove the proc for transport_options if we can implement a suitable replacement within the configuration settings code. This is the long term goal.

In the short term, to improve configuration usage, this is OK to do. Ideally this complexity will be removed long term when we have better transport configuration settings code in place.

@delner delner added this to Reviewer approved in 1.0 Mar 18, 2022
Base automatically changed from ivoanjo/agent-settings-resolver-cleanups to master March 21, 2022 09:35
…proc

As documented in the getting started guide
(<https://docs.datadoghq.com/tracing/setup_overview/setup/ruby/#configuring-the-transport-layer>),
one way of configuring ddtrace is to provide a proc as the
`tracing.transport_options` configuration setting.

Up until now, the `AgentSettingsResolver` class effectively "gave up"
when it saw one of these procs, and just included it the proc in its
`AgentSettings` output.

This meant that:

a) If there were any invalid or conflicting settings, we
could not detect or warn about them
b) We were in the dark on what settings actually were going to be used,
since the proc could do anything it wanted. The `AgentSettings` object
could be completely used or completely ignored.
c) It was hard to provide alternative transport implementations, because
they may not be able to implement the full adapter configuration API
expected by the user code. For instance, this is needed to
implement unix domain socket support in the new profiler
libddprof-based transport.

To fix this, I've implemented a very minimalistic approach:
Inside the `AgentSettingsResolver` we try to execute the
`transport_options` proc and see if all it does is configure an
http or unix adapter. If so, success, we get its configuration and
no longer need to deal with the proc.

If the proc tries to do anything fancier (extra transport
configuration or using a test or custom adapter), we just give up and
retain the previous behavior.

Worst case, the previous behavior is retained exactly. Best case,
we are able to parse the configuration correctly, and are able to
do the usual validations and include it in the `AgentSettings`
object.

Finally, yes, this does add more complexity to the
`AgentSettingsResolver` but I claim that this complexity was already
there, and now I've exposed it where it should be.
@ivoanjo ivoanjo force-pushed the ivoanjo/extend-agent-settings-parsing-to-transport-options branch from 2e0e8aa to a46c320 Compare March 21, 2022 09:42
@ivoanjo
Copy link
Member Author

ivoanjo commented Mar 21, 2022

Pushed a rebase to solve a trivial conflict with #1930.

@ivoanjo
Copy link
Member Author

ivoanjo commented Mar 21, 2022

Thanks for the review, merging away. CI is broken for ci/circleci: build_and_test_integration-2.3 but I'll investigate separately (it's completely unrelated -- CI is broken while installing the google-protobuf gem)

@ivoanjo ivoanjo merged commit 9d7f2ba into master Mar 21, 2022
@ivoanjo ivoanjo deleted the ivoanjo/extend-agent-settings-parsing-to-transport-options branch March 21, 2022 09:59
ivoanjo added a commit that referenced this pull request May 16, 2022
…ise error

In #1932 we did the
groundwork required to support parsing the unix domain socket
configuration from a c.tracing.transport_options configuration.

Thus, we can now support unix domain sockets configured by the user
without any other change (assuming that PR is merged before this
commit is).

The `transport_configuration_proc` can still contain weird transport
configurations, but if that's the case, we just ignore them and
print a warning. This is because we don't support every setting
a user may provide in that proc.

Worst case, for customers with a really custom config, is that
the profiler won't be able to report data, and the customer will need
to reach out to support for help updating it. (But we won't raise
an exception or stop the profiler from starting).
ivoanjo added a commit that referenced this pull request May 17, 2022
…ise error

In #1932 we did the
groundwork required to support parsing the unix domain socket
configuration from a c.tracing.transport_options configuration.

Thus, we can now support unix domain sockets configured by the user
without any other change (assuming that PR is merged before this
commit is).

The `transport_configuration_proc` can still contain weird transport
configurations, but if that's the case, we just ignore them and
print a warning. This is because we don't support every setting
a user may provide in that proc.

Worst case, for customers with a really custom config, is that
the profiler won't be able to report data, and the customer will need
to reach out to support for help updating it. (But we won't raise
an exception or stop the profiler from starting).
ivoanjo added a commit that referenced this pull request May 19, 2022
…ise error

In #1932 we did the
groundwork required to support parsing the unix domain socket
configuration from a c.tracing.transport_options configuration.

Thus, we can now support unix domain sockets configured by the user
without any other change (assuming that PR is merged before this
commit is).

The `transport_configuration_proc` can still contain weird transport
configurations, but if that's the case, we just ignore them and
print a warning. This is because we don't support every setting
a user may provide in that proc.

Worst case, for customers with a really custom config, is that
the profiler won't be able to report data, and the customer will need
to reach out to support for help updating it. (But we won't raise
an exception or stop the profiler from starting).
ivoanjo added a commit that referenced this pull request May 25, 2022
…ise error

In #1932 we did the
groundwork required to support parsing the unix domain socket
configuration from a c.tracing.transport_options configuration.

Thus, we can now support unix domain sockets configured by the user
without any other change (assuming that PR is merged before this
commit is).

The `transport_configuration_proc` can still contain weird transport
configurations, but if that's the case, we just ignore them and
print a warning. This is because we don't support every setting
a user may provide in that proc.

Worst case, for customers with a really custom config, is that
the profiler won't be able to report data, and the customer will need
to reach out to support for help updating it. (But we won't raise
an exception or stop the profiler from starting).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Involves Datadog core libraries dev/refactor Involves refactoring existing components
Projects
1.0
Reviewer approved
Development

Successfully merging this pull request may close these issues.

None yet

3 participants