Skip to content

Conversation

marcingrzejszczak
Copy link
Contributor

without this change in order to e.g. create spans we always need to put an observation in scope so that spans are put in thread local and a child span is being set. That doesn't make a lot of sense when we exactly know what the parent observation is.
with this change we're allowing to set a parent observation direcly on an existing observation. That way we're able to maintain a parent child relationship of observations and of e.g. spans

without this change in order to e.g. create spans we always need to put an observation in scope so that spans are put in thread local and a child span is being set. That doesn't make a lot of sense when we exactly know what the parent observation is.
with this change we're allowing to set a parent observation direcly on an existing observation. That way we're able to maintain a parent child relationship of observations and of e.g. spans
@marcingrzejszczak marcingrzejszczak added the enhancement A general enhancement label Jul 14, 2022
@marcingrzejszczak marcingrzejszczak added this to the 1.10.0-M4 milestone Jul 14, 2022
marcingrzejszczak added a commit to micrometer-metrics/tracing that referenced this pull request Jul 14, 2022
without this change in order to e.g. create spans we always need to put an observation in scope so that spans are put in thread local and a child span is being set. That doesn't make a lot of sense when we exactly know what the parent observation is.
with this change we're allowing to set a parent observation direcly on an existing observation. That way we're able to maintain a parent child relationship of observations and of e.g. spans

related to micrometer-metrics/micrometer#3291

@Override
@Nullable
public <T> T get(Object key) {
Copy link
Contributor

Choose a reason for hiding this comment

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

TypeParameterUnusedInFormals: Declaring a type parameter that is only used in the return type is a misuse of generics: operations on the type parameter are unchecked, it hides unsafe casts at invocations of the method, and it interacts badly with method overload resolution.

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]


@Override
@NonNull
public <T> T getRequired(Object key) {
Copy link
Contributor

Choose a reason for hiding this comment

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

TypeParameterUnusedInFormals: Declaring a type parameter that is only used in the return type is a misuse of generics: operations on the type parameter are unchecked, it hides unsafe casts at invocations of the method, and it interacts badly with method overload resolution.

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

* @return entry ot exception if not present
*/
@NonNull
<T> T getRequired(Object key);
Copy link
Contributor

Choose a reason for hiding this comment

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

TypeParameterUnusedInFormals: Declaring a type parameter that is only used in the return type is a misuse of generics: operations on the type parameter are unchecked, it hides unsafe casts at invocations of the method, and it interacts badly with method overload resolution.

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

* @return entry or {@code null} if not present
*/
@Nullable
<T> T get(Object key);
Copy link
Contributor

Choose a reason for hiding this comment

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

TypeParameterUnusedInFormals: Declaring a type parameter that is only used in the return type is a misuse of generics: operations on the type parameter are unchecked, it hides unsafe casts at invocations of the method, and it interacts badly with method overload resolution.

Reply with "@sonatype-lift help" for info about LiftBot commands.
Reply with "@sonatype-lift ignore" to tell LiftBot to leave out the above finding from this PR.
Reply with "@sonatype-lift ignoreall" to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.

When talking to LiftBot, you need to refresh the page to see its response. Click here to get to know more about LiftBot commands.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@@ -228,6 +228,13 @@ static Observation createNotStarted(ObservationConvention<?> observationConventi
*/
Observation contextualName(String contextualName);

/**
* Sets the parent {@link Observation}.
Copy link
Member

Choose a reason for hiding this comment

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

It would be good for us to explain here why a user would want to do this (avoid needing to scope) and that it isn't needed if you are creating a scope.


}

static class ImmutableContext extends Context {
Copy link
Member

Choose a reason for hiding this comment

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

This isn't used anywhere.

@marcingrzejszczak marcingrzejszczak merged commit fa56768 into main Jul 15, 2022
marcingrzejszczak added a commit to micrometer-metrics/tracing that referenced this pull request Jul 15, 2022
)

* Added option to set a parent Observation on an existing Observation

without this change in order to e.g. create spans we always need to put an observation in scope so that spans are put in thread local and a child span is being set. That doesn't make a lot of sense when we exactly know what the parent observation is.
with this change we're allowing to set a parent observation direcly on an existing observation. That way we're able to maintain a parent child relationship of observations and of e.g. spans

related to micrometer-metrics/micrometer#3291

* Fixed the http observation handlers
@marcingrzejszczak marcingrzejszczak deleted the parentObservation branch January 27, 2023 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants