opentelemetry-php icon indicating copy to clipboard operation
opentelemetry-php copied to clipboard

Inconsistent console exporter behavior/documentation

Open smaddock opened this issue 5 months ago • 1 comments

Is your feature request related to a problem? Not really a problem, but an observation.

Code discrepancies:

  • OpenTelemetry\SDK\Logs\Exporter\ConsoleExporter depends on being created by ConsoleExporterFactory to create the appropriate stream transport, otherwise it's not actually exporting to the consol
  • OpenTelemetry\SDK\Metrics\MetricExporter\ConsoleMetricExporter uses echo for output (the only time echo is used anywhere in the SDK)
  • OpenTelemetry\SDK\Trace\SpanExporter\ConsoleSpanExporter depends on SpanExporterFactoryInterface in the same manner as the Log exporter

Documentation discrepancies:

Referencing this otel.io page:

  • Under "Instrumentation setup>Initialize the SDK" the example instrumentation.php creates each exporter by configuring the stream transport directly
  • Under "Traces>Span Processor" the ConsoleSpanExporterFactory is used
  • Under "Metrics>Setup" the ConsoleMetricExporterFactory is used
  • Under "Logs>Setup" the stream transport is configured directly

Describe the solution you'd like

  • Update ConsoleMetricExporter to use a transport instead of echo
  • Update all three exporters to have a default stream transport targeting php://stdout so they are functionally "console" exporters even without the factory
  • Remove the (then redundant) default transport from the factories
  • Update the documentation to use the console exporter factory in all instances

Describe alternatives you've considered Checked for any related issues, did not see any.

Additional context None.

smaddock avatar Jun 23 '25 00:06 smaddock

I'm hoping to submit a PR for this in the next couple weeks, but it should be an easy one for a first issue or if someone is itching to submit one.

smaddock avatar Jun 23 '25 00:06 smaddock

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 18 '25 05:10 stale[bot]