chuan-yun / Molten

php probe for zipkin and opentracing
Apache License 2.0
793 stars 160 forks source link

运行正常,但无法上报zipkin服务器 #59

Closed zefengguo closed 6 years ago

zefengguo commented 6 years ago

描述:Molten和zipkin在同一台服务器上,php版本:PHP 7.1.8 1.使用curl是可以正常上报数据的。 curl -X POST \ http://127.0.0.1:9411/api/v1/spans \ -H 'cache-control: no-cache' \ -H 'content-type: application/json' \ -d ''

  1. molten.sink_type=2,可以正常输出trance json串的
  2. nc -l 1111,然后运行命令 php -d molten.enable=1 -d molten.sampling_type=1 -d molten.sink_type=4 -d molten.tracing_cli=1 -d molten.sink_http_uri=http://127.0.0.1:1111/api/v1/spans -d molten.service_name=php_test -d molten.sampling_rate=1 -r '$c=curl_init("http://localhost:12345");curl_exec($c);' qq 20171207140637 4.日志输出:

qq 20171207140731

已经调试了一整天但依然无法自行解决问题,麻烦帮忙看下,谢谢!

zefengguo commented 6 years ago

我打印了一下post_data,post_data是有值的. res = curl_easy_perform(curl); res 为0 应该请求成功了。可是 zipkin 为什么看不到数据呢

void send_data_by_http(char post_uri, char post_data) { SLOG(SLOG_INFO, "[sink][http] http data sender, post_uri:%s", post_uri); SLOG(SLOG_INFO, "[sink][http] http data sender, post_data:%s", post_data); if (post_uri != NULL && strlen(post_uri) > 5) { CURL curl = curl_easy_init(); if (curl) { CURLcode res; struct curl_slist list = NULL;

        list = curl_slist_append(list, "Content-Type: application/json");
        curl_easy_setopt(curl, CURLOPT_URL, post_uri);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_data);
        curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 10000L);
        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
        curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);

        res = curl_easy_perform(curl);
        //curl_easy_perform(curl);
        SLOG(SLOG_INFO, " curl request code:%d", res);
        curl_easy_cleanup(curl);
        curl_slist_free_all(list);
    } else {
        SLOG(SLOG_INFO, "[sink][http] init curl error");
    }
}

}

googlerobot commented 6 years ago

也许你可以试试zipkin的筛选?会不会被漏掉了或者没写入?看看zipkin日志有没有错误之类的?

silkcutKs commented 6 years ago

@zefengguo 贴一下zipkin server的图看看, 可能是你zipkin server 筛选的时间有问题。

zefengguo commented 6 years ago

service_name 没有出来,我用cn -l 2222,没有看到body部分? qq 20171207172345 qq 20171207173013

silkcutKs commented 6 years ago

@zefengguo 请在拉取一下master的分支 编译一下。

zefengguo commented 6 years ago

嗯,可以了,感谢!