{"id":"8f1e2d75-b50f-4f4c-80c3-c38428999874","shortId":"5RBAEh","kind":"skill","title":"azure-monitor-opentelemetry-ts","tagline":"Auto-instrument Node.js applications with distributed tracing, metrics, and logs.","description":"# Azure Monitor OpenTelemetry SDK for TypeScript\n\nAuto-instrument Node.js applications with distributed tracing, metrics, and logs.\n\n## Installation\n\n```bash\n# Distro (recommended - auto-instrumentation)\nnpm install @azure/monitor-opentelemetry\n\n# Low-level exporters (custom OpenTelemetry setup)\nnpm install @azure/monitor-opentelemetry-exporter\n\n# Custom logs ingestion\nnpm install @azure/monitor-ingestion\n```\n\n## Environment Variables\n\n```bash\nAPPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=...;IngestionEndpoint=...\n```\n\n## Quick Start (Auto-Instrumentation)\n\n**IMPORTANT:** Call `useAzureMonitor()` BEFORE importing other modules.\n\n```typescript\nimport { useAzureMonitor } from \"@azure/monitor-opentelemetry\";\n\nuseAzureMonitor({\n  azureMonitorExporterOptions: {\n    connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING\n  }\n});\n\n// Now import your application\nimport express from \"express\";\nconst app = express();\n```\n\n## ESM Support (Node.js 18.19+)\n\n```bash\nnode --import @azure/monitor-opentelemetry/loader ./dist/index.js\n```\n\n**package.json:**\n```json\n{\n  \"scripts\": {\n    \"start\": \"node --import @azure/monitor-opentelemetry/loader ./dist/index.js\"\n  }\n}\n```\n\n## Full Configuration\n\n```typescript\nimport { useAzureMonitor, AzureMonitorOpenTelemetryOptions } from \"@azure/monitor-opentelemetry\";\nimport { resourceFromAttributes } from \"@opentelemetry/resources\";\n\nconst options: AzureMonitorOpenTelemetryOptions = {\n  azureMonitorExporterOptions: {\n    connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING,\n    storageDirectory: \"/path/to/offline/storage\",\n    disableOfflineStorage: false\n  },\n  \n  // Sampling\n  samplingRatio: 1.0,  // 0-1, percentage of traces\n  \n  // Features\n  enableLiveMetrics: true,\n  enableStandardMetrics: true,\n  enablePerformanceCounters: true,\n  \n  // Instrumentation libraries\n  instrumentationOptions: {\n    azureSdk: { enabled: true },\n    http: { enabled: true },\n    mongoDb: { enabled: true },\n    mySql: { enabled: true },\n    postgreSql: { enabled: true },\n    redis: { enabled: true },\n    bunyan: { enabled: false },\n    winston: { enabled: false }\n  },\n  \n  // Custom resource\n  resource: resourceFromAttributes({ \"service.name\": \"my-service\" })\n};\n\nuseAzureMonitor(options);\n```\n\n## Custom Traces\n\n```typescript\nimport { trace } from \"@opentelemetry/api\";\n\nconst tracer = trace.getTracer(\"my-tracer\");\n\nconst span = tracer.startSpan(\"doWork\");\ntry {\n  span.setAttribute(\"component\", \"worker\");\n  span.setAttribute(\"operation.id\", \"42\");\n  span.addEvent(\"processing started\");\n  \n  // Your work here\n  \n} catch (error) {\n  span.recordException(error as Error);\n  span.setStatus({ code: 2, message: (error as Error).message });\n} finally {\n  span.end();\n}\n```\n\n## Custom Metrics\n\n```typescript\nimport { metrics } from \"@opentelemetry/api\";\n\nconst meter = metrics.getMeter(\"my-meter\");\n\n// Counter\nconst counter = meter.createCounter(\"requests_total\");\ncounter.add(1, { route: \"/api/users\", method: \"GET\" });\n\n// Histogram\nconst histogram = meter.createHistogram(\"request_duration_ms\");\nhistogram.record(150, { route: \"/api/users\" });\n\n// Observable Gauge\nconst gauge = meter.createObservableGauge(\"active_connections\");\ngauge.addCallback((result) => {\n  result.observe(getActiveConnections(), { pool: \"main\" });\n});\n```\n\n## Manual Exporter Setup\n\n### Trace Exporter\n\n```typescript\nimport { AzureMonitorTraceExporter } from \"@azure/monitor-opentelemetry-exporter\";\nimport { NodeTracerProvider, BatchSpanProcessor } from \"@opentelemetry/sdk-trace-node\";\n\nconst exporter = new AzureMonitorTraceExporter({\n  connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING\n});\n\nconst provider = new NodeTracerProvider({\n  spanProcessors: [new BatchSpanProcessor(exporter)]\n});\n\nprovider.register();\n```\n\n### Metric Exporter\n\n```typescript\nimport { AzureMonitorMetricExporter } from \"@azure/monitor-opentelemetry-exporter\";\nimport { PeriodicExportingMetricReader, MeterProvider } from \"@opentelemetry/sdk-metrics\";\nimport { metrics } from \"@opentelemetry/api\";\n\nconst exporter = new AzureMonitorMetricExporter({\n  connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING\n});\n\nconst meterProvider = new MeterProvider({\n  readers: [new PeriodicExportingMetricReader({ exporter })]\n});\n\nmetrics.setGlobalMeterProvider(meterProvider);\n```\n\n### Log Exporter\n\n```typescript\nimport { AzureMonitorLogExporter } from \"@azure/monitor-opentelemetry-exporter\";\nimport { BatchLogRecordProcessor, LoggerProvider } from \"@opentelemetry/sdk-logs\";\nimport { logs } from \"@opentelemetry/api-logs\";\n\nconst exporter = new AzureMonitorLogExporter({\n  connectionString: process.env.APPLICATIONINSIGHTS_CONNECTION_STRING\n});\n\nconst loggerProvider = new LoggerProvider();\nloggerProvider.addLogRecordProcessor(new BatchLogRecordProcessor(exporter));\n\nlogs.setGlobalLoggerProvider(loggerProvider);\n```\n\n## Custom Logs Ingestion\n\n```typescript\nimport { DefaultAzureCredential } from \"@azure/identity\";\nimport { LogsIngestionClient, isAggregateLogsUploadError } from \"@azure/monitor-ingestion\";\n\nconst endpoint = \"https://<dce>.ingest.monitor.azure.com\";\nconst ruleId = \"<data-collection-rule-id>\";\nconst streamName = \"Custom-MyTable_CL\";\n\nconst client = new LogsIngestionClient(endpoint, new DefaultAzureCredential());\n\nconst logs = [\n  {\n    Time: new Date().toISOString(),\n    Computer: \"Server1\",\n    Message: \"Application started\",\n    Level: \"Information\"\n  }\n];\n\ntry {\n  await client.upload(ruleId, streamName, logs);\n} catch (error) {\n  if (isAggregateLogsUploadError(error)) {\n    for (const uploadError of error.errors) {\n      console.error(\"Failed logs:\", uploadError.failedLogs);\n    }\n  }\n}\n```\n\n## Custom Span Processor\n\n```typescript\nimport { SpanProcessor, ReadableSpan } from \"@opentelemetry/sdk-trace-base\";\nimport { Span, Context, SpanKind, TraceFlags } from \"@opentelemetry/api\";\nimport { useAzureMonitor } from \"@azure/monitor-opentelemetry\";\n\nclass FilteringSpanProcessor implements SpanProcessor {\n  forceFlush(): Promise<void> { return Promise.resolve(); }\n  shutdown(): Promise<void> { return Promise.resolve(); }\n  onStart(span: Span, context: Context): void {}\n  \n  onEnd(span: ReadableSpan): void {\n    // Add custom attributes\n    span.attributes[\"CustomDimension\"] = \"value\";\n    \n    // Filter out internal spans\n    if (span.kind === SpanKind.INTERNAL) {\n      span.spanContext().traceFlags = TraceFlags.NONE;\n    }\n  }\n}\n\nuseAzureMonitor({\n  spanProcessors: [new FilteringSpanProcessor()]\n});\n```\n\n## Sampling\n\n```typescript\nimport { ApplicationInsightsSampler } from \"@azure/monitor-opentelemetry-exporter\";\nimport { NodeTracerProvider } from \"@opentelemetry/sdk-trace-node\";\n\n// Sample 75% of traces\nconst sampler = new ApplicationInsightsSampler(0.75);\n\nconst provider = new NodeTracerProvider({ sampler });\n```\n\n## Shutdown\n\n```typescript\nimport { useAzureMonitor, shutdownAzureMonitor } from \"@azure/monitor-opentelemetry\";\n\nuseAzureMonitor();\n\n// On application shutdown\nprocess.on(\"SIGTERM\", async () => {\n  await shutdownAzureMonitor();\n  process.exit(0);\n});\n```\n\n## Key Types\n\n```typescript\nimport {\n  useAzureMonitor,\n  shutdownAzureMonitor,\n  AzureMonitorOpenTelemetryOptions,\n  InstrumentationOptions\n} from \"@azure/monitor-opentelemetry\";\n\nimport {\n  AzureMonitorTraceExporter,\n  AzureMonitorMetricExporter,\n  AzureMonitorLogExporter,\n  ApplicationInsightsSampler,\n  AzureMonitorExporterOptions\n} from \"@azure/monitor-opentelemetry-exporter\";\n\nimport {\n  LogsIngestionClient,\n  isAggregateLogsUploadError\n} from \"@azure/monitor-ingestion\";\n```\n\n## Best Practices\n\n1. **Call useAzureMonitor() first** - Before importing other modules\n2. **Use ESM loader for ESM projects** - `--import @azure/monitor-opentelemetry/loader`\n3. **Enable offline storage** - For reliable telemetry in disconnected scenarios\n4. **Set sampling ratio** - For high-traffic applications\n5. **Add custom dimensions** - Use span processors for enrichment\n6. **Graceful shutdown** - Call `shutdownAzureMonitor()` to flush telemetry\n\n## When to Use\nThis skill is applicable to execute the workflow or actions described in the overview.\n\n## Limitations\n- Use this skill only when the task clearly matches the scope described above.\n- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.\n- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.","tags":["azure","monitor","opentelemetry","antigravity","awesome","skills","sickn33","agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding"],"capabilities":["skill","source-sickn33","skill-azure-monitor-opentelemetry-ts","topic-agent-skills","topic-agentic-skills","topic-ai-agent-skills","topic-ai-agents","topic-ai-coding","topic-ai-workflows","topic-antigravity","topic-antigravity-skills","topic-claude-code","topic-claude-code-skills","topic-codex-cli","topic-codex-skills"],"categories":["antigravity-awesome-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/sickn33/antigravity-awesome-skills/azure-monitor-opentelemetry-ts","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add sickn33/antigravity-awesome-skills","source_repo":"https://github.com/sickn33/antigravity-awesome-skills","install_from":"skills.sh"}},"qualityScore":"0.700","qualityRationale":"deterministic score 0.70 from registry signals: · indexed on github topic:agent-skills · 34928 github stars · SKILL.md body (8,442 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-24T18:50:32.781Z","embedding":null,"createdAt":"2026-04-18T21:32:54.251Z","updatedAt":"2026-04-24T18:50:32.781Z","lastSeenAt":"2026-04-24T18:50:32.781Z","tsv":"'-1':147 '/api/users':263,276 '/dist/index.js':110,118 '/path/to/offline/storage':140 '0':146,557 '0.75':534 '1':261,583 '1.0':145 '150':274 '18.19':105 '2':233,591 '3':600 '4':610 '42':218 '5':619 '6':628 '75':527 'action':648 'activ':282 'add':496,620 'app':100 'applic':10,27,94,430,549,618,642 'applicationinsight':63 'applicationinsightssampl':519,533,572 'ask':686 'async':553 'attribut':498 'auto':7,24,39,71 'auto-instru':6,23 'auto-instrument':38,70 'await':435,554 'azur':2,17 'azure-monitor-opentelemetry-t':1 'azure/identity':397 'azure/monitor-ingestion':59,402,580 'azure/monitor-opentelemetry':43,84,126,473,546,567 'azure/monitor-opentelemetry-exporter':53,299,328,362,521,575 'azure/monitor-opentelemetry/loader':109,117,599 'azuremonitorexporteropt':86,134,573 'azuremonitorlogexport':360,375,571 'azuremonitormetricexport':326,341,570 'azuremonitoropentelemetryopt':124,133,564 'azuremonitortraceexport':297,308,569 'azuresdk':161 'bash':35,62,106 'batchlogrecordprocessor':364,386 'batchspanprocessor':302,319 'best':581 'boundari':694 'bunyan':179 'call':74,584,631 'catch':225,440 'cl':413 'clarif':688 'class':474 'clear':661 'client':415 'client.upload':436 'code':232 'compon':214 'comput':427 'configur':120 'connect':64,89,137,283,311,344,378 'connectionstr':87,135,309,342,376 'console.error':450 'const':99,131,202,208,248,255,267,279,305,313,338,346,372,380,403,406,408,414,421,446,530,535 'context':465,489,490 'counter':254,256 'counter.add':260 'criteria':697 'custom':48,54,185,195,241,390,411,454,497,621 'custom-myt':410 'customdimens':500 'date':425 'defaultazurecredenti':395,420 'describ':649,665 'dimens':622 'disableofflinestorag':141 'disconnect':608 'distribut':12,29 'distro':36 'dowork':211 'durat':271 'enabl':162,165,168,171,174,177,180,183,601 'enablelivemetr':152 'enableperformancecount':156 'enablestandardmetr':154 'endpoint':404,418 'enrich':627 'environ':60,677 'environment-specif':676 'error':226,228,230,235,237,441,444 'error.errors':449 'esm':102,593,596 'execut':644 'expert':682 'export':47,291,294,306,320,323,339,353,357,373,387 'express':96,98,101 'fail':451 'fals':142,181,184 'featur':151 'filter':502 'filteringspanprocessor':475,515 'final':239 'first':586 'flush':634 'forceflush':478 'full':119 'gaug':278,280 'gauge.addcallback':284 'get':265 'getactiveconnect':287 'grace':629 'high':616 'high-traff':615 'histogram':266,268 'histogram.record':273 'http':164 'implement':476 'import':73,77,81,92,95,108,116,122,127,198,244,296,300,325,329,334,359,363,368,394,398,458,463,470,518,522,542,561,568,576,588,598 'inform':433 'ingest':56,392 'ingest.monitor.azure.com':405 'ingestionendpoint':67 'input':691 'instal':34,42,52,58 'instrument':8,25,40,72,158 'instrumentationkey':66 'instrumentationopt':160,565 'intern':504 'isaggregatelogsuploaderror':400,443,578 'json':112 'key':558 'level':46,432 'librari':159 'limit':653 'loader':594 'log':16,33,55,356,369,391,422,439,452 'loggerprovid':365,381,383,389 'loggerprovider.addlogrecordprocessor':384 'logs.setgloballoggerprovider':388 'logsingestioncli':399,417,577 'low':45 'low-level':44 'main':289 'manual':290 'match':662 'messag':234,238,429 'meter':249,253 'meter.createcounter':257 'meter.createhistogram':269 'meter.createobservablegauge':281 'meterprovid':331,347,349,355 'method':264 'metric':14,31,242,245,322,335 'metrics.getmeter':250 'metrics.setglobalmeterprovider':354 'miss':699 'modul':79,590 'mongodb':167 'monitor':3,18 'ms':272 'my-met':251 'my-servic':190 'my-trac':205 'mysql':170 'mytabl':412 'new':307,315,318,340,348,351,374,382,385,416,419,424,514,532,537 'node':107,115 'node.js':9,26,104 'nodetracerprovid':301,316,523,538 'npm':41,51,57 'observ':277 'offlin':602 'onend':492 'onstart':486 'opentelemetri':4,19,49 'opentelemetry/api':201,247,337,469 'opentelemetry/api-logs':371 'opentelemetry/resources':130 'opentelemetry/sdk-logs':367 'opentelemetry/sdk-metrics':333 'opentelemetry/sdk-trace-base':462 'opentelemetry/sdk-trace-node':304,525 'operation.id':217 'option':132,194 'output':671 'overview':652 'package.json':111 'percentag':148 'periodicexportingmetricread':330,352 'permiss':692 'pool':288 'postgresql':173 'practic':582 'process':220 'process.env.applicationinsights':88,136,310,343,377 'process.exit':556 'process.on':551 'processor':456,625 'project':597 'promis':479,483 'promise.resolve':481,485 'provid':314,536 'provider.register':321 'quick':68 'ratio':613 'readablespan':460,494 'reader':350 'recommend':37 'redi':176 'reliabl':605 'request':258,270 'requir':690 'resourc':186,187 'resourcefromattribut':128,188 'result':285 'result.observe':286 'return':480,484 'review':683 'rout':262,275 'ruleid':407,437 'safeti':693 'sampl':143,516,526,612 'sampler':531,539 'samplingratio':144 'scenario':609 'scope':664 'script':113 'sdk':20 'server1':428 'servic':192 'service.name':189 'set':611 'setup':50,292 'shutdown':482,540,550,630 'shutdownazuremonitor':544,555,563,632 'sigterm':552 'skill':640,656 'skill-azure-monitor-opentelemetry-ts' 'source-sickn33' 'span':209,455,464,487,488,493,505,624 'span.addevent':219 'span.attributes':499 'span.end':240 'span.kind':507 'span.recordexception':227 'span.setattribute':213,216 'span.setstatus':231 'span.spancontext':509 'spankind':466 'spankind.internal':508 'spanprocessor':317,459,477,513 'specif':678 'start':69,114,221,431 'stop':684 'storag':603 'storagedirectori':139 'streamnam':409,438 'string':65,90,138,312,345,379 'substitut':674 'success':696 'support':103 'task':660 'telemetri':606,635 'test':680 'time':423 'toisostr':426 'topic-agent-skills' 'topic-agentic-skills' 'topic-ai-agent-skills' 'topic-ai-agents' 'topic-ai-coding' 'topic-ai-workflows' 'topic-antigravity' 'topic-antigravity-skills' 'topic-claude-code' 'topic-claude-code-skills' 'topic-codex-cli' 'topic-codex-skills' 'total':259 'trace':13,30,150,196,199,293,529 'trace.gettracer':204 'traceflag':467,510 'traceflags.none':511 'tracer':203,207 'tracer.startspan':210 'traffic':617 'treat':669 'tri':212,434 'true':153,155,157,163,166,169,172,175,178 'ts':5 'type':559 'typescript':22,80,121,197,243,295,324,358,393,457,517,541,560 'uploaderror':447 'uploaderror.failedlogs':453 'use':592,623,638,654 'useazuremonitor':75,82,85,123,193,471,512,543,547,562,585 'valid':679 'valu':501 'variabl':61 'void':491,495 'winston':182 'work':223 'worker':215 'workflow':646","prices":[{"id":"d351c746-203a-486b-9a81-04179f070b54","listingId":"8f1e2d75-b50f-4f4c-80c3-c38428999874","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"sickn33","category":"antigravity-awesome-skills","install_from":"skills.sh"},"createdAt":"2026-04-18T21:32:54.251Z"}],"sources":[{"listingId":"8f1e2d75-b50f-4f4c-80c3-c38428999874","source":"github","sourceId":"sickn33/antigravity-awesome-skills/azure-monitor-opentelemetry-ts","sourceUrl":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/azure-monitor-opentelemetry-ts","isPrimary":false,"firstSeenAt":"2026-04-18T21:32:54.251Z","lastSeenAt":"2026-04-24T18:50:32.781Z"}],"details":{"listingId":"8f1e2d75-b50f-4f4c-80c3-c38428999874","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"sickn33","slug":"azure-monitor-opentelemetry-ts","github":{"repo":"sickn33/antigravity-awesome-skills","stars":34928,"topics":["agent-skills","agentic-skills","ai-agent-skills","ai-agents","ai-coding","ai-workflows","antigravity","antigravity-skills","claude-code","claude-code-skills","codex-cli","codex-skills","cursor","cursor-skills","developer-tools","gemini-cli","gemini-skills","kiro","mcp","skill-library"],"license":"mit","html_url":"https://github.com/sickn33/antigravity-awesome-skills","pushed_at":"2026-04-24T06:41:17Z","description":"Installable GitHub library of 1,400+ agentic skills for Claude Code, Cursor, Codex CLI, Gemini CLI, Antigravity, and more. Includes installer CLI, bundles, workflows, and official/community skill collections.","skill_md_sha":"076fc0c9980b07f76078e767aab7b1aa2549db0a","skill_md_path":"skills/azure-monitor-opentelemetry-ts/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/azure-monitor-opentelemetry-ts"},"layout":"multi","source":"github","category":"antigravity-awesome-skills","frontmatter":{"name":"azure-monitor-opentelemetry-ts","description":"Auto-instrument Node.js applications with distributed tracing, metrics, and logs."},"skills_sh_url":"https://skills.sh/sickn33/antigravity-awesome-skills/azure-monitor-opentelemetry-ts"},"updatedAt":"2026-04-24T18:50:32.781Z"}}