GcpGcs.Telemetry (GcpGcs v0.2.0)

Copy Markdown View Source

Telemetry events emitted by GcpGcs.

Request events

All operations are wrapped with :telemetry.span/3 under the [:gcp_gcs, :request] prefix:

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

Metadata carries the operation context. Typical keys:

  • :operation — atom, e.g. :create_bucket, :get_object, :upload, :download
  • :bucket — bucket name (when applicable)
  • :object — object name (when applicable)
  • :result:ok for success, {:error, code} for known errors

Auth events

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

Example

:telemetry.attach(
  "gcp-gcs-logger",
  [:gcp_gcs, :request, :stop],
  fn _event, %{duration: duration}, %{operation: op, result: result}, _config ->
    ms = System.convert_time_unit(duration, :native, :millisecond)
    Logger.info("gcs #{op} -> #{inspect(result)} in #{ms}ms")
  end,
  nil
)

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