Skip to content

Commit

Permalink
fix: add telemetry start event to fix #174
Browse files Browse the repository at this point in the history
  • Loading branch information
zookzook committed Feb 10, 2023
1 parent 4c817b7 commit e79db9e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/mongo/mongo_db_connection.ex
Expand Up @@ -340,6 +340,19 @@ defmodule Mongo.MongoDBConnection do

Events.notify(event, :commands)

metadata = %{
type: :mongodb_driver,
command: data,
command_name: opts[:command_name] || command_name,
database_name: db,
request_id: state.request_id,
operation_id: opts[:operation_id],
connection_id: self(),
options: Keyword.get(opts, :telemetry_options, [])
}

:telemetry.execute([:mongodb_driver, :start], %{}, metadata)

case :timer.tc(fn -> Utils.post_request(op, state.request_id, %{state | timeout: timeout}) end) do
{duration, {:ok, flags, doc}} ->
state = %{state | request_id: state.request_id + 1}
Expand Down

0 comments on commit e79db9e

Please sign in to comment.