caffeine_lang/codegen/relay

Codegen for the Relay artifact.

A relay is a GitHub Action that pulls metrics from a source vendor and pushes them to a destination vendor. The compiler emits a self-contained set of files that a target repository drops in to start relaying.

Today the only supported pairing is Langfuse → Datadog, producing four files:

File contents come from templates under priv/templates/relay/<pairing>/. Each template is a real .yml / .toml / .gleam file with {{PLACEHOLDER}} tokens — so editors and reviewers get the right syntax highlighting and the diffs read naturally.

Types

Configuration for a Langfuse → Datadog relay. These fields are the placeholder shape until the language constructs land — at that point they will be populated from a parsed relay declaration rather than constructed directly.

pub type LangfuseDatadogRelay {
  LangfuseDatadogRelay(
    name: String,
    metric_prefix: String,
    schedule_cron: String,
    scorers: List(Scorer),
  )
}

Constructors

  • LangfuseDatadogRelay(
      name: String,
      metric_prefix: String,
      schedule_cron: String,
      scorers: List(Scorer),
    )

    Arguments

    name

    Identifier for the relay; used as the workflow filename stem and as the workflow’s name field.

    metric_prefix

    Prefix for Datadog metric names — caller-supplied, no default. The relay emits <metric_prefix>.count (count metric, one submission per scorer per window) and <metric_prefix>.value (gauge, one submission per numeric scorer with the window’s avg value). Choosing the prefix at relay-declaration time keeps the user’s Datadog namespace under their own control.

    schedule_cron

    Cron expression for the workflow’s schedule trigger.

    scorers

    Allowlist of scorers to emit metrics for. Rows from Langfuse whose name isn’t in this list are dropped before submission. The same list drives the generated manifest module.

One file in a relay artifact’s output: a path relative to the target repository root, plus its full contents.

pub type RelayFile {
  RelayFile(path: String, content: String)
}

Constructors

  • RelayFile(path: String, content: String)

A scorer the relay should emit metrics for. The user declares the set up-front; the relay filters Langfuse rows to this allowlist before submitting to Datadog.

pub type Scorer {
  Scorer(name: String, data_type: ScorerDataType)
}

Constructors

Which family of Langfuse scores a scorer produces. Numeric and Boolean scores both get count + value metrics; Categorical scores only get counts (the v2 metrics API rejects value measure on categorical).

pub type ScorerDataType {
  Numeric
  Boolean
  Categorical
}

Constructors

  • Numeric
  • Boolean
  • Categorical

Values

pub fn generate_langfuse_to_datadog(
  relay: LangfuseDatadogRelay,
) -> List(RelayFile)

Generate the file set for a Langfuse → Datadog relay.

Search Document