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

Removes the need to set OR on OTLA #3986

Merged
merged 2 commits into from
Jul 20, 2023
Merged

Conversation

marcingrzejszczak
Copy link
Contributor

without this change we are required to set OR on OTLA so that when NullObservation gets created we will call the proper handlers to e.g. clear tracing values.

with this change we no longer require to set OR on OTLA because we will reuse the OR that was set on the Observation before clearing happens in OTLA via setValue(). When there was no Observation before calling setValue() we just skip creating any scopes. That way we are always reusing the ObservationRegistry that is used between Observations.

without this change we are required to set OR on OTLA so that when NullObservation gets created we will call the proper handlers to e.g. clear tracing values.

with this change we no longer require to set OR on OTLA because we will reuse the OR that was set on the Observation before clearing happens in OTLA via `setValue()`. When there was no Observation before calling `setValue()` we just skip creating any scopes. That way we are always reusing the ObservationRegistry that is used between Observations.
@marcingrzejszczak marcingrzejszczak added the enhancement A general enhancement label Jul 19, 2023
@marcingrzejszczak marcingrzejszczak added this to the 1.10.10 milestone Jul 19, 2023
@sonatype-lift
Copy link
Contributor

sonatype-lift bot commented Jul 19, 2023

Sonatype Lift is retiring

Sonatype Lift will be retiring on Sep 12, 2023, with its analysis stopping on Aug 12, 2023. We understand that this news may come as a disappointment, and Sonatype is committed to helping you transition off it seamlessly. If you’d like to retain your data, please export your issues from the web console.
We are extremely grateful and thank you for your support over the years.

📖 Read about the impacts and timeline

* @return corresponding observation registry
* @since 1.10.10
*/
default ObservationRegistry getObservationRegistry() {
Copy link

Choose a reason for hiding this comment

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

Are we able to operate on the ObservationRegistry.ObservationConfig level instead? All the calls to the registry to obtain the current Observation/Scope can go to the static, global instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They cannot because we need an ObservationRegistry to create an Observation, not an ObservationConfig

child.stop();
parent.stop();

then(child.getEnclosingScope()).isNull();
then(parent.getEnclosingScope()).isNull();
}

@Test
void uses2DifferentObservationRegistries() {
AtomicReference<String> reference = new AtomicReference<>("");
Copy link

@chemicL chemicL Jul 19, 2023

Choose a reason for hiding this comment

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

rename to lastCalledHandler perhaps?

Comment on lines 60 to 61
ContextRegistry.getInstance().removeContextAccessor(mapContextAccessor);
ContextRegistry.getInstance().registerContextAccessor(mapContextAccessor);
Copy link

Choose a reason for hiding this comment

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

what's happening here? :)

Copy link

@chemicL chemicL left a comment

Choose a reason for hiding this comment

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

Please consider not coupling the ObservationView with the registry even further in the public API - perhaps we can evolve the usage in the future to have ObservationRegistry be simply global and static for ThreadLocal access, while the ObservationConfig is something that can vary from Observation to Observation.

@marcingrzejszczak
Copy link
Contributor Author

Please consider not coupling the ObservationView with the registry even further in the public API - perhaps we can evolve the usage in the future to have ObservationRegistry be simply global and static for ThreadLocal access, while the ObservationConfig is something that can vary from Observation to Observation.

We can create a separate issue for that. I don't see real value of doing such a change at this point

@chemicL
Copy link

chemicL commented Jul 19, 2023

We can create a separate issue for that. I don't see real value of doing such a change at this point

Right. The fact NullObservation is public and accepts the registry makes it unfeasible now. Perhaps at a major version the registry can be decoupled from the config. For now the registry, even though can have multiple instances, has static ThreadLocal state in the form of the current Observation, while the thing than can vary is the configuration. I suppose we need to live with that for the time being :)

@marcingrzejszczak marcingrzejszczak merged commit 24b67c1 into 1.10.x Jul 20, 2023
2 checks passed
@marcingrzejszczak marcingrzejszczak deleted the noNeedForStaticsWithOtla branch July 20, 2023 10:17
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants