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

feat: Skip Trilogyping span with option ping_enabled #899

Closed

Conversation

TonyCTHsu
Copy link

@TonyCTHsu TonyCTHsu commented Mar 5, 2024

closes #842

Trilogy: Add an configuration option ping_enabled to skip ping instrumentation

@@ -28,6 +28,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
option :span_name, default: :statement_type, validate: %I[statement_type db_name db_operation_and_name]
option :obfuscation_limit, default: 2000, validate: :integer
option :propagator, default: nil, validate: :string
option :ping_enabled, default: true, validate: :boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good to me. I just have two questions based on the original issue

IMO we should default to not tracing ping if it doesn't have a parent and allow a config option to opt in.

  1. Should this option be false as default?
  2. I'm not familiar with mysql2 ping operation, so I'm not sure in what case the ping operation will have a parent span. Potentially, a scenario involving a rack span as the parent, with other spans acting as child spans if it's a Rails or Sinatra application invoking ActiveRecord. Do you have any recommendations for addressing cases where a parent span exists and enabling the ping accordingly?

Copy link
Author

@TonyCTHsu TonyCTHsu Mar 6, 2024

Choose a reason for hiding this comment

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

Addressed with: 8049f2c

  1. Should this option be false as default?

I set it as true originally because that would result in no data lost and no configuration changes for existing user. I don't mind the option being false. However, I would like to learn whether such change should be considered as a breaking change (major in SemVer2) or behavior change (minor in SemVer2)?

so I'm not sure in what case the ping operation will have a parent span.

I can imagine someone is building a /healthcheck endpoint that implements pinging databases. However, I would feel strange to see the ping span generated if I configured ping_enabled as false (Which also means that where is no way to silence it entirely.)

I am not familiar with OTel's public interfaces but I tried to simulate such scenario in test with

OpenTelemetry.tracer_provider.tracer.in_span('parent') do
  client.ping
end

Let me know if I am missing something or wrong about this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I set it as true originally because that would result in no data lost and no configuration changes for existing user.

Make sense. Maybe ask it in next SIG meeting (also breaking vs behavior change).

I would feel strange to see the ping span generated if I configured ping_enabled as false (Which also means that where is no way to silence it entirely.)

Agree. I think even document it still confuse people. I suggest either removing the condition of if ping doesn't have parent span ... (i.e. disable all if set false) or make the option name more specific.

cc: @plantfansam

@@ -26,6 +26,8 @@ def initialize(options = {})
end

def ping(...)
return super unless OpenTelemetry::Trace.current_span.context.valid? || config[:ping_enabled]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this something that we can mixin during initialization instead of checking every time this method is invoked?

@@ -28,6 +28,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
option :span_name, default: :statement_type, validate: %I[statement_type db_name db_operation_and_name]
option :obfuscation_limit, default: 2000, validate: :integer
option :propagator, default: nil, validate: :string
option :ping_enabled, default: false, validate: :boolean
Copy link
Contributor

Choose a reason for hiding this comment

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

Like we talked about during the SIG, since this changes the default behavior, keeping default: false will be a breaking change.

If you'd like to keep that approach, please update the PR title to begin with feat!:.

Copy link
Contributor

github-actions bot commented May 2, 2024

👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep label to hold stale off permanently, or do nothing. If you do nothing this pull request will be closed eventually by the stale bot

@github-actions github-actions bot added the stale Marks an issue/PR stale label May 2, 2024
@kaylareopelle
Copy link
Contributor

👋 Hi @TonyCTHsu! It looks like there are two comments in the PR blocking further review:

Let us know if you have any follow-up questions!

@arielvalentin
Copy link
Collaborator

I think we had a similar discussion where we decided to reject a similar PR for PostgreSQL

@robertlaurin suggested using custom samplers instead:

#955

@github-actions github-actions bot removed the stale Marks an issue/PR stale label May 14, 2024
Copy link
Contributor

👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep label to hold stale off permanently, or do nothing. If you do nothing this pull request will be closed eventually by the stale bot

@github-actions github-actions bot added the stale Marks an issue/PR stale label Jun 13, 2024
@github-actions github-actions bot closed this Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Marks an issue/PR stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trilogy instrumentation should make root ping spans opt-in
4 participants