Class: Braintrust::Resources::Projects::Logs

Inherits:
Object
  • Object
show all
Defined in:
lib/braintrust/resources/projects/logs.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Logs

Returns a new instance of Logs.



7
8
9
# File 'lib/braintrust/resources/projects/logs.rb', line 7

def initialize(client:)
  @client = client
end

Instance Method Details

#feedback(project_id, params = {}, opts = {}) ⇒ Braintrust::Models::FeedbackResponseSchema

Log feedback for a set of project logs events

Parameters:

  • project_id (String)

    Project id

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

Returns:



21
22
23
24
25
26
27
28
# File 'lib/braintrust/resources/projects/logs.rb', line 21

def feedback(project_id, params = {}, opts = {})
  req = {}
  req[:method] = :post
  req[:path] = "/v1/project_logs/#{project_id}/feedback"
  req[:body] = params
  req[:model] = Braintrust::Models::FeedbackResponseSchema
  @client.request(req, opts)
end

#fetch(project_id, params = {}, opts = {}) ⇒ Braintrust::Models::FetchProjectLogsEventsResponse

Fetch the events in a project logs. Equivalent to the POST form of the same path, but with the parameters in the URL query rather than in the request body

Parameters:

  • project_id (String)

    Project id

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :limit (Integer)

    limit the number of traces fetched

    Fetch queries may be paginated if the total result size is expected to be large (e.g. project_logs which accumulate over a long time). Note that fetch queries only support pagination in descending time order (from latest to earliest _xact_id. Furthermore, later pages may return rows which showed up in earlier pages, except with an earlier _xact_id. This happens because pagination occurs over the whole version history of the event log. You will most likely want to exclude any such duplicate, outdated rows (by id) from your combined result set.

    The limit parameter controls the number of full traces to return. So you may end up with more individual rows than the specified limit if you are fetching events containing traces.

  • :max_root_span_id (String)

    DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument going forwards.

    Together, max_xact_id and max_root_span_id form a pagination cursor

    Since a paginated fetch query returns results in order from latest to earliest, the cursor for the next page can be found as the row with the minimum (earliest) value of the tuple (_xact_id, root_span_id). See the documentation of limit for an overview of paginating fetch queries.

  • :max_xact_id (String)

    DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument going forwards.

    Together, max_xact_id and max_root_span_id form a pagination cursor

    Since a paginated fetch query returns results in order from latest to earliest, the cursor for the next page can be found as the row with the minimum (earliest) value of the tuple (_xact_id, root_span_id). See the documentation of limit for an overview of paginating fetch queries.

  • :version (String)

    Retrieve a snapshot of events from a past time

    The version id is essentially a filter on the latest event transaction id. You can use the max_xact_id returned by a past fetch as the version to reproduce that exact fetch.

Returns:



79
80
81
82
83
84
85
86
# File 'lib/braintrust/resources/projects/logs.rb', line 79

def fetch(project_id, params = {}, opts = {})
  req = {}
  req[:method] = :get
  req[:path] = "/v1/project_logs/#{project_id}/fetch"
  req[:query] = params
  req[:model] = Braintrust::Models::FetchProjectLogsEventsResponse
  @client.request(req, opts)
end

#fetch_post(project_id, params = {}, opts = {}) ⇒ Braintrust::Models::FetchProjectLogsEventsResponse

Fetch the events in a project logs. Equivalent to the GET form of the same path, but with the parameters in the request body rather than in the URL query

Parameters:

  • project_id (String)

    Project id

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :cursor (String)

    An opaque string to be used as a cursor for the next page of results, in order from latest to earliest.

    The string can be obtained directly from the cursor property of the previous fetch query

  • :filters (Array<Braintrust::Models::PathLookupFilter>)

    NOTE: This parameter is deprecated and will be removed in a future revision. Consider using the /btql endpoint (https://www.braintrust.dev/docs/reference/btql) for more advanced filtering.

    A list of filters on the events to fetch. Currently, only path-lookup type filters are supported.

  • :limit (Integer)

    limit the number of traces fetched

    Fetch queries may be paginated if the total result size is expected to be large (e.g. project_logs which accumulate over a long time). Note that fetch queries only support pagination in descending time order (from latest to earliest _xact_id. Furthermore, later pages may return rows which showed up in earlier pages, except with an earlier _xact_id. This happens because pagination occurs over the whole version history of the event log. You will most likely want to exclude any such duplicate, outdated rows (by id) from your combined result set.

    The limit parameter controls the number of full traces to return. So you may end up with more individual rows than the specified limit if you are fetching events containing traces.

  • :max_root_span_id (String)

    DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument going forwards.

    Together, max_xact_id and max_root_span_id form a pagination cursor

    Since a paginated fetch query returns results in order from latest to earliest, the cursor for the next page can be found as the row with the minimum (earliest) value of the tuple (_xact_id, root_span_id). See the documentation of limit for an overview of paginating fetch queries.

  • :max_xact_id (String)

    DEPRECATION NOTICE: The manually-constructed pagination cursor is deprecated in favor of the explicit 'cursor' returned by object fetch requests. Please prefer the 'cursor' argument going forwards.

    Together, max_xact_id and max_root_span_id form a pagination cursor

    Since a paginated fetch query returns results in order from latest to earliest, the cursor for the next page can be found as the row with the minimum (earliest) value of the tuple (_xact_id, root_span_id). See the documentation of limit for an overview of paginating fetch queries.

  • :version (String)

    Retrieve a snapshot of events from a past time

    The version id is essentially a filter on the latest event transaction id. You can use the max_xact_id returned by a past fetch as the version to reproduce that exact fetch.

Returns:



148
149
150
151
152
153
154
155
# File 'lib/braintrust/resources/projects/logs.rb', line 148

def fetch_post(project_id, params = {}, opts = {})
  req = {}
  req[:method] = :post
  req[:path] = "/v1/project_logs/#{project_id}/fetch"
  req[:body] = params
  req[:model] = Braintrust::Models::FetchProjectLogsEventsResponse
  @client.request(req, opts)
end

#insert(project_id, params = {}, opts = {}) ⇒ Braintrust::Models::InsertEventsResponse

Insert a set of events into the project logs

Parameters:

  • project_id (String)

    Project id

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

Returns:



167
168
169
170
171
172
173
174
# File 'lib/braintrust/resources/projects/logs.rb', line 167

def insert(project_id, params = {}, opts = {})
  req = {}
  req[:method] = :post
  req[:path] = "/v1/project_logs/#{project_id}/insert"
  req[:body] = params
  req[:model] = Braintrust::Models::InsertEventsResponse
  @client.request(req, opts)
end