PubsubGrpc.Telemetry (PubsubGrpc v0.4.2)

View Source

Telemetry events emitted by PubsubGrpc.

Events

All events share the prefix [:pubsub_grpc, :request, _] and are produced by :telemetry.span/3. Three events are emitted per operation:

  • [:pubsub_grpc, :request, :start] — measurements %{system_time: integer, monotonic_time: integer}
  • [:pubsub_grpc, :request, :stop] — measurements %{duration: integer, monotonic_time: integer}
  • [:pubsub_grpc, :request, :exception] — emitted when the wrapped function raises

Metadata

Start and stop events carry the operation context. Typical keys:

  • :operation — atom, e.g. :publish, :pull, :acknowledge, :create_topic
  • :project_id — Google Cloud project id (always present)
  • :topic_id, :subscription_id, :schema_id — when applicable
  • :message_count — for :publish and :pull (where known up front)

Stop events additionally include:

  • :result:ok for success, {:error, error_code} for known errors, :unknown for unexpected return shapes

Example

:telemetry.attach(
  "pubsub-grpc-logger",
  [:pubsub_grpc, :request, :stop],
  fn _event, %{duration: duration}, %{operation: op, result: result}, _config ->
    IO.inspect({op, result, System.convert_time_unit(duration, :native, :millisecond)})
  end,
  nil
)

Auth events

Token fetches emit [:pubsub_grpc, :auth, _] events with the same three suffixes. Stop metadata includes :source (:cache | :goth | :gcloud) when available.

Summary

Functions

auth_span(metadata, fun)

@spec auth_span(map(), (-> result)) :: result when result: var

span(operation, metadata, fun)

@spec span(atom(), map(), (-> result)) :: result when result: var