{"id":34201042,"url":"https://github.com/cmd-stream/otelcmd-stream-go","last_synced_at":"2026-05-05T05:02:04.547Z","repository":{"id":297046286,"uuid":"995464802","full_name":"cmd-stream/otelcmd-stream-go","owner":"cmd-stream","description":"OpenTelemetry instrumentation for cmd-stream","archived":false,"fork":false,"pushed_at":"2026-05-01T17:44:56.000Z","size":78,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-01T19:28:55.951Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cmd-stream.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-03T14:18:03.000Z","updated_at":"2026-05-01T17:45:00.000Z","dependencies_parsed_at":"2025-06-04T01:08:57.293Z","dependency_job_id":"0f5bc81a-c0c0-41ba-9c83-85b0ce48b576","html_url":"https://github.com/cmd-stream/otelcmd-stream-go","commit_stats":null,"previous_names":["cmd-stream/otelcmd-stream-go"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/cmd-stream/otelcmd-stream-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmd-stream%2Fotelcmd-stream-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmd-stream%2Fotelcmd-stream-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmd-stream%2Fotelcmd-stream-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmd-stream%2Fotelcmd-stream-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmd-stream","download_url":"https://codeload.github.com/cmd-stream/otelcmd-stream-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmd-stream%2Fotelcmd-stream-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32636108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"online","status_checked_at":"2026-05-05T02:00:06.033Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-15T18:28:15.418Z","updated_at":"2026-05-05T05:02:04.540Z","avatar_url":"https://github.com/cmd-stream.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# otelcmd-stream: OpenTelemetry for cmd-stream\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/cmd-stream/otelcmd-stream-go.svg)](https://pkg.go.dev/github.com/cmd-stream/otelcmd-stream-go)\n[![GoReportCard](https://goreportcard.com/badge/cmd-stream/otelcmd-stream-go)](https://goreportcard.com/report/github.com/cmd-stream/otelcmd-stream-go)\n[![codecov](https://codecov.io/gh/cmd-stream/otelcmd-stream-go/graph/badge.svg?token=04UEO65CLJ)](https://codecov.io/gh/cmd-stream/otelcmd-stream-go)\n\n## Table of Contents\n\n- [otelcmd-stream: OpenTelemetry for cmd-stream](#otelcmd-stream-opentelemetry-for-cmd-stream)\n  - [Table of Contents](#table-of-contents)\n  - [Features](#features)\n  - [Installation](#installation)\n  - [Usage](#usage)\n    - [Sender](#sender)\n    - [Server Instrumentation](#server-instrumentation)\n    - [Traceable Commands](#traceable-commands)\n\n## Features\n\n- Automated Tracing: Automatically creates spans for Command transmission and\n  execution.\n- Built-in Metrics: Reports execution counts, durations, and success/failure\n  statuses out of the box.\n- Context Propagation: Transparently carries trace context across the network \n  via the `TraceCmd` wrapper.\n- Extensible Hooks: Inject business-specific attributes and events into spans \n  and metrics.\n\n## Installation\n\n```bash\ngo get github.com/cmd-stream/otelcmd-stream-go\n```\n\n## Usage\n\n1. Instrument the sender.\n2. Instrument the server.\n3. Use `TraceCmd` for context propagation.\n\n### Sender\n\nInstrument the sender with `otelcmd.NewHooksFactory`:\n\n```go\nimport (\n  \"net\"\n  otelcmd \"github.com/cmd-stream/otelcmd-stream-go\"\n  cmdstream \"github.com/cmd-stream/cmd-stream-go\"\n  sndr \"github.com/cmd-stream/cmd-stream-go/sender\"\n)\n\nvar (\n  serverAddr net.Addr = ...\n  codec = ...\n\n  // Create OpenTelemetry hooks factory with optional customization.\n  hooksFactory = otelcmd.NewHooksFactory[T](\n    otelcmd.WithServerAddr[T](serverAddr),\n    // Other available options:\n    // otelcmd.WithPropagator[T](...),\n    // otelcmd.WithTracerProvider[T](...),\n    // otelcmd.WithMeterProvider[T](...),\n    // otelcmd.WithSpanAttributesFn[T](...),\n  )\n\n  // Initialize the high-level sender with instrumentation.\n  sender, err = cmdstream.NewSender[T](serverAddr.String(), codec,\n    sndr.WithSender[T](sndr.WithHooksFactory[T](hooksFactory)),\n  )\n)\n```\n\nYou can also use a Circuit Breaker:\n\n```go\nimport (\n  \"github.com/ymz-ncnk/circbrk-go\"\n  otelcmd \"github.com/cmd-stream/otelcmd-stream-go\"\n  cmdstream \"github.com/cmd-stream/cmd-stream-go\"\n  sndr \"github.com/cmd-stream/cmd-stream-go/sender\"\n  hks \"github.com/cmd-stream/cmd-stream-go/sender/hooks\"\n)\n\nvar (\n  // 1. Create a circuit breaker.\n  cb = circbrk.New(\n    circbrk.WithWindowSize(...),\n    circbrk.WithFailureRate(...),\n    circbrk.WithOpenDuration(...),\n    circbrk.WithSuccessThreshold(...),\n  )\n\n  // 2. Create the OTel hooks factory.\n  otelHooksFactory = otelcmd.NewHooksFactory[T](\n    otelcmd.WithServerAddr[T](serverAddr))\n\n  // 3. Compose them together.\n  hooksFactory = hks.NewCircuitBreakerHooksFactory[T](cb, otelHooksFactory)\n\n  // 4. Initialize the sender with the combined hooks.\n  sender, err = cmdstream.NewSender[T](serverAddr.String(), codec,\n    sndr.WithSender[T](sndr.WithHooksFactory[T](hooksFactory)),\n  )\n)\n```\n\n### Server Instrumentation\n\nWrap your invoker with `otelcmd.NewInvoker`:\n\n```go\nimport (\n  srv \"github.com/cmd-stream/cmd-stream-go/server\"\n  otelcmd \"github.com/cmd-stream/otelcmd-stream-go\"\n  cmdstream \"github.com/cmd-stream/cmd-stream-go\"\n)\n\nvar (\n  // Initialize your invoker and wrap it with OpenTelemetry support.\n  invoker = otelcmd.NewInvoker[T](\n    srv.NewInvoker[T](receiver),\n    otelcmd.WithServerAddr[T](serverAddr),\n    // Other available options:\n    // otelcmd.WithPropagator[T](...),\n    // otelcmd.WithTracerProvider[T](...),\n    // otelcmd.WithMeterProvider[T](...),\n  )\n  server, err = cmdstream.NewServerWithInvoker[T](invoker, codec, ...)\n)\n```\n\n### Traceable Commands\n\n`TraceCmd` carries the span context across the network. Define a traceable type \nwhich is used to generate the `core.Cmd` serializer:\n\n```go\ntype YourTraceCmd = otelcmd.TraceCmd[YourReceiver, YourCmd]\n```\n\nUse `otelcmd.NewTraceCmd` to wrap your Commands:\n\n```go\nimport (\n  otelcmd \"github.com/cmd-stream/otelcmd-stream-go\"\n)\n\nvar (\n  ctx = ...\n  cmd YourTraceCmd = otelcmd.NewTraceCmd[YourReceiver, YourCmd](YourCmd{})\n)\nresult, err := sender.Send(ctx, cmd)\n```\n\nA full working example is available [here](https://github.com/cmd-stream/examples-go/tree/main/otel).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmd-stream%2Fotelcmd-stream-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmd-stream%2Fotelcmd-stream-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmd-stream%2Fotelcmd-stream-go/lists"}