{"id":13700062,"url":"https://github.com/chuan-yun/Molten","last_synced_at":"2025-05-04T18:34:07.892Z","repository":{"id":43702832,"uuid":"96163089","full_name":"chuan-yun/Molten","owner":"chuan-yun","description":"php probe for zipkin and opentracing","archived":false,"fork":false,"pushed_at":"2021-05-27T09:11:49.000Z","size":288,"stargazers_count":793,"open_issues_count":56,"forks_count":160,"subscribers_count":45,"default_branch":"master","last_synced_at":"2024-11-13T06:32:58.132Z","etag":null,"topics":["apm","instrumentation","lucency","opentracing","php","probe","trace","tracing","transparent","zipkin"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chuan-yun.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.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":"2017-07-04T01:26:11.000Z","updated_at":"2024-10-04T08:11:23.000Z","dependencies_parsed_at":"2022-07-07T18:30:32.961Z","dependency_job_id":null,"html_url":"https://github.com/chuan-yun/Molten","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chuan-yun%2FMolten","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chuan-yun%2FMolten/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chuan-yun%2FMolten/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chuan-yun%2FMolten/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chuan-yun","download_url":"https://codeload.github.com/chuan-yun/Molten/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252382865,"owners_count":21739231,"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":["apm","instrumentation","lucency","opentracing","php","probe","trace","tracing","transparent","zipkin"],"created_at":"2024-08-02T20:00:47.952Z","updated_at":"2025-05-04T18:34:03.594Z","avatar_url":"https://github.com/chuan-yun.png","language":"C","funding_links":[],"categories":["代码分析","调试和性能( Debugging and Profiling )"],"sub_categories":[],"readme":"# molten\n\n\u003e Readme in [Chinese 中文](https://github.com/chuan-yun/Molten/blob/master/README_ZH.md)\n\n[![Build Status](https://travis-ci.org/chuan-yun/Molten.svg?branch=master)](https://travis-ci.org/chuan-yun/Molten)\n\nmolten is transparency tool for application tracing it self module call.\n\nIt trace php app core call and output zipkin/opentracing format trace log. \n\nProvides features about muliti trace sapi, multi sampling type, upload tracing \nstatus, module control and muliti sink type.\n\nIt very easy to build a [distributed systems tracing infrastructure](https://research.google.com/pubs/pub36356.html) \nbase on php, already run on thousand instance on production env.\n\n# Table of contents\n----\n1. [Installing](#install)\n2. [QuickStart](#quickstart)\n3. [Configure](#configure)\n4. [Function](#function)\n5. [Verify](#verify)\n6. [Features](#features)\n7. [Contributing](#contributing)\n8. [License](#license)\n\n# Installing\n\nEverything you should need to install molten on your system.\n\n~~~\nphpize\n./configure\nmake \u0026\u0026 make install\n~~~\n\n`make install` copies `molten.so` to and appropriate location, but you still need to enable the module int the PHP config file, To do so, either edit your php.ini or add ad molten.ini file in `/etc/php5/conf.d` with the following contents:`extension=molten.so`.\n\nat `./configure` phase, you can also add `--enable-zipkin-header=yes` to support zipkin B3 header.\n\nif you want molten support `POST` method , at the compile phase you should check `libcurl-devel` is installed.\n\n# QuickStart\n\n~~~\ncd example\nsh run.sh\n~~~\nopen `http://127.0.0.1:9411/zipkin/` in your browser, you can see the tracing detail in it.\n\nif you think above is too simple, you also can do this.\n\n~~~\ncd example\nsh complex.sh\n~~~\nit is cool, alright?\n\n`NOTICE` if you not see the trace, you select EndTime +1 hour.\n\n# Configure\n## Base Config\n\n`molten.enable` set 1 enable or set 0 disable, default `1`.\n\n`molten.service_name` is to set service name for label app service name. now we support add `ini_set('molten.service_name', 'YOUR_PROJECT_NAME'); ` to code to trace different projects using same php enveroment.\n\n`molten.tracing_cli` set `1` to trace, cli sapi, `0` not trace, just use for trace unit test, default `0`.\n\n`molten.open_report` set `1` to open report php error, default `0`.\n\n## Sampling Config\n\n`molten.sampling_type` sampling type choose to use sampling by rate(`1`) or request(`2`), default is `1`.\n\n`molten.sampling_request` sampling by request, set to per min request num, defualt is `1000`.\n\n`molten.sampling_rate` determine a request sampled or not by rate, default is `64`.\n\n## Control Config\n\n`molten.notify_uri` the uri for molten to notify manger.\n\n## Report Config\n\nreport module output type is same as sink module\n\n`molten.report_interval` reporter call interval, default `60`.\n\n`molten.report_limit`  reporter list limit current only for error num, default `100`.\n\n## Sink Config\n\n`molten.sink_type` sink type, `1` write log, log path is depend on `molten.sink_log_path`, `2` write log to standand output, `3` write log to syslog, `4` use curl to send trace log, http uri depend on `molten.sink_http_uri`.\n\n`molten.output_type`  output spans on one line(`1`) or one line one span(`2`).\n\n`molten.sink_log_path` locate log path.\n\n`molten.sink_http_uri` locate log http uri.\n\n`molten.sink_syslog_unix_socket` transform log to syslog udp unix domain collector.\n\n## Spans Config\n\n`molten.span_format` span format, you can select `zipkin` or `zipkin_v2` or `opentracing` for different tracing system.\n\n# Function\n\n`molten_span_format()` get current span format, return zipkin or opentraceing (string).\n\n`molten_get_traceid()` get current context traceid, return hex string.\n\n`molten_set_traceid($trace_id)`  set current context traceid, return void.\n\n# Verify\n\n```shell\nphp -d extension=molten.so -d molten.enable=1 -d molten.sink_type=2 -d molten.tracing_cli=1 -d molten.sampling_rate=1 -r '$c=curl_init(\"http://localhost:12345\");curl_exec($c);'\n```\nYou can see output below:\n\n```\n[{\"traceId\":\"%s\",\"name\":\"php_curl\",\"version\":\"php-4\",\"id\":\"1.1\",\"parentId\":\"1\",\"timestamp\":%d,\"duration\":%d,\"annotations\":[{\"value\":\"cs\",\"timestamp\":%d,\"endpoint\":{\"serviceName\":\"%s\",\"ipv4\":\"%s\"}},{\"value\":\"cr\",\"timestamp\":%d,\"endpoint\":{\"serviceName\":\"%s\",\"ipv4\":\"%s\"}}],\"binaryAnnotations\":[{\"key\":\"http.url\",\"value\":\"http:\\/\\/localhost:12345\\/\",\"endpoint\":{\"serviceName\":\"%s\",\"ipv4\":\"%s\"}},{\"key\":\"error\",\"value\":\"Failed\nconnect to localhost:12345; Connection\nrefused\",\"endpoint\":{\"serviceName\":\"%s\",\"ipv4\":\"%s\"}}]},{\"traceId\":\"%s\",\"name\":\"cli\",\"version\":\"php-4\",\"id\":\"1\",\"timestamp\":%d,\"duration\":%d,\"annotations\":[{\"value\":\"sr\",\"timestamp\":%d,\"endpoint\":{\"serviceName\":\"%s\",\"ipv4\":\"%s\"}},{\"value\":\"ss\",\"timestamp\":%d,\"endpoint\":{\"serviceName\":\"%s\",\"ipv4\":\"%s\"}}],\"binaryAnnotations\":[{\"key\":\"path\",\"value\":\"-\",\"endpoint\":{\"serviceName\":\"%s\",\"ipv4\":\"%s\"}}]}]\n```\n\n# Features\n\nthe Config Block above, you can see which feature we support.\n\n## Interceptor\n\nwe intercept curl,pdo,mysqli,redis,mongodb,memcached extension to build execute time span info. for chain http request, we replace curl_exec,curl_setopt,curl_setopt_array to add http request trace header (x-w-traceid, x-w-spanid and so on).\n\nthe span_format is the way to custom span format, for two popular kinds (`zipkin` and `opentracing`).\n\n## Sampling\n\ndifferent sampling type and change parameter to control sampling,  rate or request.\n\n## Sink\n\nSink is the output where you locate, molten support to standard fd, file, http and others (continue), on this way,  we can choose where to output trace log.\n\n## Control\n\nUse http to control our sampling. \n\nsee molten status, request `http://domain/molten/status` use GET method.\n\nthe output is below, already adapt the style of [prometheus](https://prometheus.io).\n\n```\n# HELP molten_request_all Number of all request.\n# TYPE molten_request_all counter\nmolten_request_all %d\n# HELP molten_request_capture Number of request be capture.\n# TYPE molten_request_capture counter\nmolten_request_capture %d\n# HELP molten_sampling_type the type of sampling.\n# TYPE molten_sampling_type gauge\nmolten_sampling_type %d\n# HELP molten_sampling_rate the rate of sampling.\n# TYPE molten_sampling_rate gauge\nmolten_sampling_rate %d\n# HELP molten_sampling_request the request be capture one min.\n# TYPE molten_sampling_request gauge\nmolten_sampling_request %d\n```\nmodify molten sampling, request `http://domain/molten/status` use POST method, \n\nbody is json format, field has the same meaning of config.\n\n```\n{\"enable\":1,\"samplingType\":2,\"samplingRate\":20,\"samplingRequest\":100}\n\n```\n\n## Report\n\nReport base import info which we do not sampled like error list.\n\n# Contributing\n\nWelcome developers who willing to make it better.\n\nthe mail list below you can contract for discuss and improve more power.\n\nphobosw@gmail.com\n\nsilkcutbeta@gmail.com\n\nYou may contribute in the following ways:\n\n* [Repost issues and feedback](https://github.com/chuan-yun/Molten/issues).\n* Submit fixes, features via Pull Request.\n\n# License\n\nApache License Version 2.0 see http://www.apache.org/licenses/LICENSE-2.0.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchuan-yun%2FMolten","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchuan-yun%2FMolten","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchuan-yun%2FMolten/lists"}