Skip to content

Commit

Permalink
Update getting-started.md with Bandit (open-telemetry#4518)
Browse files Browse the repository at this point in the history
Co-authored-by: Severin Neumann <neumanns@cisco.com>
Co-authored-by: opentelemetrybot <107717825+opentelemetrybot@users.noreply.github.com>
Co-authored-by: Phillip Carter <pcarter@fastmail.com>
  • Loading branch information
4 people committed May 23, 2024
1 parent 9eab7c5 commit a08b8e5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions content/en/docs/languages/erlang/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ We'll need a few other dependencies that Phoenix doesn't come with.
OpenTelemetry Collector and/or to self-hosted or commercial services.
- `opentelemetry_phoenix`: creates OpenTelemetry spans from the Elixir
`:telemetry` events created by Phoenix.
- `opentelemetry_cowboy`: creates OpenTelemetry spans from the Elixir
`:telemetry` events created by the Cowboy web server (which is used by
Phoenix).
- web server dependencies: There are currently two options for web servers and
each has their telemetry counterpart. Phoenix applications post 1.7.11 default
to Bandit while pre 1.7.11 default to Cowboy. Both choices are valid. Use one
of the below options based on the web server your Phoenix application uses:
- `opentelemetry_cowboy`: creates OpenTelemetry spans from the Elixir
`:telemetry` events created by the Cowboy web server
- `opentelemetry_bandit`: creates OpenTelemetry spans from the Elixir
`:telemetry` events created by the Bandit web server

```elixir
# mix.exs
Expand All @@ -59,7 +64,10 @@ def deps do
{:opentelemetry_api, "~> {{% param versions.otelApi %}}"},
{:opentelemetry_exporter, "~> {{% param versions.otelExporter %}}"},
{:opentelemetry_phoenix, "~> {{% param versions.otelPhoenix %}}"},
{:opentelemetry_cowboy, "~> {{% param versions.otelCowboy %}}"},
# for Cowboy
{:opentelemetry_cowboy, "~> {{% param versions.otelCowboy %}}"}
# for Bandit
{:opentelemetry_bandit, "~> {{% version-from-registry instrumentation-erlang-bandit %}}"},
]
end
```
Expand All @@ -70,8 +78,12 @@ The last two also need to be setup when your application starts:
# application.ex
@impl true
def start(_type, _args) do
# Depending on what webserver you are using, you will either use:
:opentelemetry_cowboy.setup()
OpentelemetryPhoenix.setup(adapter: :cowboy2)
# or
OpentelemetryBandit.setup()
OpentelemetryPhoenix.setup(adapter: :bandit)
end
```

Expand Down

0 comments on commit a08b8e5

Please sign in to comment.