open-telemetry / opentelemetry-erlang

OpenTelemetry Erlang SDK
https://opentelemetry.io
Apache License 2.0
330 stars 105 forks source link

opentelemetry_exporter run in elixir release #532

Open ziminyuri opened 1 year ago

ziminyuri commented 1 year ago

When I have such a config:

     [
          app: :test_dynatrace,
          version: "0.1.0",
          elixir: "~> 1.11",
          start_permanent: Mix.env() == :prod,
          deps: deps(),
          aliases: aliases(),
          releases: [
            test_dynatrace: [
              version: "0.1.0",
              applications: [
                test_dynatrace: :permanent
              ]
            ]
          ]
        ]

The log on application startup is as follows:

    03:29:45.519 [info] Application logger started on node 'test_dynatrace@test-dynatrace-33-xkbzx'
    03:29:45.519 [info] Application opentelemetry_api started on node 'test_dynatrace@test-dynatrace-33-xkbzx'
    [warning] OTLP exporter failed to initialize with exception :throw:{:application_either_not_started_or_not_ready, :tls_certificate_check}
    03:29:45.599 [info] Application opentelemetry started on node 'test_dynatrace@test-dynatrace-33-xkbzx'
    03:29:45.599 [info] Application acceptor_pool started on node 'test_dynatrace@test-dynatrace-33-xkbzx'
    03:29:45.599 [info] Application hpack started on node 'test_dynatrace@test-dynatrace-33-xkbzx'
    03:29:45.599 [info] Application chatterbox started on node 'test_dynatrace@test-dynatrace-33-xkbzx'
    03:29:45.599 [info] Application ctx started on node 'test_dynatrace@test-dynatrace-33-xkbzx'
    03:29:45.600 [info] Application gproc started on node 'test_dynatrace@test-dynatrace-33-xkbzx'
    03:29:45.600 [info] Application grpcbox started on node 'test_dynatrace@test-dynatrace-33-xkbzx'
    03:29:45.601 [info] Application inets started on node 'test_dynatrace@test-dynatrace-33-xkbzx'
    03:29:45.601 [info] Application ssl_verify_fun started on node 'test_dynatrace@test-dynatrace-33-xkbzx'
    03:29:45.612 [info] Application tls_certificate_check started on node 'test_dynatrace@test-dynatrace-33-xkbzx'
    03:29:45.612 [info] Application opentelemetry_exporter started on node 'test_dynatrace@test-dynatrace-33-xkbzx'
    [info] Starting node 'test_dynatrace@test-dynatrace-33-xkbzx'
    03:29:45.613 [info] Application test_dynatrace started on node 'test_dynatrace@test-dynatrace-33-xkbzx'
    [info] OTLP exporter successfully initialize

But if I add the applications listed in the instructions

        [
          app: :test_dynatrace,
          version: "0.1.0",
          elixir: "~> 1.11",
          start_permanent: Mix.env() == :prod,
          deps: deps(),
          aliases: aliases(),
          releases: [
            test_dynatrace: [
              version: "0.1.0",
              applications: [
                test_dynatrace: :permanent,
                opentelemetry_exporter: :permanent,
                opentelemetry: :temporary
              ]
            ],
          ]
        ]

Log is much shorter:

    03:47:37.855 [info] Application logger started on node 'test_dynatrace@test-dynatrace-34-n7csb'
    [info] Starting node 'test_dynatrace@test-dynatrace-34-n7csb'
    03:47:37.856 [info] Application test_dynatrace started on node 'test_dynatrace@test-dynatrace-34-n7csb'

How to write the correct config?

tsloughter commented 1 year ago

This is logs in the console when you run the release?

Note the order in the instructions would result in:

              applications: [
                opentelemetry_exporter: :permanent,
                opentelemetry: :temporary,
                test_dynatrace: :permanent
              ]

The main point here is to start the exporter before the SDK and to have the SDK started as early as possible.

tsloughter commented 1 year ago

Have you been able to try the suggested application order?

              applications: [
                opentelemetry_exporter: :permanent,
                opentelemetry: :temporary,
                test_dynatrace: :permanent
              ]