Skip to content

Comments

[Exporter.Console] Expand test coverage#6904

Merged
rajkumar-rangaraj merged 4 commits intoopen-telemetry:mainfrom
martincostello:console-exporter-test-coverage
Feb 18, 2026
Merged

[Exporter.Console] Expand test coverage#6904
rajkumar-rangaraj merged 4 commits intoopen-telemetry:mainfrom
martincostello:console-exporter-test-coverage

Conversation

@martincostello
Copy link
Member

@martincostello martincostello commented Feb 17, 2026

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.

Following the conventions used for other tests in the solution, create new unit test classes and methods to improve the test coverage of the console exporter to 70% or greater

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

Expand the test coverage for the console exporter.
@github-actions github-actions bot added the pkg:OpenTelemetry.Exporter.Console Issues related to OpenTelemetry.Exporter.Console NuGet package label Feb 17, 2026
@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.49%. Comparing base (ca5582f) to head (827a7c5).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
unittests-Project-Experimental 88.25% <ø> (+1.96%) ⬆️
unittests-Project-Stable 87.97% <ø> (+1.71%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 14 files with indirect coverage changes

@martincostello martincostello marked this pull request as ready for review February 17, 2026 14:13
@martincostello martincostello requested a review from a team as a code owner February 17, 2026 14:13
Copilot AI review requested due to automatic review settings February 17, 2026 14:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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()
Copy link
Member

Choose a reason for hiding this comment

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

We don't use the word "parameters" - its Attributes or Tags

Copy link
Member Author

Choose a reason for hiding this comment

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

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?

Co-authored-by: Matthew Hensley <130569+matt-hensley@users.noreply.github.com>
@rajkumar-rangaraj rajkumar-rangaraj added this pull request to the merge queue Feb 18, 2026
Merged via the queue into open-telemetry:main with commit db429bf Feb 18, 2026
46 checks passed
@martincostello martincostello deleted the console-exporter-test-coverage branch February 18, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:OpenTelemetry.Exporter.Console Issues related to OpenTelemetry.Exporter.Console NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants