Categorygithub.com/ThijsKoot/openlineage-go
modulepackage
0.0.3
Repository: https://github.com/thijskoot/openlineage-go.git
Documentation: pkg.go.dev

# README

OpenLineage SDK for Go GoDoc

This library contains an SDK for the OpenLineage project. Large parts are generated from the OpenLineage specification.

The root of the library contains the core OpenLineage types, facets are located in pkg/facets.

Installing

go get github.com/ThijsKoot/openlineage-go

Usage

runID := uuid.Must(uuid.NewV7())
facet := facets.NewProcessingEngine("v1.2.3").
    WithName("my-go-engine")

openlineage.NewRunEvent(openlineage.EventTypeStart, runID, "my-job").
    WithRunFacets(facet).
    Emit()

Configuring

All configuration is captured in openlineage.ClientConfig, which can be read from the following sources:

  • YAML configuration file
  • Environment variables
  • Variables set in code
// config which prints pretty-printed events to console
cfg := openlineage.ClientConfig{
	Transport: transport.Config{
		Type: transport.TransportTypeConsole,
		Console: &transport.ConsoleConfig{
			PrettyPrint: true,
		},
	},
}

// create a new client using this configuration
client, err := openlineage.NewClient(cfg)

File

See below for how to read a configuration file and its format.

config, err := openlineage.ConfigFromFile("my/openlineage/config.yaml")
# example file
namespace: default # default
disabled: false # default

transport:
  type: console
  console:
    prettyPrint: true

  http:
    url: https://foo
    endpoint: api/v1/lineage # default
    apiKey: ""

Environment

Use openlineage.ConfigFromEnv to read configuration values from the environment. If OPENLINEAGE_CONFIG is specified, it is processed first. Values from the environment are applied afterwards.

cfg, err := openlineage.ConfigFromEnv()

The table below contains an overview of all environment variables.

VariableDefaultDescription
OPENLINEAGE_CONFIGPath to YAML-file containing configuration
OPENLINEAGE_TRANSPORTTransport to use. Can be: http, console
OPENLINEAGE_PRETTY_PRINTPretty-print JSON events if using console transport
OPENLINEAGE_NAMESPACEdefaultNamespace used for emitting events
OPENLINEAGE_ENDPOINTapi/v1/lineageEndpoint on OPENLINEAGE_URL accepting events
OPENLINEAGE_API_KEYAPI key for HTTP transport, if required
OPENLINEAGE_URLURL for HTTP transport
OPENLINEAGE_DISABLEDfalseDisable OpenLineage

Transport

The SDK supports pluggable transports via the transport.Transport interface.

type Transport interface {
	Emit(ctx context.Context, event any) error
}

The built-in transports are HTTP and Console. HTTP uses POST-requests to an endpoint, optionally secured with bearer authentication. Console prints JSON-formatted events to stdout.

Run API

The run package contains a tracing-like API modeled loosely after OpenTelemetry's. It is separate from the core functionality because of its opinionated design. The purpose of this package is to provide an ergonomic way of emitting events within code with less verbosity. It also allows for implicit passing of Runs with context.Context to avoid having to manually propagate a run context.

# Packages

No description provided by the author

# Functions

ConfigFromEnv attempts to parse [ClientConfig] from the environment.
ConfigFromFile reads a configuration file in YAML-format from the specified location.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewJob calls [NewNamespacedJob] with [DefaultNamespace].
NewJobEvent calls [NewNamespacedJobEvent] with [DefaultNamespace].
NewNamespacedJob creates a new [Job].
No description provided by the author
NewNamespacedRunEvent creates a new [RunEvent] with EventTime set to [time.Now].
No description provided by the author
NewRunEvent calls [NewNamespacedRunEvent] with [DefaultNamespace].

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
A Dataset sent within static metadata events.
DatasetEvent represents an OpenLineage DatasetEvent.
No description provided by the author
An input dataset.
No description provided by the author
JobEvent represents an OpenLineage JobEvent.
An output dataset.
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author

# Type aliases

the current transition of the run state.