Skip to content

Commit

Permalink
update changelog and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
cpiemontese committed Apr 17, 2024
1 parent 97ededf commit c2d5e28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Attach to `[:absinthe, :subscription, :publish]` (both `:start` and `:stop`)
- New `graphql.event.type` trace attribute, with value `operation` or `publish`

## [2.2.1] - 2024-02-21

### Changed
Expand Down
12 changes: 6 additions & 6 deletions lib/instrumentation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,28 @@ defmodule OpentelemetryAbsinthe.Instrumentation do
:telemetry.attach(
{__MODULE__, :operation_start},
[:absinthe, :execute, :operation, :start],
&__MODULE__.handle_operation_start/4,
&__MODULE__.handle_start/4,
Map.put(config, :type, :operation)
)

:telemetry.attach(
{__MODULE__, :operation_stop},
[:absinthe, :execute, :operation, :stop],
&__MODULE__.handle_operation_stop/4,
&__MODULE__.handle_stop/4,
Map.put(config, :type, :operation)
)

:telemetry.attach(
{__MODULE__, :publish_start},
[:absinthe, :subscription, :publish, :start],
&__MODULE__.handle_operation_start/4,
&__MODULE__.handle_start/4,
Map.put(config, :type, :publish)
)

:telemetry.attach(
{__MODULE__, :publish_stop},
[:absinthe, :subscription, :publish, :stop],
&__MODULE__.handle_operation_stop/4,
&__MODULE__.handle_stop/4,
Map.put(config, :type, :publish)
)
end
Expand All @@ -104,7 +104,7 @@ defmodule OpentelemetryAbsinthe.Instrumentation do
:telemetry.detach({__MODULE__, :publish_stop})
end

def handle_operation_start(_event_name, _measurements, metadata, config) do
def handle_start(_event_name, _measurements, metadata, config) do
document = metadata.blueprint.input
variables = metadata |> Map.get(:options, []) |> Keyword.get(:variables, %{})

Expand All @@ -125,7 +125,7 @@ defmodule OpentelemetryAbsinthe.Instrumentation do
Tracer.set_current_span(new_ctx)
end

def handle_operation_stop(_event_name, measurements, data, config) do
def handle_stop(_event_name, measurements, data, config) do
operation_type = get_operation_type(data)
operation_name = get_operation_name(data)

Expand Down

0 comments on commit c2d5e28

Please sign in to comment.