{"id":16612879,"url":"https://github.com/ttys3/echo-otel-metrics","last_synced_at":"2026-01-05T04:50:15.994Z","repository":{"id":61679672,"uuid":"553309523","full_name":"ttys3/echo-otel-metrics","owner":"ttys3","description":"go labstack/echo opentelemetry metrics middleware","archived":false,"fork":false,"pushed_at":"2025-01-21T03:04:53.000Z","size":162,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-21T03:27:01.583Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ttys3.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2022-10-18T02:54:30.000Z","updated_at":"2025-01-21T03:04:50.000Z","dependencies_parsed_at":"2024-04-22T21:30:28.504Z","dependency_job_id":"89505a8f-b343-4fe9-8c61-99acba2ccc30","html_url":"https://github.com/ttys3/echo-otel-metrics","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttys3%2Fecho-otel-metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttys3%2Fecho-otel-metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttys3%2Fecho-otel-metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ttys3%2Fecho-otel-metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ttys3","download_url":"https://codeload.github.com/ttys3/echo-otel-metrics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244966522,"owners_count":20539797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-10-12T01:45:14.547Z","updated_at":"2026-01-05T04:50:15.969Z","avatar_url":"https://github.com/ttys3.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# echo-otel-metrics\n\nthis is an opentelemetry metrics middleware for echo http framework.\n\nit addd a custom opentelemetry metrics middleware `otelmetric` to echo framework, and setup a prometheus exporter endpoint at `/metrics`.\n\nthis `otelmetric` middleware can work as a replacement for\n\n`https://github.com/labstack/echo-contrib/tree/master/echoprometheus`\n\nor the legacy \n`https://github.com/labstack/echo-contrib/tree/master/prometheus`\n\nas of this module get v0.3.0 (otel metric v1.16.0), the metrics component is stable now, so this middleware is stable too.\n\nbut the metrics name diffs.\n\n**counter**\n\n```\nrequests_total\n```\n\n\n**histogram**\n\nref https://opentelemetry.io/docs/specs/semconv/http/http-metrics/\n\n```\nrequest_duration_seconds{_bucket, _sum, _count}\n\nrequest_size_bytes{_bucket, _sum, _count}\n\nresponse_size_bytes{_bucket, _sum, _count}\n```\n\necho's middleware result:\n\n```\nrequest_duration_seconds_bucket{code=\"200\",host=\"example.com\",method=\"GET\",url=\"/\",le=\"0.005\"}\n```\n\nbut this one result:\n\n```\nrequest_duration_milliseconds_bucket{code=\"200\",method=\"GET\",otel_scope_name=\"echo\",otel_scope_version=\"\",url=\"/\",le=\"5\"}\n```\n\nand otel metric exporter also add an `target_info` **gauge** looks like:\n\n```\ntarget_info{service_name=\"otelmetric-demo\",telemetry_sdk_language=\"go\",telemetry_sdk_name=\"opentelemetry\",telemetry_sdk_version=\"1.16.0\"} 1\n```\n\n------------------------------------\n\nThe `echoprometheus` middleware registers the following metrics by default:\n\n* Counter `requests_total`\n* Histogram `request_duration_seconds`\n* Histogram `response_size_bytes`\n* Histogram `request_size_bytes`\n\nhistogram will have `_bucket`, `_sum`, `_count` suffix.\n------------------------------------\n\n## warning\n\nstatus https://opentelemetry.io/docs/instrumentation/go/\n\nthe Metrics component for OpenTelemetry Go is **Stable** now!\n\nsee https://github.com/open-telemetry/opentelemetry-go/releases/tag/v1.16.0\n\n## prometheus related\n\n### Unit `1`\n\nhttps://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/compatibility/prometheus_and_openmetrics.md#metric-metadata-1\n\n\u003e The Unit of an OTLP metric point SHOULD be converted to the equivalent unit in Prometheus when possible. This includes:\n\u003e * Special case: Converting \"1\" to \"ratio\".\n\nhttps://github.com/open-telemetry/opentelemetry-collector-contrib/issues/10554\nMetrics about offset should use an empty unit.\nUnit `1` must be used only for fractions and ratios.\n\nhttps://github.com/open-telemetry/opentelemetry-specification/blob/ce360a26894271fa9a2b0c846a78d97d277e4183/specification/metrics/semantic_conventions/README.md#instrument-units\n\n\u003e Instrument Units\n\u003e \n\u003e Units should follow the\n\u003e [Unified Code for Units of Measure](http://unitsofmeasure.org/ucum.html).\n\u003e \n\u003e - Instruments for **utilization** metrics (that measure the fraction out of a\n\u003e   total) are dimensionless and SHOULD use the default unit `1` (the unity).\n\u003e - All non-units that use curly braces to annotate a quantity need to match the\n\u003e   grammatical number of the quantity it represent. For example if measuring the\n\u003e   number of individual requests to a process the unit would be `{request}`, not\n\u003e   `{requests}`.\n\u003e - Instruments that measure an integer count of something SHOULD only use\n\u003e   [annotations](https://ucum.org/ucum.html#para-curly) with curly braces to\n\u003e   give additional meaning *without* the leading default unit (`1`). For example,\n\u003e   use `{packet}`, `{error}`, `{fault}`, etc.\n\u003e - Instrument units other than `1` and those that use\n\u003e   [annotations](https://ucum.org/ucum.html#para-curly) SHOULD be specified using\n\u003e   the UCUM case sensitive (\"c/s\") variant.\n\u003e   For example, \"Cel\" for the unit with full name \"degree Celsius\".\n\u003e - Instruments SHOULD use non-prefixed units (i.e. `By` instead of `MiBy`)\n\u003e   unless there is good technical reason to not do so.\n\u003e - When instruments are measuring durations, seconds (i.e. `s`) SHOULD be used.\n\u003e\n\nhttps://github.com/open-telemetry/opentelemetry-collector-contrib/blob/8f394d4ffea8d5f06a9019245746ff253be106fd/pkg/translator/prometheus/normalize_name.go#L155-L162\n\nMetric name normalization\n\nhttps://github.com/open-telemetry/opentelemetry-collector-contrib/blob/8f394d4ffea8d5f06a9019245746ff253be106fd/pkg/translator/prometheus/README.md#full-normalization\n\nhttps://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/translator/prometheus/README.md#full-normalization\n\n## docs\n\nthe implementation ref to https://github.com/labstack/echo-contrib/blob/master/prometheus/prometheus.go\n\nhttps://uptrace.dev/opentelemetry/go-metrics.html\n\nhttps://uptrace.dev/opentelemetry/prometheus-metrics.html#sending-go-metrics-to-prometheus\n\nhttps://opentelemetry.io/docs/reference/specification/metrics/sdk/\n\nhttps://echo.labstack.com/cookbook/hello-world/\n\nsemconv\n\nhttps://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#document-conventions\nhttps://github.com/open-telemetry/opentelemetry-go/blob/main/semconv/v1.12.0/resource.go\n\nhttp server\n\nhttps://opentelemetry.io/docs/specs/semconv/attributes-registry/server/\n\nhttps://opentelemetry.io/docs/specs/semconv/http/http-metrics/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttys3%2Fecho-otel-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fttys3%2Fecho-otel-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fttys3%2Fecho-otel-metrics/lists"}