{"id":15137797,"url":"https://github.com/grammyjs/opentelemetry","last_synced_at":"2025-03-26T01:31:22.310Z","repository":{"id":179439587,"uuid":"663380431","full_name":"grammyjs/opentelemetry","owner":"grammyjs","description":"Work-in-progress integration with OpenTelemetry for collecting metrics and monitoring bots.","archived":true,"fork":false,"pushed_at":"2024-03-17T15:08:14.000Z","size":36,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-21T00:51:07.108Z","etag":null,"topics":["grammy","open-telemetry","telegram"],"latest_commit_sha":null,"homepage":"https://grammy.dev","language":"TypeScript","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/grammyjs.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}},"created_at":"2023-07-07T07:00:33.000Z","updated_at":"2025-03-17T16:26:39.000Z","dependencies_parsed_at":"2024-03-17T16:24:56.160Z","dependency_job_id":"22dd813b-a2a0-4fdf-9fdc-da3d05a92dee","html_url":"https://github.com/grammyjs/opentelemetry","commit_stats":null,"previous_names":["grammyjs/prometheus","grammyjs/opentelemetry","grammyjs/open-telemetry"],"tags_count":8,"template":false,"template_full_name":"grammyjs/plugin-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grammyjs%2Fopentelemetry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grammyjs%2Fopentelemetry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grammyjs%2Fopentelemetry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grammyjs%2Fopentelemetry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grammyjs","download_url":"https://codeload.github.com/grammyjs/opentelemetry/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245571811,"owners_count":20637403,"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":["grammy","open-telemetry","telegram"],"created_at":"2024-09-26T07:02:06.213Z","updated_at":"2025-03-26T01:31:21.925Z","avatar_url":"https://github.com/grammyjs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grammY OpenTelemetry\n\nIntegrates OpenTelemetry into grammY.\n\nDevelopment is in progress.\n\n## Description\n\nAfter a lot of thought and research, we came to the conclusion that it would be bad to integrate with a particular\ntechnology, especially if it is possible to support many at once. Fortunately, there is the OpenTelemetry project, which\ndefines a single approach to collecting and managing telemetry that integrates perfectly with many existing services.\nHowever, there are some problems with it:\n\n1. The JS toolkit is quite young, so many things are experimental or just under development, which makes it difficult to\n   use.\n2. They split the Web and Node.js tools into separate packages, which will cause support issues in the future.\n3. They are very fond of autoinstrumentation, which intercepts `require/import` calls and patches the requested package,\n   which we think is a very, very bad pattern that we don't want to impose on grammY users.\n\nThis plugin allows you to use OpenTelemetry without those caveats.\n\n## Usage\n\n```ts\nimport { Bot, Context } from \"grammy\";\nimport { getHttpTracer, openTelemetryTransformer } from \"@grammyjs/opentelemetry\";\n\nconst bot = new Bot\u003cContext\u003e(\"token\");\n\nbot.api.config.use(openTelemetryTransformer(getHttpTracer(\"my-bot\")));\n\nbot.command(\"start\", (ctx) =\u003e {\n  // Creates a new span tied to the span of the current update.\n  return ctx.openTelemetry.trace(\n    // span name\n    \"command.start\",\n    // span attributes\n    { [\"user.id\"]: ctx.from?.id },\n    // span actions\n    async (span) =\u003e {\n      span.addEvent(\"command.start.handle\");\n      await ctx.reply(\"Hello! I'm a bot!\");\n      await ctx.reply(\"I can help you with a lot of things!\");\n    },\n  );\n});\n\nbot.command(\n  \"ping\",\n  // Wraps the handler in a span with the given name, tied to the span of the current update.\n  // Shortcut for `ctx.openTelemetry.trace(\"command.ping\", ...)`.\n  traced(\"command.ping\", async (ctx) =\u003e {\n    await new Promise((resolve) =\u003e setTimeout(resolve, 1000));\n    await ctx.reply(\"Pong!\");\n  }),\n);\n\nbot.start();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrammyjs%2Fopentelemetry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrammyjs%2Fopentelemetry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrammyjs%2Fopentelemetry/lists"}