Skip to content
langfuse-ci-integration logo

Langfuse CI Integration

langfuse-ci-integration

Configure Langfuse CI/CD integration with GitHub Actions and automated testing. Use when setting up automated testing, configuring CI pipelines, or integrating Langfuse tests into your build process. Trigger with phrases like "langfuse CI", "langfuse GitHub Actions", "langfuse automated tests", "...

SKILL.md

Full skill instructions

Langfuse CI Integration

Overview

Set up CI/​CD pipelines for Langfuse integrations with automated testing and validation.

Prerequisites

  • GitHub repository with Actions enabled
  • Langfuse test project API keys
  • npm/​pnpm project configured

Instructions

Step 1: Create GitHub Actions Workflow

Create .github/​workflows/​langfuse-integration.yml:

name: Langfuse Integration Tests

on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main]
  schedule:
    # Run daily to catch Langfuse API changes
    - cron: '0 6 * * *'

env:
  NODE_VERSION: '20'

jobs:
  test:
    runs-on: ubuntu-latest
    environment: test

    env:
      LANGFUSE_PUBLIC_KEY: ${{ secrets.LANGFUSE_PUBLIC_KEY_TEST }}
      LANGFUSE_SECRET_KEY: ${{ secrets.LANGFUSE_SECRET_KEY_TEST }}
      LANGFUSE_HOST: https://cloud.langfuse.com

    steps:
      - name: Checkout code
        uses: actions/​checkout@v4

      - name: Setup Node.js
        uses: actions/​setup-node@v4
        with:
          node-version: ${{ env.NODE_VERSION }}
          cache: 'npm'

      - name: Install dependencies
        run: npm ci

      - name: Run unit tests
        run: npm test -- --coverage

      - name: Run Langfuse integration tests
        run: npm run test:integration
        timeout-minutes: 10

      - name: Upload coverage
        uses: codecov/​codecov-action@v4
        with:
          token: ${{ secrets.CODECOV_TOKEN }}

  validate-traces:
    runs-on: ubuntu-latest
    needs: test
    if: github.event_name == 'push' && github.ref == 'refs/​heads/​main'

    env:
      LANGFUSE_PUBLIC_KEY: ${{ secrets.LANGFUSE_PUBLIC_KEY_TEST }}
      LANGFUSE_SECRET_KEY: ${{ secrets.LANGFUSE_SECRET_KEY_TEST }}

    steps:
      - name: Checkout code
        uses: actions/​checkout@v4

      - name: Setup Node.js
        uses: actions/​setup-node@v4
        with:
          node-version: ${{ env.NODE_VERSION }}
          cache: 'npm'

      - name: Install dependencies
        run: npm ci

      - name: Validate Langfuse traces
        run: npm run validate:langfuse

Step 2: Configure Secrets

# Set test environment secrets
gh secret set LANGFUSE_PUBLIC_KEY_TEST --body "pk-lf-test-..."
gh secret set LANGFUSE_SECRET_KEY_TEST --body "sk-lf-test-..."

# Set production secrets (for deploy workflow)
gh secret set LANGFUSE_PUBLIC_KEY_PROD --body "pk-lf-prod-..."
gh secret set LANGFUSE_SECRET_KEY_PROD --body "sk-lf-prod-..."

Step 3: Create Integration Tests

// tests/​langfuse.integration.test.ts
import { describe, it, expect, beforeAll, afterAll } from "vitest";
import { Langfuse } from "langfuse";

const SKIP_INTEGRATION = !process.env.LANGFUSE_PUBLIC_KEY;

describe.skipIf(SKIP_INTEGRATION)("Langfuse Integration", () => {
  let langfuse: Langfuse;

  beforeAll(() => {
    langfuse = new Langfuse({
      publicKey: process.env.LANGFUSE_PUBLIC_KEY!,
      secretKey: process.env.LANGFUSE_SECRET_KEY!,
      baseUrl: process.env.LANGFUSE_HOST,
    });
  });

  afterAll(async () => {
    await langfuse.shutdownAsync();
  });

  it("should connect to Langfuse", async () => {
    const trace = langfuse.trace({
      name: "ci-connection-test",
      metadata: {
        ci: true,
        commit: process.env.GITHUB_SHA,
        workflow: process.env.GITHUB_WORKFLOW,
      },
    });

    expect(trace.id).toBeDefined();
    await langfuse.flushAsync();
  });

  it("should create complete trace with generation", async () => {
    const trace = langfuse.trace({
      name: "ci-full-trace-test",
      input: { query: "test query" },
    });

    const span = trace.span({
      name: "process",
      input: { step: 1 },
    });

    const generation = span.generation({
      name: "llm-call",
      model: "gpt-4",
      input: [{ role: "user", content: "test" }],
    });

    generation.end({
      output: "test response",
      usage: { promptTokens: 5, completionTokens: 10 },
    });

    span.end({ output: { processed: true } });
    trace.update({ output: { success: true } });

    await langfuse.flushAsync();

    // Verify trace URL is valid
    const traceUrl = trace.getTraceUrl();
    expect(traceUrl).toContain("langfuse.com");
  });

  it("should handle errors gracefully", async () => {
    const trace = langfuse.trace({
      name: "ci-error-test",
    });

    trace.update({
      level: "ERROR",
      statusMessage: "Test error for CI validation",
    });

    await langfuse.flushAsync();
    expect(trace.id).toBeDefined();
  });
});

Step 4: Add Validation Script

// scripts/​validate-langfuse.ts
import { Langfuse } from "langfuse";

async function validateLangfuseSetup() {
  console.log("=== Langfuse CI Validation ===\n");

  const langfuse = new Langfuse();

  const checks = [
    {
      name: "Create trace",
      test: async () => {
        const trace = langfuse.trace({
          name: "ci-validation",
          metadata: { validation: true },
        });
        return !!trace.id;
      },
    },
    {
      name: "Create span",
      test: async () => {
        const trace = langfuse.trace({ name: "span-test" });
        const span = trace.span({ name: "test-span" });
        span.end();
        return !!span.id;
      },
    },
    {
      name: "Create generation",
      test: async () => {
        const trace = langfuse.trace({ name: "gen-test" });
        const gen = trace.generation({
          name: "test-gen",
          model: "test-model",
        });
        gen.end({ output: "test" });
        return !!gen.id;
      },
    },
    {
      name: "Flush data",
      test: async () => {
        await langfuse.flushAsync();
        return true;
      },
    },
    {
      name: "Shutdown gracefully",
      test: async () => {
        await langfuse.shutdownAsync();
        return true;
      },
    },
  ];

  let passed = 0;
  let failed = 0;

  for (const { name, test } of checks) {
    try {
      const result = await test();
      if (result) {
        console.log(`✓ ${name}`);
        passed++;
      } else {
        console.log(`✗ ${name}`);
        failed++;
      }
    } catch (error) {
      console.log(`✗ ${name}: ${error}`);
      failed++;
    }
  }

  console.log(`\nResults: ${passed}/​${checks.length} passed`);

  if (failed > 0) {
    process.exit(1);
  }
}

validateLangfuseSetup();

Step 5: Add package.json Scripts

{
  "scripts": {
    "test": "vitest run",
    "test:integration": "vitest run tests/​*.integration.test.ts",
    "validate:langfuse": "tsx scripts/​validate-langfuse.ts"
  }
}

Output

  • Automated test pipeline
  • PR checks configured
  • Coverage reports uploaded
  • Daily validation runs
  • Trace validation on merge

PR Status Checks

# .github/​branch-protection.yml (reference)
required_status_checks:
  strict: true
  contexts:
    - "test"
    - "validate-traces"

Error Handling

IssueCauseSolution
Secret not foundMissing configurationAdd secret via gh secret set
Tests timeoutNetwork issuesIncrease timeout or add retry
Auth failuresInvalid keyCheck secret value
Flaky testsRace conditionsAdd proper flush/​wait

Examples

Matrix Testing (Multiple Node Versions)

jobs:
  test:
    strategy:
      matrix:
        node-version: [18, 20, 22]

    steps:
      - uses: actions/​setup-node@v4
        with:
          node-version: ${{ matrix.node-version }}
      # ... rest of steps

Release Workflow with Langfuse Validation

name: Release

on:
  push:
    tags: ['v*']

jobs:
  release:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/​checkout@v4

      - name: Setup Node.js
        uses: actions/​setup-node@v4
        with:
          node-version: '20'
          registry-url: 'https://registry.npmjs.org'

      - name: Install dependencies
        run: npm ci

      - name: Validate Langfuse integration
        env:
          LANGFUSE_PUBLIC_KEY: ${{ secrets.LANGFUSE_PUBLIC_KEY_PROD }}
          LANGFUSE_SECRET_KEY: ${{ secrets.LANGFUSE_SECRET_KEY_PROD }}
        run: npm run validate:langfuse

      - name: Build
        run: npm run build

      - name: Publish
        run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Resources

Next Steps

For deployment patterns, see langfuse-deploy-integration.

More skills from Dicklesworthstone

environment-setup-guide logo
Dicklesworthstone/pi_agent_rust

environment-setup-guide

Guide developers through setting up development environments with proper tools, dependencies, and configurations

1.8K 0
View
exa-policy-guardrails logo
Dicklesworthstone/pi_agent_rust

exa-policy-guardrails

Implement Exa lint rules, policy enforcement, and automated guardrails. Use when setting up code quality rules for Exa integrations, implementing pre-commit hooks, or configuring CI policy checks for Exa best practices. Trigger with phrases like "exa policy", "exa lint", "exa guardrails", "exa be...

1.8K 0
View
documenso-ci-integration logo
Dicklesworthstone/pi_agent_rust

documenso-ci-integration

Configure CI/CD pipelines for Documenso integrations. Use when setting up automated testing, deployment pipelines, or continuous integration for Documenso projects. Trigger with phrases like "documenso CI", "documenso GitHub Actions", "documenso pipeline", "documenso automated testing".

1.8K 0
View
openrouter-model-availability logo
Dicklesworthstone/pi_agent_rust

openrouter-model-availability

Build check model availability and implement fallback chains. Use when building resilient systems or handling model outages. Trigger with phrases like 'openrouter availability', 'openrouter fallback', 'openrouter model down', 'openrouter health check'.

1.8K 0
View
langfuse-enterprise-rbac logo
Dicklesworthstone/pi_agent_rust

langfuse-enterprise-rbac

Configure Langfuse enterprise organization management and access control. Use when implementing team access controls, configuring organization settings, or setting up role-based permissions for Langfuse projects. Trigger with phrases like "langfuse RBAC", "langfuse teams", "langfuse organization"...

1.8K 0
View
cursor-compliance-audit logo
Dicklesworthstone/pi_agent_rust

cursor-compliance-audit

Execute compliance and security auditing for Cursor usage. Triggers on "cursor compliance", "cursor audit", "cursor security review", "cursor soc2", "cursor gdpr". Use when analyzing or auditing cursor compliance audit. Trigger with phrases like "cursor compliance audit", "cursor audit", "cursor".

1.8K 0
View
apollo-ci-integration logo
Dicklesworthstone/pi_agent_rust

apollo-ci-integration

Configure Apollo.io CI/CD integration. Use when setting up automated testing, continuous integration, or deployment pipelines for Apollo integrations. Trigger with phrases like "apollo ci", "apollo github actions", "apollo pipeline", "apollo ci/cd", "apollo automated tests".

1.8K 0
View
python-script logo
Dicklesworthstone/pi_agent_rust

python-script

Create robust Python automation with full logging and safety checks. Use when tasks need complex data processing, authenticated API work, conditional file operations, or error handling beyond simple shell commands.

1.8K 0
View
posthog-multi-env-setup logo
Dicklesworthstone/pi_agent_rust

posthog-multi-env-setup

Configure PostHog across development, staging, and production environments. Use when setting up multi-environment deployments, configuring per-environment secrets, or implementing environment-specific PostHog configurations. Trigger with phrases like "posthog environments", "posthog staging", "po...

1.8K 0
View
ai-agents-architect logo
Dicklesworthstone/pi_agent_rust

ai-agents-architect

Expert in designing and building autonomous AI agents. Masters tool use, memory systems, planning strategies, and multi-agent orchestration. Use when: build agent, AI agent, autonomous agent, tool use, function calling.

1.8K 0
View
insecure-deserialization-checker logo
Dicklesworthstone/pi_agent_rust

insecure-deserialization-checker

Validate insecure deserialization checker operations. Auto-activating skill for Security Fundamentals. Triggers on: insecure deserialization checker, insecure deserialization checker Part of the Security Fundamentals skill category. Use when working with insecure deserialization checker functiona...

1.8K 0
View
path-traversal-finder logo
Dicklesworthstone/pi_agent_rust

path-traversal-finder

Manage path traversal finder operations. Auto-activating skill for Security Fundamentals. Triggers on: path traversal finder, path traversal finder Part of the Security Fundamentals skill category. Use when working with path traversal finder functionality. Trigger with phrases like "path traversa...

1.8K 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View