-
Notifications
You must be signed in to change notification settings - Fork 69
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
Closes #1555: [Feature] - fix StackTraceSampler / AutoTracing #1558
Closes #1555: [Feature] - fix StackTraceSampler / AutoTracing #1558
Conversation
f6842a8
to
1ca1464
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 81 of 81 files at r1, all commit messages.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @heiko-holz)
a discussion (no related file):
There were a few inconsistencies regarding code formatting, maybe we should discuss this in a Meeting.
inspectit-ocelot-agent/src/system-test/java/rocks/inspectit/ocelot/instrumentation/special/logging/Log4J2TraceIdAutoInjectorTest.java
line 58 at r1 (raw file):
Span span = tracer.spanBuilder("test").startSpan(); try (Scope scope = span.makeCurrent()) { traceId = Span.current().getSpanContext().getTraceId();
in LogCorelationTest.java
this part was extracted into their own function so to keep everything the same we should do this here too or move the previous implementation into a higher order to be able to use this function everywhere its needed and don't have redundancy.
inspectit-ocelot-agent/src/system-test/java/rocks/inspectit/ocelot/instrumentation/special/logging/Log4JTraceIdAutoInjectorTest.java
line 36 at r1 (raw file):
try (Scope scope = tracer.spanBuilder("test").startSpan().makeCurrent()) { traceId = Span.current().getSpanContext().getTraceId();
Same here for the extraction into their own function.
inspectit-ocelot-bootstrap/src/main/java/rocks/inspectit/ocelot/bootstrap/opentelemetry/IOpenTelemetryController.java
line 61 at r1 (raw file):
/** * Registers a new {@link rocks.inspectit.ocelot.core.service.DynamicallyActivatableService trace exporter service} that is used to export {@link io.opentelemetry.sdk.trace.data.SpanData} for sampled {@link io.opentelemetry.api.trace.Span}s * This method should ONLY be used in tests of the {@code agent} package.
Is it a good idea to implement a test only function here?
inspectit-ocelot-core/src/main/java/io/opentelemetry/sdk/trace/OcelotAnchoredClockUtils.java
line 87 at r1 (raw file):
throw new RuntimeException(e); }
This space is not needed.
inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/instrumentation/config/MethodHookConfigurationResolver.java
line 55 at r1 (raw file):
boolean traceEntryHook = Stream.of(matchedRules.stream() .map(InstrumentationRule::getPreEntryActions) .flatMap(Collection::stream), matchedRules.stream()
I think it would be better to format this one with the commas instead of the dots to make it more readable for each value. e.g.
Code snippet:
boolean traceEntryHook = Stream.of(
matchedRules.stream().map(InstrumentationRule::getPreEntryActions).flatMap(Collection::stream),
matchedRules.stream().map(InstrumentationRule::getEntryActions).flatMap(Collection::stream),
matchedRules.stream().map(InstrumentationRule::getPostEntryActions).flatMap(Collection::stream)).flatMap(s -> s).anyMatch(ActionCallConfig::isActionTracing);
...
inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/instrumentation/context/InspectitContextImpl.java
line 3 at r1 (raw file):
package rocks.inspectit.ocelot.core.instrumentation.context; import io.opencensus.tags.*;
Is this something that can't be done with open telemetry?
inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/instrumentation/hook/MethodHookGenerator.java
line 176 at r1 (raw file):
String sampleProbability = tracing.getSampleProbability(); if (!StringUtils.isBlank(sampleProbability)) {
this empty line can be removed.
inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/opentelemetry/trace/samplers/HybridParentTraceIdRatioBasedSampler.java
line 52 at r1 (raw file):
// if any parent link has been sampled, keep the sampling decision. if (isAnyParentLinkSampled) {
Could we not put this if into the previous if statement with an OR since they are both returning the same?
inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/utils/OpenCensusShimUtils.java
line 90 at r1 (raw file):
} // TODO: über Reflection auf die Copy-Helper-Methode zuzugreifen, anstatt diese zu kopieren
Is this TODO supposed to be finished in this PR? If not it might be a better idea to create a separate Ticket for it before it gets forgotten.
inspectit-ocelot-core/src/test/java/rocks/inspectit/ocelot/core/instrumentation/hook/actions/span/WriteSpanAttributesTest.java
line 30 at r1 (raw file):
IObfuscatory obfuscatory; @Spy
Do we still need to use @Spy
here? If yes, a comment explaining why would be helpful 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @heiko-holz)
a discussion (no related file):
Previously, Dimi-Ma (Dimitiros Mantas) wrote…
There were a few inconsistencies regarding code formatting, maybe we should discuss this in a Meeting.
Additionally, there is a failing Test in the class JaegerThriftExporterServiceIntTest
which i have tested multiple times with the name verifyTraceSent
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @heiko-holz)
a discussion (no related file):
Previously, Dimi-Ma (Dimitiros Mantas) wrote…
Additionally, there is a failing Test in the class
JaegerThriftExporterServiceIntTest
which i have tested multiple times with the nameverifyTraceSent
.
Follow up information: the failing Test only fails, if all other tests run too but passes if run alone, this indicates that something isn't cleaned up properly from previous tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 10 unresolved discussions (waiting on @heiko-holz)
inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/instrumentation/context/InspectitContextImpl.java
line 3 at r1 (raw file):
Previously, Dimi-Ma (Dimitiros Mantas) wrote…
Is this something that can't be done with open telemetry?
Since the changes only were supposed to affect traces and not metrics i will retract this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 10 unresolved discussions (waiting on @Dimi-Ma)
a discussion (no related file):
Previously, Dimi-Ma (Dimitiros Mantas) wrote…
Follow up information: the failing Test only fails, if all other tests run too but passes if run alone, this indicates that something isn't cleaned up properly from previous tests.
Let's have a chat and look into this issue
inspectit-ocelot-agent/src/system-test/java/rocks/inspectit/ocelot/instrumentation/special/logging/Log4J2TraceIdAutoInjectorTest.java
line 58 at r1 (raw file):
Previously, Dimi-Ma (Dimitiros Mantas) wrote…
in
LogCorelationTest.java
this part was extracted into their own function so to keep everything the same we should do this here too or move the previous implementation into a higher order to be able to use this function everywhere its needed and don't have redundancy.
I agree.
I have refactored Log4J2TraceIdAutoInjectorTest.java
and moved the logic to start the span, extract the trace id, and log the message into the method startSpanAndExtractTraceIdAndLogMessage
inspectit-ocelot-agent/src/system-test/java/rocks/inspectit/ocelot/instrumentation/special/logging/Log4JTraceIdAutoInjectorTest.java
line 36 at r1 (raw file):
Previously, Dimi-Ma (Dimitiros Mantas) wrote…
Same here for the extraction into their own function.
I would leave this class as it. In my opinion, we would create more boilerplate code when trying to extract this into an extra method as this is the only call to Span.current().getSpanContext().getTraceId();
in this class
inspectit-ocelot-bootstrap/src/main/java/rocks/inspectit/ocelot/bootstrap/opentelemetry/IOpenTelemetryController.java
line 61 at r1 (raw file):
Previously, Dimi-Ma (Dimitiros Mantas) wrote…
Is it a good idea to implement a test only function here?
I added this for the tests in the agent
package, as we do not have access to the core
package there.
Otherwise, I could have directly worked with the OpenTelemetryControllerImpl.java
class.
I would not know how I could otherwise register a trace exporter in the agent test package, without re-building OpenTelemetry from scratch and discarding the configurations.
Let's discuss this in a meeting.
inspectit-ocelot-core/src/main/java/io/opentelemetry/sdk/trace/OcelotAnchoredClockUtils.java
line 87 at r1 (raw file):
Previously, Dimi-Ma (Dimitiros Mantas) wrote…
This space is not needed.
Thanks for catching this.
I have deleted the empty line.
inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/instrumentation/config/MethodHookConfigurationResolver.java
line 55 at r1 (raw file):
Previously, Dimi-Ma (Dimitiros Mantas) wrote…
I think it would be better to format this one with the commas instead of the dots to make it more readable for each value. e.g.
I cannot really follow.
What do you exactly mean, can you make an example?
inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/instrumentation/context/InspectitContextImpl.java
line 3 at r1 (raw file):
Previously, Dimi-Ma (Dimitiros Mantas) wrote…
Is this something that can't be done with open telemetry?
It can be replaced at a later point with Baggage
and Attributes
of OpenTelemetry,
However, this would add more complexity (and take at least 2 more days to this ticket).
inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/instrumentation/hook/MethodHookGenerator.java
line 176 at r1 (raw file):
Previously, Dimi-Ma (Dimitiros Mantas) wrote…
this empty line can be removed.
Thanks, I have deleted the empty line.
inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/opentelemetry/trace/samplers/HybridParentTraceIdRatioBasedSampler.java
line 52 at r1 (raw file):
Previously, Dimi-Ma (Dimitiros Mantas) wrote…
Could we not put this if into the previous if statement with an OR since they are both returning the same?
Technically we could. However, I have followed OpenCensus' implementation of https://github.com/census-instrumentation/opencensus-java/blob/master/api/src/main/java/io/opencensus/trace/samplers/ProbabilitySampler.java.
But we can change it to this if you think this is more readable:
// If the parent or any parent link has been sampled keep, the sampling decision.
if ((parentSpanContext.isValid() && parentSpanContext.isSampled()) || isAnyParentLinkSampled(parentLinks)) {
return SamplingResult.recordAndSample();
}
inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/utils/OpenCensusShimUtils.java
line 90 at r1 (raw file):
Previously, Dimi-Ma (Dimitiros Mantas) wrote…
Is this TODO supposed to be finished in this PR? If not it might be a better idea to create a separate Ticket for it before it gets forgotten.
Good catch!
Actually, the methods mapKind
where not used. Thus, I have removed the TODO
statement and the unused methods.
inspectit-ocelot-core/src/test/java/rocks/inspectit/ocelot/core/instrumentation/hook/actions/span/WriteSpanAttributesTest.java
line 30 at r1 (raw file):
Previously, Dimi-Ma (Dimitiros Mantas) wrote…
Do we still need to use
@Spy
here? If yes, a comment explaining why would be helpful 🙂
Yes, we need the @Spy
to have a dummy span for the evaluation in verifyAttributesWritten
. I have added a comment
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #1558 +/- ##
============================================
+ Coverage 77.54% 78.24% +0.70%
- Complexity 2320 2404 +84
============================================
Files 240 246 +6
Lines 7730 7909 +179
Branches 924 936 +12
============================================
+ Hits 5994 6188 +194
+ Misses 1350 1307 -43
- Partials 386 414 +28
|
cddfe7f
to
eb2637d
Compare
eb2637d
to
2d4b6cc
Compare
Previously, heiko-holz (Heiko Holz) wrote…
We have agreed to change it to the shorter version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 72 of 81 files reviewed, 10 unresolved discussions (waiting on @Dimi-Ma)
inspectit-ocelot-core/src/main/java/rocks/inspectit/ocelot/core/instrumentation/config/MethodHookConfigurationResolver.java
line 55 at r1 (raw file):
Previously, heiko-holz (Heiko Holz) wrote…
I cannot really follow.
What do you exactly mean, can you make an example?
After the discussion, we agreed that we need to tweak the code styling of inspectIT Ocelot, but not in this ticket.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 7 of 7 files at r2, 1 of 1 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @heiko-holz)
inspectit-ocelot-agent/src/system-test/java/rocks/inspectit/ocelot/instrumentation/special/logging/Log4JTraceIdAutoInjectorTest.java
line 36 at r1 (raw file):
Previously, heiko-holz (Heiko Holz) wrote…
I would leave this class as it. In my opinion, we would create more boilerplate code when trying to extract this into an extra method as this is the only call to
Span.current().getSpanContext().getTraceId();
in this class
Yes, you are right. I probably overlooked the fact that it was the only call in this class.
Closes #1555
This change is