Skip to content
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

OtlpHttpTransportFactory requires protobuf implementation, but not mentioned in docs #1065

Closed
tigrannajaryan opened this issue Jun 28, 2023 · 2 comments
Labels
bug Something isn't working tc-review technical committee review feedback

Comments

@tigrannajaryan
Copy link
Member

Describe your environment
$ php -v
PHP 8.2.7 (cli) (built: Jun 8 2023 20:05:45) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.7, Copyright (c) Zend Technologies
with Zend OPcache v8.2.7, Copyright (c), by Zend Technologies

Steps to reproduce
I am following the instruction exporter example here https://opentelemetry.io/docs/instrumentation/php/exporters/

Executed composer require open-telemetry/exporter-otlp php-http/guzzle7-adapter

Using the following code:

<?php

declare(strict_types=1);

use OpenTelemetry\API\Logs\LogRecord;
use OpenTelemetry\SDK\Sdk;
use OpenTelemetry\SDK\Common\Attribute\Attributes;
use OpenTelemetry\SDK\Common\Instrumentation\InstrumentationScopeFactory;
use OpenTelemetry\SDK\Common\Time\ClockFactory;
use OpenTelemetry\SDK\Logs\Exporter\ConsoleExporterFactory;
use OpenTelemetry\SDK\Logs\LoggerProvider;
use OpenTelemetry\SDK\Logs\Processor\SimpleLogsProcessor;
use OpenTelemetry\SDK\Logs\Processor\BatchLogsProcessor;
use OpenTelemetry\API\Common\Instrumentation\Globals;
use OpenTelemetry\Contrib\Otlp\OtlpHttpTransportFactory;
use OpenTelemetry\Contrib\Otlp\LogsExporter;

require 'vendor/autoload.php';


$transport = (new OtlpHttpTransportFactory())->create('http://jaeger:4318/v1/traces', 'application/json');

$exporter = new LogsExporter($transport);

$loggerProvider = new LoggerProvider(
    new SimpleLogsProcessor(
        (new ConsoleExporterFactory())->create()
    ),
    new InstrumentationScopeFactory(Attributes::factory())
);

Sdk::builder()
    ->setLoggerProvider($loggerProvider)
    ->setAutoShutdown(true)
    ->buildAndRegisterGlobal();


$logger = Globals::loggerProvider()->getLogger('demo', '1.0', 'http://schema.url', ['scopefoo' => 'scopebar']);

$record = (new LogRecord(['foo' => 'bar', 'baz' => 'bat', 'msg' => 'hello world']))
    ->setSeverityText('INFO')
    ->setSeverityNumber(9);

$logger->emit($record);

What is the expected behavior?
Logs exported via OTLP

What is the actual behavior?
Error:

Uncaught RuntimeException: No protobuf implementation found (ext-protobuf or google/protobuf) in /Users/tnajaryan/work/experiments/otel-php/vendor/open-telemetry/exporter-otlp/LogsExporter.php:33
Stack trace:
#0 /Users/tnajaryan/work/experiments/otel-php/otlpexport.php(23): OpenTelemetry\Contrib\Otlp\LogsExporter->__construct(Object(OpenTelemetry\SDK\Common\Export\Http\PsrTransport))
#1 {main}
  thrown in /Users/tnajaryan/work/experiments/otel-php/vendor/open-telemetry/exporter-otlp/LogsExporter.php on line 33

Additional context
Part of review open-telemetry/community#1537

@tigrannajaryan tigrannajaryan added the bug Something isn't working label Jun 28, 2023
@tigrannajaryan tigrannajaryan changed the title OtlpHttpTransportFactory requires protobuf implementation OtlpHttpTransportFactory requires protobuf implementation, but not mentioned in docs Jun 28, 2023
@brettmc brettmc added the tc-review technical committee review feedback label Jul 3, 2023
@brettmc
Copy link
Collaborator

brettmc commented Jul 3, 2023

related issue: #1061

@brettmc
Copy link
Collaborator

brettmc commented Jul 18, 2023

@brettmc brettmc closed this as completed Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tc-review technical committee review feedback
Projects
None yet
Development

No branches or pull requests

2 participants