GitHub CopilotTypeScriptDebugging
Observability with OpenTelemetry Rules for GitHub Copilot
Rules for implementing distributed tracing, metrics, and logging with OpenTelemetry.
.github/copilot-instructions.md
# Observability with OpenTelemetry Rules for GitHub Copilot
# Observability with OpenTelemetry Rules
## The Three Pillars
- **Traces**: distributed request flow across services — OpenTelemetry SDK
- **Metrics**: aggregated measurements — Prometheus + Grafana or Datadog
- **Logs**: structured events — always JSON, always with trace ID
## Instrumentation Setup
```typescript
// Initialize BEFORE importing application code
import { NodeSDK } from '@opentelemetry/sdk-node';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
const sdk = new NodeSDK({
traceExporter: new OTLPTraceExporter({ url: process.env.OTEL_ENDPOINT }),
instrumentations: [getNodeAutoInstrumentations()], // HTTP, express, DB auto-instrumented
});
sdk.start();
```
## Trace Conventions
- Service name: lowercase, hyphenated (`user-service`, `payment-api`)
- Every HTTP request: automatic via auto-instrumentation
- Custom spans for business operations: `tracer.startActiveSpan('process-payment', ...)`
- Span attributes: `user.id`, `order.id`, `payment.amount` — queryable in Jaeger/Tempo
- Error spans: `span.setStatus({ code: SpanStatusCode.ERROR, message: err.message })`
## Structured Logging
```typescript
// Every log includes trace context
const logger = {
info: (msg: string, attrs?: object) => {
const span = trace.getActiveSpan();
const ctx = span?.spanContext();
console.log(JSON.stringify({
level: 'info', message: msg, timestamp: new Date().toISOString(),
traceId: ctx?.traceId, spanId: ctx?.spanId,
...attrsHow to use with GitHub Copilot
Create `.github/copilot-instructions.md` in your repository. GitHub Copilot uses these to customize suggestions across your whole repo.
#copilot#typescript#observability#ai-coding-rules
Related Rules
TypeScript Cursor Rules
CursorTypeScript
Cursor rules for TypeScript: enforce strict mode, eliminate any types, and write type-safe code with these .cursorrules configurations.
Code Style
typescript · strictCopy Ready
TypeScript Windsurf Rules
WindsurfTypeScript
Windsurf rules for TypeScript: strict type safety, functional patterns, and modern TypeScript conventions.
Code Style
typescript · windsurfCopy Ready
TypeScript GitHub Copilot Instructions
GitHub CopilotTypeScript
GitHub Copilot custom instructions for TypeScript: strict types, modern patterns, and team conventions.
Code Style
typescript · copilotCopy Ready
React GitHub Copilot Instructions
GitHub CopilotReact
GitHub Copilot instructions for React: hooks, patterns, and best practices for modern React apps.
Code Style
react · copilotCopy Ready