{"id":13682607,"url":"https://github.com/uniiverse/apollo-tracing-ruby","last_synced_at":"2025-10-09T04:19:43.550Z","repository":{"id":54454909,"uuid":"101417540","full_name":"uniiverse/apollo-tracing-ruby","owner":"uniiverse","description":"[Maintainers Wanted] Ruby implementation of GraphQL trace data in the Apollo Tracing format","archived":false,"fork":false,"pushed_at":"2023-06-11T03:40:35.000Z","size":49,"stargazers_count":84,"open_issues_count":5,"forks_count":10,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-09T04:19:43.221Z","etag":null,"topics":["apollo-engine","apollo-tracing","graphql","graphql-ruby","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/uniiverse.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-08-25T15:31:40.000Z","updated_at":"2024-12-10T06:43:29.000Z","dependencies_parsed_at":"2023-07-14T11:07:43.678Z","dependency_job_id":null,"html_url":"https://github.com/uniiverse/apollo-tracing-ruby","commit_stats":{"total_commits":32,"total_committers":6,"mean_commits":5.333333333333333,"dds":0.46875,"last_synced_commit":"4fbcc0af15a72b5bd265d984ff44e400307d1469"},"previous_names":["uniiverse/graphql-tracing"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/uniiverse/apollo-tracing-ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uniiverse%2Fapollo-tracing-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uniiverse%2Fapollo-tracing-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uniiverse%2Fapollo-tracing-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uniiverse%2Fapollo-tracing-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uniiverse","download_url":"https://codeload.github.com/uniiverse/apollo-tracing-ruby/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uniiverse%2Fapollo-tracing-ruby/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000757,"owners_count":26082921,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"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":["apollo-engine","apollo-tracing","graphql","graphql-ruby","ruby"],"created_at":"2024-08-02T13:01:49.570Z","updated_at":"2025-10-09T04:19:43.510Z","avatar_url":"https://github.com/uniiverse.png","language":"Ruby","readme":"# Apollo Tracing\n\n[![Build Status](https://travis-ci.org/uniiverse/apollo-tracing-ruby.svg?branch=master)](https://travis-ci.org/uniiverse/apollo-tracing-ruby)\n[![Latest Version](https://img.shields.io/gem/v/apollo-tracing.svg)](https://rubygems.org/gems/apollo-tracing)\n\nRuby implementation of [GraphQL](https://github.com/rmosolgo/graphql-ruby) trace data in the [Apollo Tracing](https://github.com/apollographql/apollo-tracing) format.\n\n\n## Contents\n\n* [Installation](#installation)\n* [Usage](#usage)\n  * [Tracing](#tracing)\n  * [Engine Proxy](#engine-proxy)\n* [Development](#development)\n* [Contributing](#contributing)\n* [License](#license)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'apollo-tracing'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install apollo-tracing\n\n## Usage\n\nDefine a GraphQL schema:\n\n```ruby\n# Define a type\nPostType = GraphQL::ObjectType.define do\n  name \"Post\"\n\n  field :id, !types.ID\n  field :title, !types.String\nend\n\n# Define a query\nQueryType = GraphQL::ObjectType.define do\n  name \"Query\"\n\n  field :posts, !types[PostType] do\n    argument :user_id, !types.ID\n    resolve -\u003e(obj, args, ctx) { Post.where(user_id: args[:user_id]) }\n  end\nend\n\n# Define a schema\nSchema = GraphQL::Schema.define do\n  query QueryType\nend\n\n# Execute query\nquery = \"\n  query($user_id: ID!) {\n    posts(user_id: $user_id) {\n      id\n      title\n    }\n  }\n\"\nSchema.execute(query, variables: { user_id: 1 })\n```\n\n### Tracing\n\nAdd 'ApolloTracing' to your schema:\n\n\u003cpre\u003e\n\u003cb\u003erequire \"apollo/tracing\"\u003c/b\u003e\n\nSchema = GraphQL::Schema.define do\n  query QueryType\n  \u003cb\u003euse ApolloTracing.new\u003c/b\u003e\nend\n\u003c/pre\u003e\n\nNow your response should look something like:\n```\n{\n   \"data\":{\n      \"posts\":[\n         {\n            \"id\":\"1\",\n            \"title\":\"Post Title\"\n         }\n      ]\n   },\n   \"extensions\":{\n      \"tracing\":{\n         \"version\":1,\n         \"startTime\":\"2017-08-25T19:55:04.821Z\",\n         \"endTime\":\"2017-08-25T19:55:04.823Z\",\n         \"duration\":1702785,\n         \"execution\":{\n            \"resolvers\":[\n               {\n                  \"path\":[\n                     \"posts\"\n                  ],\n                  \"parentType\":\"Query\",\n                  \"fieldName\":\"posts\",\n                  \"returnType\":\"[Post!]!\",\n                  \"startOffset\":1451015,\n                  \"duration\":15735\n               },\n               {\n                  \"path\":[\n                     \"posts\",\n                     0,\n                     \"id\"\n                  ],\n                  \"parentType\":\"Post\",\n                  \"fieldName\":\"id\",\n                  \"returnType\":\"ID!\",\n                  \"startOffset\":1556873,\n                  \"duration\":6914\n               },\n               {\n                  \"path\":[\n                     \"posts\",\n                     0,\n                     \"title\"\n                  ],\n                  \"parentType\":\"Post\",\n                  \"fieldName\":\"title\",\n                  \"returnType\":\"String!\",\n                  \"startOffset\":1604795,\n                  \"duration\":4053\n               },\n               {\n                  \"path\":[\n                     \"posts\",\n                     0,\n                     \"user_id\"\n                  ],\n                  \"parentType\":\"Post\",\n                  \"fieldName\":\"user_id\",\n                  \"returnType\":\"ID!\",\n                  \"startOffset\":1642942,\n                  \"duration\":3814\n               }\n            ]\n         }\n      }\n   }\n}\n```\n\n### Engine Proxy\n\nNow you can start using the [Apollo Engine](https://www.apollographql.com/engine/) service.\nHere is the general architecture overview of a sidecar mode – Proxy runs next to your application server:\n\n```\n -----------------    request     -----------------    request     -----------------\n|                 | -----------\u003e |                 | -----------\u003e |                 |\n|     Client      |              |  Engine Proxy   |              |   Application   |\n|                 | \u003c----------- |                 | \u003c----------- |                 |\n -----------------    response    -----------------    response    -----------------\n                                          |\n                                          |\n                          GraphQL tracing | from response\n                                          |\n                                          ˅\n                                  -----------------\n                                 |                 |\n                                 |  Apollo Engine  |\n                                 |                 |\n                                  -----------------\n```\n\n`ApolloTracing` gem comes with the [Apollo Engine Proxy](https://www.apollographql.com/docs/engine/index.html#engine-proxy) binary written in Go.\nTo configure the Proxy create a Proxy config file:\n\n```\n# config/apollo-engine-proxy.json\n\n{\n  \"apiKey\": \"service:YOUR_ENGINE_API_KEY\",\n  \"logging\": { \"level\": \"INFO\" },\n  \"origins\": [{\n    \"http\": { \"url\": \"http://localhost:3000/graphql\" }\n  }],\n  \"frontends\": [{\n    \"host\": \"localhost\", \"port\": 3001, \"endpoints\": [\"/graphql\"]\n  }]\n}\n```\n\n* `apiKey` – get this on your [Apollo Engine](https://engine.apollographql.com/) home page.\n* `logging.level` – a log level for the Proxy (\"INFO\", \"DEBUG\" or \"ERROR\").\n* `origins` – a list of URLs with your GraphQL endpoints in the Application.\n* `frontends` – an address on which the Proxy will be listening.\n\nTo run the Proxy as a child process, which will be automatically terminated if the Application proccess stoped, add the following line to the `config.ru` file:\n\n\u003cpre\u003e\n# config.ru – this file is used by Rack-based servers to start the application\nrequire File.expand_path('../config/environment',  __FILE__)\n\n\u003cb\u003eApolloTracing.start_proxy('config/apollo-engine-proxy.json')\u003c/b\u003e\n# or pass a JSON string:\n# ApolloTracing.start_proxy('{\"apiKey\": \"KEY\", ...}')\n\nrun Your::Application\n\u003c/pre\u003e\n\nFor example, if you use [rails](https://github.com/rails/rails) with [puma](https://github.com/puma/puma) application server and run it like:\n\n```\nbundle exec puma -w 2 -t 16 -p 3000\n```\n\nThe proccess tree may look like:\n\n```\n                ---------------\n               |  Puma Master  |\n               |   Port 3000   |\n                ---------------\n                   |      |\n         ----------        ----------\n        |                            |    ----------------\n        ˅                             -\u003e |  Puma Worker1  |\n ----------------                    |    -----------------\n|  Engine Proxy  |                   |    ----------------\n|   Port 3001    |                    -\u003e |  Puma Worker2  |\n ----------------                         ----------------\n```\n\nNow you can send requests to the reverse Proxy `http://localhost:3001`.\nIt'll proxy any (GraphQL and non-GraphQL) requests to the Application `http://localhost:3000`.\nIf the request matches the endpoints described in `origins`, it'll strip the `tracing` data from the response and will send it to the Apollo Engine service.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/uniiverse/apollo-tracing-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funiiverse%2Fapollo-tracing-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funiiverse%2Fapollo-tracing-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funiiverse%2Fapollo-tracing-ruby/lists"}