> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wyvern.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Logging Events

Wyvern has a standardized way of logging events that’s useful either for debugging, observability and training/improving your models. Here are the events wyvern records:

| Event Type           | Explanation                                                                                                                                                           | Data Being Logged                                                                                                                                                                                          |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Candidate event      | Wyvern records each candidate passed into Wyvern from it’s caller.                                                                                                    | 1. The entity id (ie product\_id)<br />2. The entity score (from your search, OpenSearch or algolia)<br />3. The candidate order (from from your search)                                                   |
| Feature event        | Wyvern records each feature generated for the purposes of evaluating model                                                                                            | 1. The entity id (ie product\_id)<br />2. The feature identifier (ie what entity the feature corresponds to.. for example the entity’s brand, or query:product)<br />3. feature name<br />4. feature value |
| Model event          | Wyvern records the model scores for each candidate. This includes the actual predictions for each model that’s evaluated, including the ensembling of multiple models | 1. The entity id<br />2. The model source<br />3. The model generated score                                                                                                                                |
| Business logic event | Wyvern records each candidate which had business logic applied to it. whether the ML model results was modified or not and what was change was)                       | 1. The entity id (ie product\_id)<br />2. The business logic application source<br />3. The original candidate score<br />4. The adjusted candidate score                                                  |
| Impression event     | Wyvern records the final scores for each candidate, after it has gone through Model Scoring and Business logic pipelines                                              | 1. Impression id<br />2. Impression type<br />3. Impression order (this will be 0 for non-ranking situations)<br />4. Impression score                                                                     |
| Custom event         | Wyvern records your custom event data. See [Custom Logging](/logging_events#custom-logging) to see how to build a custom event log                                    | 1. The custom entity id<br />2. The custom entity identifier type<br />3. custom data                                                                                                                      |

## Custom logging

Here’s an example of how to log custom event data within Wyvern:

```python theme={null}
from wyvern.event_logging import event_logger
from wyvern.components.events.events import EntityEventData

# define your custom event data
class EmailEventData(EntityEventData):
    owner_name: str
    title: str

# log the event
event_logger.log_custom_events(
    events=[
        EmailEventData(
            entity_identifier="email_addr@gmail.com",
            entity_identifier_type="email",
            owner_name="Jim",
            title="Check-in",
            ),
        EmailEventData(
            entity_identifier="email_addr_2@gmail.com",
            entity_identifier_type="email",
            owner_name="Shu",
            title="Hello World",
        ),
    ]
)
```

1. import the `EntityEventData` and build your custom entity event data like the `EmailEventData` in this exampl

   e

2. import `event_logger` from `wyvern.components.events.events` and call `event_logger.log_custom_events` to log your custom event

   s

## Integration

By default, event logging is always enabled. This might cause error if you have not set up your event logging integration. To disable Wyvern event logging, set the `EVENT_LOGGING_ENABLED=false` in your environment.

### Raw Event Logging Integration

Currently wyvern is only integrated with AWS kinesis, which sends all the events to your destination.

Steps to set up kinesis with Wyvern:

1. Check out [Creating an Amazon Kinesis Data Firehose Delivery Stream](https://docs.aws.amazon.com/firehose/latest/dev/basic-create.html) to set up kinesis and send the data to s3.
2. Once you set up your kinesis delivery system, set up an IAM role that has access to the firehose delivery stream.
3. Set up your AWS configurations in the environment for running wyvern:

* AWS\_ACCESS\_KEY\_ID
* AWS\_SECRET\_ACCESS\_KEY
* AWS\_REGION\_NAME

### Data Warehouse Integration

#### Snowflake

Use [snowpipe](https://docs.snowflake.com/en/user-guide/data-load-snowpipe-auto-s3) to auto ingest wyvern's events to your data warehouse.

### Event Transformation (Coming soon)

Wyvern provides a built-in transformer to transform the raw event logs into event tables show in this page.
