Skip to content

Commit

Permalink
chore: improve changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
yordis committed Dec 27, 2023
1 parent 071fa40 commit e3fcadd
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 53 deletions.
29 changes: 27 additions & 2 deletions instrumentation/opentelemetry_oban/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,33 @@

### Changed

* Improve Plugin span attributes. The Plugin's span introduce a set of
attributes prefixed with `oban.`.
* Improve `OpentelemetryOban.PluginHandler` Tracer span attributes.
The Plugin's span introduce a set of attributes prefixed with `oban.`.
Previously, no attributes were added to the span. The new attributes are:

* All Plugin:
* `oban.plugin`
* `Oban.Plugins.Cron` Plugin:
* `oban.jobs_count`
* `Oban.Plugins.Gossip` Plugin:
* `oban.gossip_count`
* `Oban.Plugins.Lifeline` Plugin:
* `oban.discarded_count`
* `oban.rescued_count`
* `Oban.Plugins.Pruner` Plugin:
* `oban.pruned_count`
* `Oban.Pro.Plugins.DynamicCron` Plugin:
* `oban.jobs_count`
* `Oban.Pro.Plugins.DynamicLifeline` Plugin:
* `oban.discarded_count`
* `oban.rescued_count`
* `Oban.Pro.Plugins.DynamicPrioritizer` Plugin:
* `oban.reprioritized_count`
* `Oban.Pro.Plugins.DynamicPruner` Plugin:
* `oban.pruned_count`
* `Oban.Pro.Plugins.DynamicScaler` Plugin:
* `oban.scaler.last_scaled_to`
* `oban.scaler.last_scaled_at`

## 1.0.0

Expand Down
8 changes: 4 additions & 4 deletions instrumentation/opentelemetry_oban/lib/opentelemetry_oban.ex
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ defmodule OpentelemetryOban do
Trace.messaging_system() => :oban,
Trace.messaging_destination() => queue,
Trace.messaging_destination_kind() => :queue,
:"messaging.oban.worker" => worker
:"oban.job.worker" => worker
}
end

defp attributes_after_insert(job) do
%{
"messaging.oban.job_id": job.id,
"messaging.oban.priority": job.priority,
"messaging.oban.max_attempts": job.max_attempts
"oban.job.job_id": job.id,
"oban.job.priority": job.priority,
"oban.job.max_attempts": job.max_attempts
}
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,13 @@ defmodule OpentelemetryOban.JobHandler do
Trace.messaging_destination() => queue,
Trace.messaging_destination_kind() => :queue,
Trace.messaging_operation() => :process,
:"messaging.oban.job_id" => id,
:"messaging.oban.worker" => worker,
:"messaging.oban.priority" => priority,
:"messaging.oban.attempt" => attempt,
:"messaging.oban.max_attempts" => max_attempts,
:"messaging.oban.inserted_at" =>
if(inserted_at, do: DateTime.to_iso8601(inserted_at), else: nil),
:"messaging.oban.scheduled_at" => DateTime.to_iso8601(scheduled_at)
:"oban.job.job_id" => id,
:"oban.job.worker" => worker,
:"oban.job.priority" => priority,
:"oban.job.attempt" => attempt,
:"oban.job.max_attempts" => max_attempts,
:"oban.job.inserted_at" => if(inserted_at, do: DateTime.to_iso8601(inserted_at), else: nil),
:"oban.job.scheduled_at" => DateTime.to_iso8601(scheduled_at)
}

span_name = "#{worker} process"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
defmodule OpentelemetryOban.PluginHandler do
require OpenTelemetry.Tracer, as: Tracer

alias OpenTelemetry.Tracer
alias OpenTelemetry.Span

@tracer_id __MODULE__
Expand Down Expand Up @@ -68,47 +67,47 @@ defmodule OpentelemetryOban.PluginHandler do
end

defp end_span_plugin_attrs(%{plugin: Oban.Plugins.Cron} = metadata) do
%{"oban.jobs_count": length(metadata[:jobs])}
%{"oban.plugins.cron.jobs_count": length(metadata[:jobs])}
end

defp end_span_plugin_attrs(%{plugin: Oban.Plugins.Gossip} = metadata) do
%{"oban.gossip_count": metadata[:gossip_count]}
%{"oban.plugins.gossip.gossip_count": metadata[:gossip_count]}
end

defp end_span_plugin_attrs(%{plugin: Oban.Plugins.Lifeline} = metadata) do
%{
"oban.discarded_count": metadata[:discarded_count],
"oban.rescued_count": metadata[:rescued_count]
"oban.plugins.lifeline.discarded_count": metadata[:discarded_count],
"oban.plugins.lifeline.rescued_count": metadata[:rescued_count]
}
end

defp end_span_plugin_attrs(%{plugin: Oban.Plugins.Pruner} = metadata) do
%{"oban.pruned_count": metadata[:pruned_count]}
%{"oban.plugins.pruner.pruned_count": metadata[:pruned_count]}
end

defp end_span_plugin_attrs(%{plugin: Oban.Pro.Plugins.DynamicCron} = metadata) do
%{"oban.jobs_count": length(metadata[:jobs])}
%{"oban.pro.plugins.dynamic_cron.jobs_count": length(metadata[:jobs])}
end

defp end_span_plugin_attrs(%{plugin: Oban.Pro.Plugins.DynamicLifeline} = metadata) do
%{
"oban.discarded_count": metadata[:discarded_count],
"oban.rescued_count": metadata[:rescued_count]
"oban.pro.plugins.dynamic_lifeline.discarded_count": metadata[:discarded_count],
"oban.pro.plugins.dynamic_lifeline.rescued_count": metadata[:rescued_count]
}
end

defp end_span_plugin_attrs(%{plugin: Oban.Pro.Plugins.DynamicPrioritizer} = metadata) do
%{"oban.reprioritized_count": metadata[:reprioritized_count]}
%{"oban.pro.plugins.dynamic_prioritizer.reprioritized_count": metadata[:reprioritized_count]}
end

defp end_span_plugin_attrs(%{plugin: Oban.Pro.Plugins.DynamicPruner} = metadata) do
%{"oban.pruned_count": metadata[:pruned_count]}
%{"oban.pro.plugins.dynamic_pruner.pruned_count": metadata[:pruned_count]}
end

defp end_span_plugin_attrs(%{plugin: Oban.Pro.Plugins.DynamicScaler} = metadata) do
%{
"oban.scaler.last_scaled_to": metadata[:scaler][:last_scaled_to],
"oban.scaler.last_scaled_at": metadata[:scaler][:last_scaled_at]
"oban.pro.plugins.dynamic_scaler.scaler.last_scaled_to": metadata[:scaler][:last_scaled_to],
"oban.pro.plugins.dynamic_scaler.scaler.last_scaled_at": metadata[:scaler][:last_scaled_at]
}
end

Expand Down
50 changes: 25 additions & 25 deletions instrumentation/opentelemetry_oban/test/opentelemetry_oban_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ defmodule OpentelemetryObanTest do
assert %{
"messaging.destination": "events",
"messaging.destination_kind": :queue,
"messaging.oban.job_id": _job_id,
"messaging.oban.max_attempts": 1,
"messaging.oban.priority": 0,
"messaging.oban.worker": "TestJob",
"oban.job.job_id": _job_id,
"oban.job.max_attempts": 1,
"oban.job.priority": 0,
"oban.job.worker": "TestJob",
"messaging.system": :oban
} = :otel_attributes.map(attributes)
end
Expand Down Expand Up @@ -147,13 +147,13 @@ defmodule OpentelemetryObanTest do
assert %{
"messaging.destination": "events",
"messaging.destination_kind": :queue,
"messaging.oban.attempt": 1,
"messaging.oban.inserted_at": _inserted_at,
"messaging.oban.job_id": _job_id,
"messaging.oban.max_attempts": 1,
"messaging.oban.priority": 0,
"messaging.oban.scheduled_at": _scheduled_at,
"messaging.oban.worker": "TestJob",
"oban.job.attempt": 1,
"oban.job.inserted_at": _inserted_at,
"oban.job.job_id": _job_id,
"oban.job.max_attempts": 1,
"oban.job.priority": 0,
"oban.job.scheduled_at": _scheduled_at,
"oban.job.worker": "TestJob",
"messaging.operation": :process,
"messaging.system": :oban
} = :otel_attributes.map(attributes)
Expand All @@ -177,13 +177,13 @@ defmodule OpentelemetryObanTest do
assert %{
"messaging.destination": "events",
"messaging.destination_kind": :queue,
"messaging.oban.attempt": 1,
"messaging.oban.inserted_at": _inserted_at,
"messaging.oban.job_id": _job_id,
"messaging.oban.max_attempts": 1,
"messaging.oban.priority": 0,
"messaging.oban.scheduled_at": _scheduled_at,
"messaging.oban.worker": "TestJobThatReturnsError",
"oban.job.attempt": 1,
"oban.job.inserted_at": _inserted_at,
"oban.job.job_id": _job_id,
"oban.job.max_attempts": 1,
"oban.job.priority": 0,
"oban.job.scheduled_at": _scheduled_at,
"oban.job.worker": "TestJobThatReturnsError",
"messaging.operation": :process,
"messaging.system": :oban
} = :otel_attributes.map(attributes)
Expand Down Expand Up @@ -255,13 +255,13 @@ defmodule OpentelemetryObanTest do
assert %{
"messaging.destination": "events",
"messaging.destination_kind": :queue,
"messaging.oban.attempt": 1,
"messaging.oban.inserted_at": _inserted_at,
"messaging.oban.job_id": _job_id,
"messaging.oban.max_attempts": 1,
"messaging.oban.priority": 0,
"messaging.oban.scheduled_at": _scheduled_at,
"messaging.oban.worker": "TestJobThatThrowsException",
"oban.job.attempt": 1,
"oban.job.inserted_at": _inserted_at,
"oban.job.job_id": _job_id,
"oban.job.max_attempts": 1,
"oban.job.priority": 0,
"oban.job.scheduled_at": _scheduled_at,
"oban.job.worker": "TestJobThatThrowsException",
"messaging.operation": :process,
"messaging.system": :oban
} = :otel_attributes.map(attributes)
Expand Down

0 comments on commit e3fcadd

Please sign in to comment.