{"id":21056950,"url":"https://github.com/fluent-plugins-nursery/fluent-plugin-measure_time","last_synced_at":"2025-05-15T23:33:34.555Z","repository":{"id":15747347,"uuid":"18486032","full_name":"fluent-plugins-nursery/fluent-plugin-measure_time","owner":"fluent-plugins-nursery","description":"Fluentd plugin to measure elapsed time to process messages","archived":false,"fork":false,"pushed_at":"2016-05-20T13:29:36.000Z","size":39,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-13T20:15:12.525Z","etag":null,"topics":["fluentd-output-plugin","fluentd-plugin","to-do-v14","v10","v12"],"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/fluent-plugins-nursery.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}},"created_at":"2014-04-06T09:05:00.000Z","updated_at":"2023-04-04T08:23:03.000Z","dependencies_parsed_at":"2022-09-09T01:00:49.582Z","dependency_job_id":null,"html_url":"https://github.com/fluent-plugins-nursery/fluent-plugin-measure_time","commit_stats":null,"previous_names":["sonots/fluent-mixin-elapsed_time","sonots/fluent-plugin-measure_time"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent-plugins-nursery%2Ffluent-plugin-measure_time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent-plugins-nursery%2Ffluent-plugin-measure_time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent-plugins-nursery%2Ffluent-plugin-measure_time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluent-plugins-nursery%2Ffluent-plugin-measure_time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluent-plugins-nursery","download_url":"https://codeload.github.com/fluent-plugins-nursery/fluent-plugin-measure_time/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442429,"owners_count":22071864,"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":["fluentd-output-plugin","fluentd-plugin","to-do-v14","v10","v12"],"created_at":"2024-11-19T16:55:13.902Z","updated_at":"2025-05-15T23:33:29.512Z","avatar_url":"https://github.com/fluent-plugins-nursery.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fluent-plugin-measure_time\n\n[![Build Status](https://secure.travis-ci.org/sonots/fluent-plugin-measure_time.png?branch=master)](http://travis-ci.org/sonots/fluent-plugin-measure_time)\n[![Code Climate](https://codeclimate.com/github/sonots/fluent-plugin-measure_time.png)](https://codeclimate.com/github/sonots/fluent-plugin-measure_time)\n\nFluentd plugin to measure elapsed time to process messages\n\n\n## Installation\n\nUse RubyGems:\n\n    gem install fluent-plugin-measure_time\n\n## Parameters\n\n* tag\n\n    The output tag name. Default is `measure_time`\n\n* hook (required)\n\n    Specify the method to measure time.\n\n* interval\n\n    The time interval to emit measurement results. Default is nil which do not compute statistics and emit the time in each measurement.\n\n## Configuration Example 1 - Profile an Output Plugin\n\nAs an example, let's profile how long the [emit](https://github.com/sonots/fluent-plugin-grep/blob/master/lib/fluent/plugin/out_grep.rb#L56) method of [fluent-plugin-grep](https://github.com/sonots/fluent-plugin-grep) is taking.\nConfigure fluentd.conf as below:\n\nFor Fluentd v0.10:\n\n```apache\n\u003csource\u003e\n  type measure_time\n  # This makes available the `measure_time` directive for all plugins\n\u003c/source\u003e\n\n\u003csource\u003e\n  type forward\n  port 24224\n\u003c/source\u003e\n\n# measure_time plugin output comes here\n\u003cmatch measure_time\u003e\n  type stdout\n\u003c/match\u003e\n\n# Whatever you want to do\n\u003cmatch greped.**\u003e\n  type stdout\n\u003c/match\u003e\n\n\u003cmatch **\u003e\n  type grep\n  add_tag_prefix greped\n  \u003cmeasure_time\u003e\n    tag measure_time\n    hook emit\n  \u003c/measure_time\u003e\n\u003c/match\u003e\n```\n\nFor Fluentd v0.12:\n\n```apache\n\u003clabel @measure_time\u003e\n  \u003cmatch\u003e\n    @type measure_time\n    # This makes available the `measure_time` directive for all plugins\n  \u003c/match\u003e\n\u003c/label\u003e\n\n\u003csource\u003e\n  @type dummy\n  tag raw.dummy\n  dummy {\"message\":\"foo\"}\n\u003c/source\u003e\n\n# measure_time plugin output comes here\n\u003cmatch measure_time\u003e\n  @type stdout\n\u003c/match\u003e\n\n# Whatever you want to do\n\u003cmatch greped.**\u003e\n  @type stdout\n\u003c/match\u003e\n\n\u003cmatch **\u003e\n  @type grep\n  add_tag_prefix greped\n  \u003cmeasure_time\u003e\n    tag measure_time\n    hook emit\n  \u003c/measure_time\u003e\n\u003c/match\u003e\n```\n\nThe output of fluent-plugin-measure_time will be as below:\n\n```\nmeasure_time: {\"time\":0.000849735,\"class\":\"Fluent::GrepOutput\",\"hook\":\"emit\",\"object_id\":83935080}\n```\n\nwhere `time` denotes the measured elapsed time, and `class`, `hook`, and `object_id` denotes the hooked class, the hooked method, and the object id of the plugin instance.\n\n### interval option\n\nfluent-plugin-measure_time outputs the elapsed time for each calling, but you can use the `interval` option when you want to get statistics in each interval.\n\n```\nmeasure_time: {\"max\":1.011,\"avg\":0.002\",\"num\":10,\"class\":\"Fluent::GrepOutput\",\"hook\":\"emit\",\"object_id\":83935080}\n```\n\nwhere `max` and `avg` are the maximum and average elapsed times, and `num` is the number of being called in each interval.\n\n## Configuration Example (2) - Profile the in_forward plugin\n\nI introduce an interesting example here.\n\nFollowing illustration draws the sequence of that `in_forward` plugin receives a data, processes, and passes the data to output plugins.\n\n*Sequence Diagram*\n\n```\n     +–––––––––––––+    +––––––––––––––+   +––––––––––––––+\n     |  in_forwrd  |    |   Output     |   |   Output     |\n     +––––––+––––––+    +––––––+–––––––+   +––––––+–––––––+\n#on_message | start = Time.now |                  |\n            +––––––––––––––––––\u003e                  |\n            |      #emit       |                  |\n            |                  +––––––––––––––––––\u003e\n            |                  |      #emit       |\n            |                  |                  |\n            |                  |                  |\n            |                  \u003c– – – – – – – – – +\n            | elapsed = Time.now - start          |\n            \u003c– – – – – - – – – +                  |\n            |                  |                  |\n            +                  +                  +\n```\n\nAs the illustration, by hooking `on_message` method of `in_forward` plugin,\nwe can measure the blocking time taking to process the received data,\nwhich also means that the time taking until `in_forward` will be ready for receiving a next data.\n\nThis profiling is very useful to investigate when you have a suspicion that throughputs of Fluentd fell down extremely.\n\nThe configuration will be as follows:\n\nFor Fluentd v0.10:\n\n```apache\n\u003csource\u003e\n  type measure_time\n  # This makes available the `measure_time` directive for all plugins\n\u003c/source\u003e\n\n\u003csource\u003e\n  type forward\n  port 24224\n  \u003cmeasure_time\u003e\n    tag measure_time\n    hook on_message\n  \u003c/measure_time\u003e\n\u003c/source\u003e\n\n\u003cmatch measure_time\u003e\n  type stdout\n\u003c/match\u003e\n\n# whatever you want\n\u003cmatch **\u003e\n  type stdout\n\u003c/match\u003e\n```\n\nFor Fluentd v0.12:\n\n```apache\n\u003clabel @measure_time\u003e\n  \u003cmatch\u003e\n    @type measure_time\n    # This makes available the `measure_time` directive for all plugins\n  \u003c/match\u003e\n\u003c/match\u003e\n\n\u003csource\u003e\n  @type forward\n  port 24224\n  \u003cmeasure_time\u003e\n    tag measure_time\n    hook on_message\n  \u003c/measure_time\u003e\n\u003c/source\u003e\n\n\u003cmatch measure_time\u003e\n  @type stdout\n\u003c/match\u003e\n\n# whatever you want\n\u003cmatch **\u003e\n  @type stdout\n\u003c/match\u003e\n```\n\nOutput becomes as below:\n\n```\nmeasure_time: {\"time\":0.000849735,\"class\":\"Fluent::ForwardInput\",\"hook\":\"on_message\",\"object_id\":83935080}\n```\n\n## ChangeLog\n\nSee [CHANGELOG.md](CHANGELOG.md) for details.\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new [Pull Request](../../pull/new/master)\n\n## Copyright\n\nCopyright (c) 2014 Naotoshi Seo. See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluent-plugins-nursery%2Ffluent-plugin-measure_time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluent-plugins-nursery%2Ffluent-plugin-measure_time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluent-plugins-nursery%2Ffluent-plugin-measure_time/lists"}