Module: Exa

Defined in:
lib/exa.rb,
lib/exa/client.rb,
lib/exa/errors.rb,
lib/exa/errors.rb,
lib/exa/version.rb,
lib/exa/cli/root.rb,
lib/exa/types/base.rb,
lib/exa/types/enums.rb,
lib/exa/types/answer.rb,
lib/exa/types/schema.rb,
lib/exa/types/search.rb,
lib/exa/internal/util.rb,
lib/exa/cli/formatters.rb,
lib/exa/resources/base.rb,
lib/exa/responses/cost.rb,
lib/exa/types/contents.rb,
lib/exa/types/research.rb,
lib/exa/instrumentation.rb,
lib/exa/cli/config_store.rb,
lib/exa/resources/events.rb,
lib/exa/resources/search.rb,
lib/exa/responses/result.rb,
lib/exa/resources/imports.rb,
lib/exa/resources/websets.rb,
lib/exa/responses/helpers.rb,
lib/exa/resources/research.rb,
lib/exa/resources/webhooks.rb,
lib/exa/types/find_similar.rb,
lib/exa/cli/account_resolver.rb,
lib/exa/instrumentation/events.rb,
lib/exa/responses/raw_response.rb,
lib/exa/resources/websets/items.rb,
lib/exa/responses/event_response.rb,
lib/exa/internal/transport/stream.rb,
lib/exa/responses/answer_response.rb,
lib/exa/responses/import_response.rb,
lib/exa/responses/search_response.rb,
lib/exa/responses/webset_response.rb,
lib/exa/resources/websets/monitors.rb,
lib/exa/responses/monitor_response.rb,
lib/exa/responses/webhook_response.rb,
lib/exa/responses/contents_response.rb,
lib/exa/responses/research_response.rb,
lib/exa/instrumentation/cost_tracker.rb,
lib/exa/resources/websets/enrichments.rb,
lib/exa/internal/transport/base_client.rb,
lib/exa/internal/transport/async_requester.rb,
lib/exa/internal/transport/pooled_net_requester.rb

Defined Under Namespace

Modules: CLI, Errors, Instrumentation, Internal, Resources, Responses, Types Classes: Client

Constant Summary collapse

Error =
Exa::Errors::Error
VERSION =
"1.3.0"

Class Method Summary collapse

Class Method Details

.emit(event_name, payload) ⇒ Object

Emit an event to all subscribers. Primarily used internally by the transport layer.

Parameters:

  • event_name (String)

    The event name (e.g., 'exa.request.complete')

  • payload (Object)

    The event payload



37
38
39
# File 'lib/exa.rb', line 37

def emit(event_name, payload)
  instrumentation.notify(event_name, payload)
end

.instrumentationExa::Instrumentation::EventRegistry

Returns the global instrumentation event registry. Use this to subscribe to API events for cost tracking, logging, etc.

Examples:

Subscribe to all request events

Exa.instrumentation.subscribe('exa.request.*') do |event_name, payload|
  puts "#{event_name}: #{payload.inspect}"
end

Returns:



28
29
30
# File 'lib/exa.rb', line 28

def instrumentation
  @instrumentation ||= Instrumentation::EventRegistry.new
end