Skip to content

Resolver

provide.foundation.eventsets.resolver

TODO: Add module docstring.

Classes

EventSetResolver

EventSetResolver()

Resolves and applies event set enrichments to log events.

Initialize the resolver with cached configurations.

Source code in provide/foundation/eventsets/resolver.py
def __init__(self) -> None:
    """Initialize the resolver with cached configurations."""
    self._field_mappings: list[FieldMapping] = []
    self._event_mappings_by_set: dict[str, list[EventMapping]] = {}
    self._resolved = False
Functions
enrich_event
enrich_event(event_dict: dict[str, Any]) -> dict[str, Any]

Enrich a log event with event set data.

Parameters:

Name Type Description Default
event_dict dict[str, Any]

The event dictionary to enrich

required

Returns:

Type Description
dict[str, Any]

The enriched event dictionary

Source code in provide/foundation/eventsets/resolver.py
def enrich_event(self, event_dict: dict[str, Any]) -> dict[str, Any]:
    """Enrich a log event with event set data.

    Args:
        event_dict: The event dictionary to enrich

    Returns:
        The enriched event dictionary

    """
    if not self._resolved:
        self.resolve()

    enrichments = []

    # Process each field in the event
    for field_key, field_value in list(event_dict.items()):
        if field_key == "event" or field_value is None:
            continue

        visual_marker = self._process_field_enrichment(field_key, field_value, event_dict)
        if visual_marker:
            enrichments.append(visual_marker)

    # Add visual enrichments to event message
    self._apply_visual_enrichments(enrichments, event_dict)

    return event_dict
get_visual_markers
get_visual_markers(event_dict: dict[str, Any]) -> list[str]

Extract visual markers for an event without modifying it.

Parameters:

Name Type Description Default
event_dict dict[str, Any]

The event dictionary to analyze

required

Returns:

Type Description
list[str]

List of visual markers that would be applied

Source code in provide/foundation/eventsets/resolver.py
def get_visual_markers(self, event_dict: dict[str, Any]) -> list[str]:
    """Extract visual markers for an event without modifying it.

    Args:
        event_dict: The event dictionary to analyze

    Returns:
        List of visual markers that would be applied

    """
    if not self._resolved:
        self.resolve()

    markers = []

    for field_key, field_value in event_dict.items():
        if field_key == "event" or field_value is None:
            continue

        event_mapping = self._find_event_mapping_for_field(field_key, field_value)
        if not event_mapping:
            continue

        value_str = str(field_value).lower()
        marker = event_mapping.visual_markers.get(
            value_str,
            event_mapping.visual_markers.get(event_mapping.default_key, ""),
        )

        if marker:
            markers.append(marker)

    return markers
resolve
resolve() -> None

Resolve all registered event sets into a unified configuration.

This merges all registered event sets by priority, building the field mapping and event mapping lookup tables.

Source code in provide/foundation/eventsets/resolver.py
def resolve(self) -> None:
    """Resolve all registered event sets into a unified configuration.

    This merges all registered event sets by priority, building
    the field mapping and event mapping lookup tables.
    """
    registry = get_registry()
    event_sets = registry.list_event_sets()  # Already sorted by priority

    # Clear existing state
    self._field_mappings.clear()
    self._event_mappings_by_set.clear()

    # Process each event set in priority order
    for event_set in event_sets:
        # Store event mappings by event set name
        self._event_mappings_by_set[event_set.name] = event_set.mappings

        # Add field mappings
        self._field_mappings.extend(event_set.field_mappings)

    self._resolved = True

Functions

enrich_event

enrich_event(event_dict: dict[str, Any]) -> dict[str, Any]

Enrich a log event with event set data.

Parameters:

Name Type Description Default
event_dict dict[str, Any]

The event dictionary to enrich

required

Returns:

Type Description
dict[str, Any]

The enriched event dictionary

Source code in provide/foundation/eventsets/resolver.py
def enrich_event(event_dict: dict[str, Any]) -> dict[str, Any]:
    """Enrich a log event with event set data.

    Args:
        event_dict: The event dictionary to enrich

    Returns:
        The enriched event dictionary

    """
    return _resolver.enrich_event(event_dict)

get_resolver

get_resolver() -> EventSetResolver

Get the global event set resolver instance.

Source code in provide/foundation/eventsets/resolver.py
def get_resolver() -> EventSetResolver:
    """Get the global event set resolver instance."""
    return _resolver