Skip to content

Add a testing-internal module and functionality to SuppressLogger for…#4130

Merged
anuraaga merged 5 commits intoopen-telemetry:mainfrom
anuraaga:testing-internal-suppress
Feb 1, 2022
Merged

Add a testing-internal module and functionality to SuppressLogger for…#4130
anuraaga merged 5 commits intoopen-telemetry:mainfrom
anuraaga:testing-internal-suppress

Conversation

@anuraaga
Copy link
Copy Markdown
Contributor

… a test.

In #4126 I realized that SimpleLogger doesn't support mutating logLevel - I had just had good luck with SetSystemProperty initially that the logger got initialized after the property mutation. I'll still rework that PR to focus on enabling slf4j logging throughout for consistency but for suppression sticking to JUL suppression because JUL does support level mutation.

I also went ahead and moved mockito-extensions into this module as it was a reason I've wanted a testing-internal module for a while now.

@anuraaga anuraaga force-pushed the testing-internal-suppress branch from d8713ba to ab02fb3 Compare January 28, 2022 06:49
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 28, 2022

Codecov Report

Merging #4130 (3309c71) into main (3cabcc7) will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #4130      +/-   ##
============================================
+ Coverage     90.14%   90.17%   +0.02%     
- Complexity     4504     4514      +10     
============================================
  Files           532      533       +1     
  Lines         13832    13831       -1     
  Branches       1322     1321       -1     
============================================
+ Hits          12469    12472       +3     
+ Misses          931      927       -4     
  Partials        432      432              
Impacted Files Coverage Δ
...ension/trace/jaeger/sampler/OkHttpGrpcService.java 75.30% <0.00%> (-6.18%) ⬇️
...elemetry/sdk/trace/export/SimpleSpanProcessor.java 83.33% <0.00%> (-4.77%) ⬇️
...sdk/autoconfigure/MetricExporterConfiguration.java 84.50% <0.00%> (-0.43%) ⬇️
...ry/sdk/autoconfigure/LogExporterConfiguration.java 92.15% <0.00%> (-0.16%) ⬇️
...y/sdk/autoconfigure/SpanExporterConfiguration.java 94.52% <0.00%> (-0.08%) ⬇️
...n/java/io/opentelemetry/api/common/Attributes.java 83.33% <0.00%> (ø)
...entelemetry/exporter/internal/retry/RetryUtil.java 100.00% <0.00%> (ø)
...try/sdk/autoconfigure/PropagatorConfiguration.java 100.00% <0.00%> (ø)
...sdk/autoconfigure/TracerProviderConfiguration.java 100.00% <0.00%> (ø)
...entelemetry/sdk/autoconfigure/NamedSpiManager.java 100.00% <0.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3cabcc7...3309c71. Read the comment docs.

import org.slf4j.event.Level;

/** Tests for the {@link LoggingSpanExporter}. */
@SuppressLogger(LoggingSpanExporter.class)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm a bit confused on what is going on here. Whether this annotation is present or not I don't see log output for this when I run ./gradlew :exporters:logging:test.

I thought it might be because the default log level is set to warn, but even after reducing it and removing the @SurpressLogger annotation, I don't see the logs produced by LoggingSpanExporter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for looking into this so deeply! I've never used a logging.properties file before and can't believe that I have to copy in the default values (e.g. ConsoleHandler) when using one... 🙀

Comment on lines +1 to +2
handlers= java.util.logging.ConsoleHandler
.level= INFO
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

formatting here is slightly different than the rest of the file. missing a space before the = sign.

"4.2.0",
listOf("mockito-core", "mockito-junit-jupiter")
)
),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

?

import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

public final class LoggerExtension
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

would you mind adding a bit of javadoc on this class to explain what it's for, and why we have it?

Copy link
Copy Markdown
Contributor

@jkwatson jkwatson left a comment

Choose a reason for hiding this comment

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

Just one small ask for some additional internal documentation

@anuraaga anuraaga merged commit 03c41ec into open-telemetry:main Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants