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

tracing: skip reconfiguration if tracer already configured #633

Merged
merged 4 commits into from
Nov 8, 2023

Conversation

redloaf
Copy link
Contributor

@redloaf redloaf commented Nov 8, 2023

💸 TL;DR

In baseplate.go v2 we configure a global opentracing tracer. Currently, calling baseplate.New will override the new tracer. This change prevents the override using a flag in internalv2compat.

📜 Details

If internalv2compat.SetV2TracingEnabled(true) is called before InitGlobalTracer, the opentracing global tracer will not be configured, and a message will be logged.

🧪 Testing Steps / Validation

✅ Checks

  • CI tests (if present) are passing
  • Adheres to code style for repo
  • Contributor License Agreement (CLA) completed if not a Reddit employee

@redloaf redloaf requested a review from a team as a code owner November 8, 2023 18:32
@redloaf redloaf requested review from fishy, kylelemons and pacejackson and removed request for a team November 8, 2023 18:32
internalv2compat/compat.go Outdated Show resolved Hide resolved
Comment on lines 69 to 70
v2TracingEnabledMutex sync.RWMutex
v2TracingEnabled bool
Copy link
Member

Choose a reason for hiding this comment

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

use atomic.Bool instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered it but picked a mutex because this should only be referenced during setup/init, and I feel like the benefit of a memory barrier outweighs the performance benefits of atomics.

tracing/tracer.go Outdated Show resolved Hide resolved
tracing/tracer.go Outdated Show resolved Hide resolved
@redloaf redloaf requested a review from fishy November 8, 2023 18:57
@redloaf redloaf merged commit ccc5cd0 into master Nov 8, 2023
2 checks passed
@redloaf redloaf deleted the skip-tracer-reconfigure branch November 8, 2023 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants