Skip to content

traces_sampler example doesn't match the actual context provided #945

Open

Description

@dmarkow

Issue Description

The docs give an example on how to adjust the sample rate depending on the context. However, it appears the example doesn't match what ultimately gets reported in the Sentry dashboard.

Reproduction Steps

Add this config from the docs and you'll see that the op is never http.server for any http requests, but instead atoms like :GET and :POST

config :sentry,
  traces_sampler: fn sampling_context ->
    case sampling_context.transaction_context.op do
      IO.inspect(op, label: "Actual op") 
      "http.server" -> 0.1  # Sample 10% of HTTP requests
      _ -> 0.05             # Sample 5% of other operations
    end
  end

Expected Behavior

Sample code should work, or docs should be updated to match what the library actually does.

Actual Behavior

100% of the traces reported by my Phoenix app show up with an op of either db or http.server on the Sentry dashboard. But the op field in the context passed to traces_sampler is always something more detailed. For example, if I issue a GET request to /health-check, this is what the context actually looks like when I inspect it.

%{
  attributes: %{
    "url.path": "/health-check",
    "http.request.method": :GET,
    "client.address": "127.0.0.1",
    "network.peer.address": "127.0.0.1",
    "network.peer.port": 62201,
    "network.protocol.version": :"1.1",
    "url.scheme": :http,
    "user_agent.original": "curl/8.7.1",
    "server.address": "localhost",
    "server.port": 4001
  },
  name: :GET,
  op: :GET,
  trace_id: 68167592341524485616445320670865761234
}

However, in Sentry's dashboard, this shows up like this, with an op of http.server.

Image

So if I try to filter on http.server like the example shows, it doesn't work because op doesn't become http.server until some point after the traces_sampler function runs.

The same issue for db ops. In the context, they will show up as my_app.repo.query but report as db on the dashboard.

Elixir Version

1.18.4

SDK Version

11.0.4

Integration and Its Version

No response

Sentry Config

No response

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 26, 2025
  2. self-assigned this
    on Nov 21, 2025
  3. solnic commented on Dec 22, 2025

    @solnic
    Collaborator

    @dmarkow thanks for reporting this and apologies for the late reply - I'll update the docs and try to improve the DX eventually. For now the sampler operates at a lower level hence the discrapency.

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Dec 22, 2025
  5. wingyplus commented on Apr 2, 2026

    @wingyplus

    Hi, I ran into this issue as well.

    Possible to use span_kind instead of span_name? (see from https://github.com/getsentry/sentry-elixir/blob/master/lib/sentry/opentelemetry/sampler.ex#L134).

    Or do you have any design in mind? I can help take a look.

  6. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Apr 2, 2026
  7. added this to the 14.0.0 milestone on Sep 1, 2026
  8. modified the milestones: 14.0.0, 15.0 on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions