Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Datahub project Datahub MetadataEventFormatter

From Leeroopedia


Knowledge Sources
Domains Metadata_Integration, Event_Serialization
Last Updated 2026-02-10 00:00 GMT

Overview

Description

EventFormatter is a Java class within the DataHub event SDK that serializes MetadataChangeProposalWrapper objects into transport-ready MetadataChangeProposal messages. It uses Jackson and the Pegasus JacksonDataTemplateCodec to convert aspect data templates into JSON byte payloads wrapped in a GenericAspect. The class supports configurable serialization formats through its Format enum, though currently only PEGASUS_JSON is implemented.

The maximum serialized string length is controlled via the INGESTION_MAX_SERIALIZED_STRING_LENGTH environment variable, falling back to a constant default defined in com.linkedin.metadata.Constants.

Usage

Used by DataHub Java SDK clients to convert high-level metadata change proposal wrapper objects into the lower-level MetadataChangeProposal wire format before sending to the GMS backend or Kafka.

Code Reference

Source Location

metadata-integration/java/datahub-event/src/main/java/datahub/event/EventFormatter.java

Signature

public class EventFormatter {

    public EventFormatter(Format serializationFormat)

    public EventFormatter()

    public MetadataChangeProposal convert(MetadataChangeProposalWrapper mcpw) throws IOException

    public enum Format {
        PEGASUS_JSON,
    }
}

Import

import datahub.event.EventFormatter;

I/O Contract

Inputs

Parameter Type Description
serializationFormat EventFormatter.Format The serialization format to use (default: PEGASUS_JSON)
mcpw MetadataChangeProposalWrapper The wrapper object containing entity type, URN, change type, aspect name, and aspect data template

Outputs

Return Type Description
MetadataChangeProposal A fully populated MCP with the aspect serialized as a GenericAspect with application/json content type

Exceptions:

  • IOException -- if serialization of the aspect data template fails
  • EventValidationException -- if an unsupported serialization format is requested

Usage Examples

// Default Pegasus JSON format
EventFormatter formatter = new EventFormatter();
MetadataChangeProposal mcp = formatter.convert(mcpWrapper);

// Explicit format
EventFormatter formatter = new EventFormatter(EventFormatter.Format.PEGASUS_JSON);
MetadataChangeProposal mcp = formatter.convert(mcpWrapper);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment