-
Notifications
You must be signed in to change notification settings - Fork 61
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
RUM-3405 Provide core tracer logger implementation #1953
RUM-3405 Provide core tracer logger implementation #1953
Conversation
2a7a9a4
to
e52fa08
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## feature/otel-support #1953 +/- ##
========================================================
+ Coverage 60.00% 60.06% +0.06%
========================================================
Files 803 805 +2
Lines 30050 30119 +69
Branches 4928 4929 +1
========================================================
+ Hits 18030 18089 +59
- Misses 10810 10822 +12
+ Partials 1210 1208 -2
|
@JvmField | ||
val UNBOUND: InternalLogger = SdkInternalLogger(null) |
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.
I think you don't need to use UNBOUND
. According to the code, you have access to the sdkCore.internalLogger
in the OtelTracerProvider.Builder.build()
which calls CoreTracer.CoreTracerBuilder()
- you can just inject sdkCore.internalLogger
there and pass it down to the CoreTracer
instance then.
Is there a need in the UNBOUND
then and thus this change?
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.
yes, I think I did not want to provide it as optional there in the builder but yes it can work this way. I will change it back.
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.
I'm not sure why it should be optional. If it is provided in the constructor of CoreTracer.CoreTracerBuilder()
why it should be?
InternalLogger.UNBOUND
is only for cases when there is no possibility to get logger associated with particular SDK core. This logger is not able to send telemetry and logs produced cannot print the SDK core instance used.
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.
yes...that's the thing, I did not want to provide it in the constructor, not sure why, can't remember, but think it about it now I don't see why I should not.
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.
actually it is because I do not want to use modify the static method: CoreTracer:builder
to CoreTracer:builder(logger)
but will provide a NoOpInternalLogger implementation instead.
92bd5f3
to
ef74896
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.
I left some comments, but I guess nothing blocking.
public CoreTracerBuilder internalLogger(InternalLogger internalLogger) { | ||
this.internalLogger = internalLogger; | ||
return this; | ||
} |
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.
is this method still needed given that we use constructor to inject logger?
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.
I am keeping it just in case.
@NonNull DDSpanContext context, | ||
final List<AgentSpanLink> links) { | ||
final DDSpan span = new DDSpan(instrumentationName, timestampMicro, context, links); | ||
log.debug("Started span: {}", span); |
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.
don't need this anymore?
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.
I think I removed it because I could see the log also elsewhere. I will double check.
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.
yes, it was a call on a static instance log
which now it is a private class instance. I will move it to the constructor instead.
features/dd-sdk-android-trace/src/main/java/com/datadog/trace/core/DDSpan.java
Show resolved
Hide resolved
import java.util.Arrays; | ||
import java.util.Locale; | ||
|
||
public class DatadogCoreTracerLogger implements Logger { |
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.
minor thought: is name still valid? I don't see any relationship with CoreTracer
here.
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.
It is as this is the Logger
implementation for the CoreTracer
module.
...res/dd-sdk-android-trace/src/main/java/com/datadog/trace/logger/DatadogCoreTracerLogger.java
Show resolved
Hide resolved
...res/dd-sdk-android-trace/src/main/java/com/datadog/trace/logger/DatadogCoreTracerLogger.java
Show resolved
Hide resolved
public final class LoggerFactory { | ||
|
||
@NonNull | ||
public static Logger getLogger(String name) { | ||
return new NoOpLogger(); |
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.
seems like we still can have places without any log coverage?
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.
yes but it is quite a lot if we want to cover all the code, I covered all the important places and most of all the other places where these methods are used are not actually needed in the CoreTracer
and maybe I will remove them at the end in a final clean.
.withProperties(properties()) | ||
.serviceName(serviceName) | ||
.writer(tracingFeature?.otelDataWriter ?: NoOpOtelWriter()) | ||
.partialFlushMinSpans(partialFlushThreshold) | ||
.idGenerationStrategy(IdGenerationStrategy.fromName("SECURE_RANDOM", false)) | ||
.internalLogger(sdkCore.internalLogger) |
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.
why do we need to call this if we already injected logger in the constructor above?
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.
I wanted to keep this method just in case for flexibility later. Not sure if we still need to. What do you think ?
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.
if we need it, we can add it later, but currently it creates just some confusion in the API imo, since it is already provided in the constructor.
@StringForgery | ||
lateinit var fakeMessage: String | ||
|
||
private lateinit var expectedFakeMessage: String |
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.
minor suggestion: fakes lingvo is usually just for the setup phase. And also for the consistency, because in some assertions it is already called as expectedMessage
.
Another suggestion is to remove it from the properties as have as a function.
private lateinit var expectedFakeMessage: String | |
private lateinit var expectedMessage: String |
ef74896
to
41370c3
Compare
What does this PR do?
A brief description of the change being made with this pull request.
Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)