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

Update getting-started.md with Bandit #4518

Merged
merged 7 commits into from
May 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions content/en/docs/languages/erlang/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ 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 webservers 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 webserver 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
def deps do
Expand All @@ -59,7 +65,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, "~> 0.1.4"},
pdgonzalez872 marked this conversation as resolved.
Show resolved Hide resolved
]
end
```
Expand All @@ -70,8 +79,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