[Exporter.Console] Expand test coverage#6904
[Exporter.Console] Expand test coverage#6904rajkumar-rangaraj merged 4 commits intoopen-telemetry:mainfrom
Conversation
Expand the test coverage for the console exporter.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6904 +/- ##
==========================================
+ Coverage 86.29% 88.49% +2.19%
==========================================
Files 263 263
Lines 12383 12383
==========================================
+ Hits 10686 10958 +272
+ Misses 1697 1425 -272
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive test coverage for the OpenTelemetry Console Exporter, increasing coverage from approximately 12% to 80%. The new tests focus primarily on exercising code paths to improve coverage metrics rather than exhaustively validating functional correctness of console output.
Changes:
- Added 7 new test files covering exporters, extension methods, and options configuration
- Tests cover metrics, logs, and tracing exporters with various configurations
- Tests exercise different output targets (Console, Debug, or both) and various telemetry data types
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| ConsoleMetricExporterTests.cs | Tests for ConsoleMetricExporter covering counters, gauges, histograms, exponential histograms, tags, descriptions, meter versions, resources, and different output targets |
| ConsoleLogRecordExporterTests.cs | Tests for ConsoleLogRecordExporter including trace context, event IDs, exceptions, scopes, attributes, severity levels, resources, disposal behavior, and output targets |
| ConsoleActivityExporterAdditionalTests.cs | Tests for ConsoleActivityExporter covering various activity features like events, status, trace state, parent-child relationships, different activity kinds, tags, links, source versions, and resources |
| ConsoleExporterTracerExtensionsTests.cs | Tests for AddConsoleExporter extension methods on TracerProviderBuilder with various parameter combinations and null builder validation |
| ConsoleExporterOptionsTests.cs | Tests for ConsoleExporterOptions covering default values and Target flag configurations |
| ConsoleExporterMetricsExtensionsTests.cs | Tests for AddConsoleExporter extension methods on MeterProviderBuilder with various parameter combinations and null builder validation |
| ConsoleExporterLoggingExtensionsTests.cs | Tests for AddConsoleExporter extension methods on both LoggerProviderBuilder and OpenTelemetryLoggerOptions with various configurations and null validation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| public class ConsoleExporterMetricsExtensionsTests | ||
| { | ||
| [Fact] | ||
| public void AddConsoleExporter_WithNoParameters_Success() |
There was a problem hiding this comment.
We don't use the word "parameters" - its Attributes or Tags
There was a problem hiding this comment.
That's not how I interpret this test.
It uses AddConsoleExporter with no parameters (.AddConsoleExporter()), compared to the other tests which use different overloads that take at least one parameter.
Attributes and tags aren't relevant in this context.
Do you have a suggested alternative name for this test if you think the name is confusing/ambiguous?
test/OpenTelemetry.Exporter.Console.Tests/ConsoleLogRecordExporterTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Matthew Hensley <130569+matt-hensley@users.noreply.github.com>
Changes
Expand the test coverage for the console exporter.
I noticed in the codecov data that test coverage in this repo is pretty good except for the console exporter which is poor (~12%). These additions bring the coverage to ~80% (report).
The tests are mostly aiming at improving coverage only, rather than also verifying functional correctness in all cases (e.g. not checking the text written to the console itself is correct).
The tests were written by Copilot with the prompt below, I then just tidied-up and reformatted the code a bit.
Merge requirement checklist
AppropriateCHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)