gamma-observability

0
1
Source

Implement comprehensive observability for Gamma integrations. Use when setting up monitoring, logging, tracing, or building dashboards for Gamma API usage. Trigger with phrases like "gamma monitoring", "gamma logging", "gamma metrics", "gamma observability", "gamma dashboard".

Install

mkdir -p .claude/skills/gamma-observability && curl -L -o skill.zip "https://mcp.directory/api/skills/download/5418" && unzip -o skill.zip -d .claude/skills/gamma-observability && rm skill.zip

Installs to .claude/skills/gamma-observability

About this skill

Gamma Observability

Overview

Implement monitoring, logging, and health checks for Gamma API integrations. Since Gamma does not expose rate limit headers or internal metrics, observability is built around your API call patterns, latency, error rates, credit consumption, and generation success rates.

Prerequisites

  • Working Gamma integration (see gamma-sdk-patterns)
  • Monitoring stack (Prometheus/Grafana, Datadog, or CloudWatch)
  • Logging infrastructure

Instructions

Step 1: Instrumented Client

// src/observability/gamma-metrics.ts
interface GammaMetrics {
  requests: number;
  errors: number;
  generations: number;
  completions: number;
  failures: number;
  totalCredits: number;
  totalLatencyMs: number;
  errorsByStatus: Record<number, number>;
}

const metrics: GammaMetrics = {
  requests: 0, errors: 0,
  generations: 0, completions: 0, failures: 0,
  totalCredits: 0, totalLatencyMs: 0,
  errorsByStatus: {},
};

export function createInstrumentedClient(apiKey: string) {
  const base = "https://public-api.gamma.app/v1.0";
  const headers = { "X-API-KEY": apiKey, "Content-Type": "application/json" };

  async function instrumentedRequest(method: string, path: string, body?: unknown) {
    metrics.requests++;
    const start = Date.now();

    try {
      const res = await fetch(`${base}${path}`, {
        method, headers,
        body: body ? JSON.stringify(body) : undefined,
      });
      metrics.totalLatencyMs += Date.now() - start;

      if (!res.ok) {
        metrics.errors++;
        metrics.errorsByStatus[res.status] = (metrics.errorsByStatus[res.status] || 0) + 1;
        throw new Error(`Gamma ${res.status}: ${await res.text()}`);
      }
      return res.json();
    } catch (err) {
      if (!metrics.errorsByStatus[0]) metrics.errorsByStatus[0] = 0;
      metrics.totalLatencyMs += Date.now() - start;
      throw err;
    }
  }

  return {
    generate: async (body: any) => {
      metrics.generations++;
      return instrumentedRequest("POST", "/generations", body);
    },
    poll: (id: string) => instrumentedRequest("GET", `/generations/${id}`),
    listThemes: () => instrumentedRequest("GET", "/themes"),
    listFolders: () => instrumentedRequest("GET", "/folders"),

    // Record completion metrics
    recordCompletion: (creditsUsed: number) => {
      metrics.completions++;
      metrics.totalCredits += creditsUsed;
    },
    recordFailure: () => { metrics.failures++; },
  };
}

export function getMetrics() {
  return {
    ...metrics,
    avgLatencyMs: metrics.requests > 0
      ? Math.round(metrics.totalLatencyMs / metrics.requests) : 0,
    errorRate: metrics.requests > 0
      ? (metrics.errors / metrics.requests * 100).toFixed(2) + "%" : "0%",
    completionRate: metrics.generations > 0
      ? (metrics.completions / metrics.generations * 100).toFixed(1) + "%" : "N/A",
    avgCreditsPerGeneration: metrics.completions > 0
      ? Math.round(metrics.totalCredits / metrics.completions) : 0,
  };
}

Step 2: Structured Logging

// src/observability/logger.ts
function logGammaEvent(event: string, data: Record<string, any>) {
  console.log(JSON.stringify({
    timestamp: new Date().toISOString(),
    service: "gamma",
    event,
    ...data,
    // Never log: apiKey, raw content (may contain PII)
  }));
}

// Usage
logGammaEvent("generation.started", {
  generationId: "gen_abc123",
  outputFormat: "presentation",
  contentLength: 500,
});

logGammaEvent("generation.completed", {
  generationId: "gen_abc123",
  creditsUsed: 42,
  latencyMs: 15000,
});

logGammaEvent("generation.failed", {
  generationId: "gen_abc123",
  error: "Generation failed after 180s",
});

Step 3: Health Check Endpoint

// src/api/health.ts
async function checkGammaHealth() {
  const start = Date.now();
  try {
    const res = await fetch("https://public-api.gamma.app/v1.0/themes", {
      headers: { "X-API-KEY": process.env.GAMMA_API_KEY! },
    });
    const latencyMs = Date.now() - start;

    if (!res.ok) {
      return { status: "unhealthy", latencyMs, error: `HTTP ${res.status}` };
    }
    if (latencyMs > 5000) {
      return { status: "degraded", latencyMs, message: "High latency" };
    }
    return { status: "healthy", latencyMs };
  } catch (err: any) {
    return { status: "unhealthy", latencyMs: Date.now() - start, error: err.message };
  }
}

app.get("/health/gamma", async (req, res) => {
  const health = await checkGammaHealth();
  res.status(health.status === "unhealthy" ? 503 : 200).json(health);
});

Step 4: Prometheus Metrics Endpoint

// src/api/metrics.ts
app.get("/metrics/gamma", (req, res) => {
  const m = getMetrics();
  res.type("text/plain").send(`
# HELP gamma_requests_total Total API requests
# TYPE gamma_requests_total counter
gamma_requests_total ${m.requests}

# HELP gamma_errors_total Total API errors
# TYPE gamma_errors_total counter
gamma_errors_total ${m.errors}

# HELP gamma_generations_total Total generations started
# TYPE gamma_generations_total counter
gamma_generations_total ${m.generations}

# HELP gamma_completions_total Successful generations
# TYPE gamma_completions_total counter
gamma_completions_total ${m.completions}

# HELP gamma_credits_total Total credits consumed
# TYPE gamma_credits_total counter
gamma_credits_total ${m.totalCredits}

# HELP gamma_avg_latency_ms Average request latency
# TYPE gamma_avg_latency_ms gauge
gamma_avg_latency_ms ${m.avgLatencyMs}
  `.trim());
});

Step 5: Alerting Rules

# alerting-rules.yml (Prometheus)
groups:
  - name: gamma
    rules:
      - alert: GammaHighErrorRate
        expr: rate(gamma_errors_total[5m]) / rate(gamma_requests_total[5m]) > 0.1
        for: 5m
        annotations:
          summary: "Gamma error rate above 10%"

      - alert: GammaHealthUnhealthy
        expr: up{job="gamma-health"} == 0
        for: 2m
        annotations:
          summary: "Gamma health check failing"

      - alert: GammaHighCreditBurn
        expr: rate(gamma_credits_total[1h]) > 100
        for: 30m
        annotations:
          summary: "Gamma credit consumption > 100/hour"

      - alert: GammaLowCompletionRate
        expr: gamma_completions_total / gamma_generations_total < 0.8
        for: 15m
        annotations:
          summary: "Gamma generation completion rate below 80%"

Key Metrics to Monitor

MetricHealthyWarningCritical
API error rate< 5%5-10%> 10%
Health check latency< 2s2-5s> 5s
Generation completion rate> 90%80-90%< 80%
Credits per hourWithin budget75% of budgetOver budget
Average generation time< 30s30-60s> 60s

Error Handling

IssueCauseSolution
Metrics not appearingScrape config wrongCheck Prometheus targets
Health check flappingNetwork jitterAdd for: 2m to alert rules
Credit alerts too noisyThresholds too lowCalibrate to your usage pattern
Missing generation metricsNot calling recordCompletion()Ensure poll results feed metrics

Resources

Next Steps

Proceed to gamma-incident-runbook for incident response.

svg-icon-generator

jeremylongshore

Svg Icon Generator - Auto-activating skill for Visual Content. Triggers on: svg icon generator, svg icon generator Part of the Visual Content skill category.

10735

d2-diagram-creator

jeremylongshore

D2 Diagram Creator - Auto-activating skill for Visual Content. Triggers on: d2 diagram creator, d2 diagram creator Part of the Visual Content skill category.

8833

automating-mobile-app-testing

jeremylongshore

This skill enables automated testing of mobile applications on iOS and Android platforms using frameworks like Appium, Detox, XCUITest, and Espresso. It generates end-to-end tests, sets up page object models, and handles platform-specific elements. Use this skill when the user requests mobile app testing, test automation for iOS or Android, or needs assistance with setting up device farms and simulators. The skill is triggered by terms like "mobile testing", "appium", "detox", "xcuitest", "espresso", "android test", "ios test".

18728

performing-penetration-testing

jeremylongshore

This skill enables automated penetration testing of web applications. It uses the penetration-tester plugin to identify vulnerabilities, including OWASP Top 10 threats, and suggests exploitation techniques. Use this skill when the user requests a "penetration test", "pentest", "vulnerability assessment", or asks to "exploit" a web application. It provides comprehensive reporting on identified security flaws.

5519

designing-database-schemas

jeremylongshore

Design and visualize efficient database schemas, normalize data, map relationships, and generate ERD diagrams and SQL statements.

12516

optimizing-sql-queries

jeremylongshore

This skill analyzes and optimizes SQL queries for improved performance. It identifies potential bottlenecks, suggests optimal indexes, and proposes query rewrites. Use this when the user mentions "optimize SQL query", "improve SQL performance", "SQL query optimization", "slow SQL query", or asks for help with "SQL indexing". The skill helps enhance database efficiency by analyzing query structure, recommending indexes, and reviewing execution plans.

5513

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

1,6771,424

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

1,2531,313

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

1,5221,142

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

1,345805

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

1,257725

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

1,464673