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

feat: telemetry ingestion api stats #1855

Merged
merged 5 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions lib/logflare_web/controllers/plugs/rate_limiter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ defmodule LogflareWeb.Plugs.RateLimiter do
|> put_x_rate_limit_headers(metrics)

{:error, %{message: message, metrics: metrics}} ->
:telemetry.execute(
[:logflare, :rate_limiter],
%{
rejected: true
},
%{user_id: user.id, source_id: source.id, source_token: source.token}
)

conn
|> put_x_rate_limit_headers(metrics)
|> send_resp(429, message)
Expand Down
29 changes: 24 additions & 5 deletions lib/telemetry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,14 @@ defmodule Logflare.Telemetry do
tags: [:processor],
unit: {:native, :millisecond}
),
counter("logflare.logs.processor.ingest.stop.duration", tags: [:processor]),
sum("logflare.logs.processor.ingest.logs.count", tags: [:processor]),
counter("logflare.logs.processor.ingest.stop.duration",
tags: [:processor, :source_token],
description: "Ingestion execution counts"
),
summary("logflare.logs.processor.ingest.logs.count",
tags: [:processor, :source_token],
description: "Ingestion batch size"
),
summary("logflare.logs.processor.ingest.store.stop.duration",
tags: [:processor],
unit: {:native, :millisecond}
Expand All @@ -88,9 +94,22 @@ defmodule Logflare.Telemetry do
summary("logflare.ingest.common_pipeline.handle_batch.batch_size", tags: [:pipeline]),
counter("logflare.context_cache.busted.count", tags: [:schema, :table]),
counter("logflare.context_cache.handle_record.count", tags: [:schema, :table]),
counter("logflare.logs.ingest_logs.drop"),
counter("logflare.logs.ingest_logs.rejected"),
counter("logflare.logs.ingest_logs.buffer_full")
counter("logflare.logs.ingest_logs.drop",
tags: [:source_token],
description: "Ingest drops by source"
),
counter("logflare.logs.ingest_logs.rejected",
tags: [:source_token],
description: "Ingest rejects by source"
),
counter("logflare.logs.ingest_logs.buffer_full",
tags: [:source_token],
description: "Ingest buffer fulls by source"
),
counter("logflare.rate_limiter.rejected",
tags: [:user_id, :source_token],
description: "Rate limited API hits"
)
]

Enum.concat([
Expand Down
Loading