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

[opentelemetry-php-contrib] SdkBundle: OTLP exporter factory creates exporter with default values #1146

Open
DrLuke opened this issue Nov 26, 2023 · 2 comments
Labels
bug Something isn't working help wanted This issue is looking for someone to work on it

Comments

@DrLuke
Copy link

DrLuke commented Nov 26, 2023

Describe your environment Describe any aspect of your environment relevant to the problem, including your php version (php -v will tell you your current version), version numbers of installed dependencies, information about your cloud hosting provider, etc. If you're reporting a problem with a specific version of a library in this repo, please check whether the problem has been fixed on master.

Tried on both

      "open-telemetry/sdk": "1.0.0",
      "open-telemetry/symfony-sdk-bundle": "0.0.23",

and

      "open-telemetry/sdk": "dev-main",
      "open-telemetry/symfony-sdk-bundle": "dev-main",

Steps to reproduce
With the config:

otel_sdk:
    trace:
        enabled: true
        span:
          processors: simple
        exporters:
          - "otlp+grpc://otel-col:4317"
          - "otlp+http://otel-col:4318"

The OTLP span exporters are created with default values for protocol and endpoint instead of the values defined in the config.

I guess the SdkBundle is not setting the values in the config the factory is trying to access.

What is the expected behavior?
Exporters configured as I specified

What is the actual behavior?
Exporters configured with default values

@DrLuke DrLuke added the bug Something isn't working label Nov 26, 2023
@brettmc brettmc added the help wanted This issue is looking for someone to work on it label Nov 26, 2023
@mops1k
Copy link

mops1k commented Nov 28, 2023

I have same issue. URL for configuration always taking from \OpenTelemetry\SDK\Common\Configuration\Defaults.
Using environment parameter OTEL_EXPORTER_ZIPKIN_ENDPOINT with my settings only works.

You have to look at https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/sdk-environment-variables.md

@DrLuke
Copy link
Author

DrLuke commented Nov 29, 2023

Workaround if you only require a simple setup (one processor, one exporter, etc.):

  1. Remove OtelSDKBundle
  2. Set up with Zero-code configuration for automatic instrumentation
  3. Add the components you need as synthetic services

e.g. if you want to use TracerProviderInterface via DI, you add this to your config:

OpenTelemetry\API\Trace\TracerProviderInterface:
        synthetic: true

and then somewhere appropriate in your Kernel you just inject it into the container:

protected function initializeContainer(): void
{
    parent::initializeContainer();

    /**
     * @psalm-suppress MixedMethodCall
     */
    $this->container->set("OpenTelemetry\API\Trace\TracerProviderInterface", Globals::tracerProvider());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted This issue is looking for someone to work on it
Projects
None yet
Development

No branches or pull requests

3 participants