Skip to content

Commit

Permalink
feat: source.service_name for setting the service name on backends (#…
Browse files Browse the repository at this point in the history
…2166)

* style: tweak dashboard new source position, refactor to heex

* feat: use source.service_name as a grouping for sources

* feat: add in entire event body to dd as metadata

* docs: add in Datadog backend adjustments

* chore: fix tests
  • Loading branch information
Ziinc authored Aug 7, 2024
1 parent 4e87cef commit c720745
Show file tree
Hide file tree
Showing 8 changed files with 247 additions and 204 deletions.
4 changes: 3 additions & 1 deletion docs/docs.logflare.com/docs/backends/datadog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ The following values are required when creating a webhook backend:

Implementation is based on the [webhook backend](/backends/webhook).

Events will be gzipped and batch with a maximum of 250 events per request. The source name will be set as the service name.
The entire event body will be set to the `data` key of the events sent to Datadog.

Events will be gzipped and batch with a maximum of 250 events per request. The service name of the source will be used as the `ddservice`. If not set, it will default to the source name.
7 changes: 4 additions & 3 deletions lib/logflare/backends/adaptor/datadog_adaptor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ defmodule Logflare.Backends.Adaptor.DatadogAdaptor do
%Logflare.LogEvent{
le
| body: %{
message: formatted_ts <> " " <> Jason.encode!(le.body),
ddsource: "Logflare by Supabase",
service: le.source.name
"message" => formatted_ts <> " " <> (le.body["message"] || le.body["event_message"]),
"ddsource" => "Supabase",
"service" => le.source.service_name || le.source.name,
"data" => le.body
}
}
end
Expand Down
4 changes: 4 additions & 0 deletions lib/logflare/sources/source.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ defmodule Logflare.Source do
@derive {Jason.Encoder,
only: [
:name,
:service_name,
:token,
:id,
:favorite,
Expand Down Expand Up @@ -104,6 +105,7 @@ defmodule Logflare.Source do

schema "sources" do
field(:name, :string)
field(:service_name, :string)
field(:token, Ecto.UUID.Atom, autogenerate: true)
field(:public_token, :string)
field(:favorite, :boolean, default: false)
Expand Down Expand Up @@ -159,6 +161,7 @@ defmodule Logflare.Source do
source
|> cast(attrs, [
:name,
:service_name,
:token,
:public_token,
:favorite,
Expand Down Expand Up @@ -186,6 +189,7 @@ defmodule Logflare.Source do
source
|> cast(attrs, [
:name,
:service_name,
:token,
:public_token,
:favorite,
Expand Down
196 changes: 0 additions & 196 deletions lib/logflare_web/templates/source/dashboard.html.eex

This file was deleted.

Loading

0 comments on commit c720745

Please sign in to comment.