Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
SkyAPM
SkyAPM-php-sdk
提交
90b6e9ef
S
SkyAPM-php-sdk
项目概览
SkyAPM
/
SkyAPM-php-sdk
通知
14
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyAPM-php-sdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
90b6e9ef
编写于
3月 18, 2018
作者:
S
songzhian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
支持3.X 和 GRPC 版本 通信
上级
c8b03512
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
2164 addition
and
1291 deletion
+2164
-1291
sdk-php/SkyWalking.php
sdk-php/SkyWalking.php
+622
-276
sky-php7ext/config.m4
sky-php7ext/config.m4
+38
-1
sky-php7ext/grpc/common_struct.h
sky-php7ext/grpc/common_struct.h
+157
-0
sky-php7ext/grpc/greeter_client.cc
sky-php7ext/grpc/greeter_client.cc
+223
-0
sky-php7ext/php.ini
sky-php7ext/php.ini
+4
-2
sky-php7ext/php_skywalking.h
sky-php7ext/php_skywalking.h
+126
-42
sky-php7ext/protos/ApplicationRegisterService.proto
sky-php7ext/protos/ApplicationRegisterService.proto
+24
-0
sky-php7ext/protos/DiscoveryService.proto
sky-php7ext/protos/DiscoveryService.proto
+65
-0
sky-php7ext/protos/TraceSegmentService.proto
sky-php7ext/protos/TraceSegmentService.proto
+93
-0
sky-php7ext/skywalking.c
sky-php7ext/skywalking.c
+769
-970
sky-php7ext/skywalking.php
sky-php7ext/skywalking.php
+43
-0
未找到文件。
sdk-php/SkyWalking.php
浏览文件 @
90b6e9ef
此差异已折叠。
点击以展开。
sky-php7ext/config.m4
浏览文件 @
90b6e9ef
...
...
@@ -62,6 +62,43 @@ if test "$PHP_SKYWALKING" != "no"; then
dnl ])
dnl
dnl PHP_SUBST(SKYWALKING_SHARED_LIBADD)
PHP_REQUIRE_CXX()
PHP_NEW_EXTENSION(skywalking, skywalking.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
KYWALKING_LIBS=" -L/usr/local/lib "
KYWALKING_LIBS+=`pkg-config --libs protobuf grpc++ grpc`
KYWALKING_LIBS+="-Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -ldl"
AC_OUTPUT_COMMANDS(
protoc -I ./protos --cpp_out=./grpc ./protos/DiscoveryService.proto
protoc -I ./protos --cpp_out=./grpc ./protos/ApplicationRegisterService.proto
protoc -I ./protos --cpp_out=./grpc ./protos/TraceSegmentService.proto
)
AC_OUTPUT_COMMANDS(
protoc -I ./protos --grpc_out=./grpc --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./protos/DiscoveryService.proto
protoc -I ./protos --grpc_out=./grpc --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./protos/ApplicationRegisterService.proto
protoc -I ./protos --grpc_out=./grpc --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` ./protos/TraceSegmentService.proto
)
AC_OUTPUT_COMMANDS(
mv grpc/DiscoveryService.grpc.pb.cc grpc/DiscoveryService-grpc.pb.cc
mv grpc/ApplicationRegisterService.grpc.pb.cc grpc/ApplicationRegisterService-grpc.pb.cc
mv grpc/TraceSegmentService.grpc.pb.cc grpc/TraceSegmentService-grpc.pb.cc
)
PHP_EVAL_LIBLINE($KYWALKING_LIBS, SKYWALKING_SHARED_LIBADD)
PHP_NEW_EXTENSION(skywalking, \
skywalking.c \
grpc/greeter_client.cc \
grpc/DiscoveryService.pb.cc \
grpc/DiscoveryService-grpc.pb.cc \
grpc/ApplicationRegisterService.pb.cc \
grpc/ApplicationRegisterService-grpc.pb.cc \
grpc/TraceSegmentService.pb.cc \
grpc/TraceSegmentService-grpc.pb.cc \
, $ext_shared,, -std=c++11 -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_ADD_BUILD_DIR($ext_builddir/grpc)
PHP_SUBST(SKYWALKING_SHARED_LIBADD)
fi
sky-php7ext/grpc/common_struct.h
0 → 100644
浏览文件 @
90b6e9ef
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: DiscoveryService.proto
#ifndef DISCOVERY_CLIENT_C_H
#define DISCOVERY_CLIENT_C_H
#define METHOD__GO_REGISTER 1
#define METHOD__GO_REGISTER_INSTANCE 2
#define METHOD__SEND_TRACE_SEGMENT 3
typedef
struct
_RegisterParamtruct
{
char
*
appCode
;
}
RegisterParamtruct
;
typedef
struct
_RegisterInstanceParamtruct
{
char
*
agentUUID
;
char
*
osName
;;
char
*
hostname
;
char
*
ipv4s
;
int
applicationId
;
long
registerTime
;
int
processNo
;
}
RegisterInstanceParamtruct
;
typedef
enum
_SpanTypeStruct
{
Entry_x
,
Exit_x
,
Local_x
}
SpanTypeStruct
;
typedef
enum
_SpanLayerStruct
{
Unknown_x
,
Database_x
,
RPCFramework_x
,
Http_x
,
MQ_x
,
Cache_x
}
SpanLayerStruct
;
typedef
struct
_KeyWithStringValueStruct
{
int
key
;
char
*
value
;
}
KeyWithStringValueStruct
;
typedef
struct
_LogMessageStruct
{
long
time
;
KeyWithStringValueStruct
*
data
;
}
LogMessageStruct
;
typedef
enum
_RefTypeStruct
{
CrossProcess_x
,
CrossThread_x
}
RefTypeStruct
;
typedef
struct
_UniqueIdStruct
{
long
idParts
;
}
UniqueIdStruct
;
typedef
struct
_TraceSegmentReferenceStruct
{
RefTypeStruct
*
refType
;
UniqueIdStruct
*
parentTraceSegmentId
;
int
parentSpanId
;
int
parentApplicationInstanceId
;
int
networkAddress
;
int
networkAddressId
;
int
entryApplicationInstanceId
;
char
*
entryServiceName
;
int
entryServiceId
;
char
*
parentServiceName
;
int
*
parentServiceId
;
}
TraceSegmentReferenceStruct
;
typedef
struct
_SpanObjectStruct
{
int
spanId
;
int
parentSpanId
;
long
startTime
;
long
endTime
;
TraceSegmentReferenceStruct
*
refs
;
int
operationNameId
;
char
*
operationName
;
int
peerId
;
char
*
peer
;
SpanTypeStruct
*
spanType
;
SpanLayerStruct
*
spanLayer
;
int
componentId
;
int
isError
;
KeyWithStringValueStruct
*
tags
;
LogMessageStruct
*
logs
;
}
SpanObjectStruct
;
typedef
struct
_comListNode
{
UniqueIdStruct
*
data
;
struct
_comListNode
*
next
;
}
comListNode
;
typedef
struct
_comList
{
struct
_comListNode
*
head
;
struct
_comListNode
*
tail
;
int
count
;
}
comList
;
typedef
struct
_TraceSegmentObjectStruct
{
comList
*
traceSegmentIdList
;
SpanObjectStruct
*
spans
;
char
*
segment
;
int
applicationId
;
int
applicationInstanceId
;
int
isSizeLimited
;
}
TraceSegmentObjectStruct
;
typedef
struct
_SendTraceSegmentParamStruct
{
TraceSegmentObjectStruct
*
traceSegment
;
}
SendTraceSegmentParamStruct
;
typedef
union
_ParamDataStruct
{
RegisterParamtruct
*
registerParam
;
RegisterInstanceParamtruct
*
registerInstanceParam
;
SendTraceSegmentParamStruct
*
sendTraceSegmentParam
;
}
ParamDataStruct
;
typedef
struct
_UpstreamSegmentStruct
{
UniqueIdStruct
*
globalTraceIds
;
char
*
segment
;
}
UpstreamSegmentStruct
;
typedef
struct
AppInstanceStruct
{
int
applicationId
;
int
applicationInstanceId
;
}
AppInstance
;
#endif
/* #ifndef DISCOVERY_CLIENT_C_H */
\ No newline at end of file
sky-php7ext/grpc/greeter_client.cc
0 → 100644
浏览文件 @
90b6e9ef
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <iostream>
#include <memory>
#include <string>
#include <grpc++/grpc++.h>
#include "ApplicationRegisterService.grpc.pb.h"
#include "DiscoveryService.grpc.pb.h"
#include "TraceSegmentService.grpc.pb.h"
#include "common_struct.h"
using
grpc
::
Channel
;
using
grpc
::
ClientContext
;
using
grpc
::
Status
;
using
grpc
::
ClientReader
;
using
grpc
::
ClientReaderWriter
;
using
grpc
::
ClientWriter
;
extern
"C"
int
goSkyGrpc
(
char
*
host
,
int
method
,
ParamDataStruct
*
paramData
,
void
(
*
callfuct
)(
AppInstance
*
)
);
class
GreeterClient
{
public:
GreeterClient
(
std
::
shared_ptr
<
Channel
>
channel
)
{
channel_
=
channel
;
}
// Assembles the client's payload, sends it and presents the response back
// from the server.
AppInstance
*
goRegister
(
const
std
::
string
&
appCode
)
{
std
::
unique_ptr
<
ApplicationRegisterService
::
Stub
>
stub_
;
stub_
=
ApplicationRegisterService
::
NewStub
(
channel_
)
;
// Data we are sending to the server.
Application
request
;
request
.
set_applicationcode
(
appCode
);
// Container for the data we expect from the server.
ApplicationMapping
reply
;
// Context for the client. It could be used to convey extra information to
// the server and/or tweak certain RPC behaviors.
ClientContext
context
;
KeyWithIntegerValue
kwiv
;
// The actual RPC.
Status
status
=
stub_
->
applicationCodeRegister
(
&
context
,
request
,
&
reply
);
AppInstance
*
appInstance
=
(
AppInstance
*
)
malloc
(
sizeof
(
AppInstance
));
// Act upon its status.
if
(
status
.
ok
())
{
kwiv
=
reply
.
application
();
appInstance
->
applicationId
=
kwiv
.
value
();
return
appInstance
;
}
return
NULL
;
}
// Assembles the client's payload, sends it and presents the response back
// from the server.
AppInstance
*
goRegisterInstance
(
std
::
string
agentUUID
,
std
::
string
osName
,
std
::
string
hostname
,
std
::
string
ipv4s
,
int
applicationId
,
long
registerTime
,
int
processNo
)
{
std
::
unique_ptr
<
InstanceDiscoveryService
::
Stub
>
stub_
;
stub_
=
InstanceDiscoveryService
::
NewStub
(
channel_
);
// Data we are sending to the server.
ApplicationInstance
request
;
request
.
set_applicationid
(
applicationId
);
request
.
set_agentuuid
(
agentUUID
);
request
.
set_registertime
(
registerTime
);
OSInfo
*
osinfo
=
new
OSInfo
;
request
.
set_allocated_osinfo
(
osinfo
);
osinfo
->
set_osname
(
osName
);
osinfo
->
set_hostname
(
hostname
);
osinfo
->
set_processno
(
processNo
);
osinfo
->
add_ipv4s
(
ipv4s
);
AppInstance
*
appInstancestruct
=
(
AppInstance
*
)
malloc
(
sizeof
(
AppInstance
));
// Container for the data we expect from the server.
ApplicationInstanceMapping
reply
;
// Context for the client. It could be used to convey extra information to
// the server and/or tweak certain RPC behaviors.
ClientContext
context
;
// The actual RPC.
Status
status
=
stub_
->
registerInstance
(
&
context
,
request
,
&
reply
);
//free OSInfo
//delete osinfo;
// Act upon its status.
if
(
status
.
ok
())
{
appInstancestruct
->
applicationId
=
reply
.
applicationid
();
appInstancestruct
->
applicationInstanceId
=
reply
.
applicationinstanceid
();
return
appInstancestruct
;
}
return
NULL
;
}
void
sendTrace
(
TraceSegmentObjectStruct
*
traceSegment
)
{
std
::
unique_ptr
<
TraceSegmentService
::
Stub
>
stub_
;
stub_
=
TraceSegmentService
::
NewStub
(
channel_
);
// Data we are sending to the server.
UpstreamSegment
request
;
//UniqueId
UniqueId
*
uniqueId
;
uniqueId
=
request
.
add_globaltraceids
();
comListNode
*
com_list
=
traceSegment
->
traceSegmentIdList
->
head
;
while
(
com_list
!=
NULL
)
{
uniqueId
->
add_idparts
(
com_list
->
data
->
idParts
);
com_list
=
com_list
->
next
;
}
if
(
traceSegment
->
segment
){
request
.
set_segment
(
traceSegment
->
segment
);
Downstream
reply
;
ClientContext
context
;
grpc_connectivity_state
state
=
channel_
->
GetState
(
false
);
if
(
state
==
GRPC_CHANNEL_TRANSIENT_FAILURE
){
return
;
}
std
::
unique_ptr
<
ClientWriter
<
UpstreamSegment
>
>
writer
(
stub_
->
collect
(
&
context
,
&
reply
));
writer
->
Write
(
request
);
writer
->
WritesDone
();
writer
->
Finish
();
}
}
private:
std
::
shared_ptr
<
Channel
>
channel_
;
};
int
goSkyGrpc
(
char
*
host
,
int
method
,
ParamDataStruct
*
paramData
,
void
(
*
callfuct
)(
AppInstance
*
)
)
{
std
::
shared_ptr
<
Channel
>
channel
=
grpc
::
CreateChannel
(
host
,
grpc
::
InsecureChannelCredentials
());
static
GreeterClient
greeter
(
channel
);
switch
(
method
)
{
case
METHOD__GO_REGISTER
:
{
std
::
string
appCode
(
paramData
->
registerParam
->
appCode
);
callfuct
(
greeter
.
goRegister
(
appCode
));
}
break
;
case
METHOD__GO_REGISTER_INSTANCE
:
{
std
::
string
agentUUID
(
paramData
->
registerInstanceParam
->
agentUUID
);
std
::
string
osName
(
paramData
->
registerInstanceParam
->
osName
);
std
::
string
hostname
(
paramData
->
registerInstanceParam
->
hostname
);
std
::
string
ipv4s
(
paramData
->
registerInstanceParam
->
ipv4s
);
int
applicationId
=
paramData
->
registerInstanceParam
->
applicationId
;
long
registerTime
=
paramData
->
registerInstanceParam
->
registerTime
;
int
processNo
=
paramData
->
registerInstanceParam
->
processNo
;
callfuct
(
greeter
.
goRegisterInstance
(
agentUUID
,
osName
,
hostname
,
ipv4s
,
applicationId
,
registerTime
,
processNo
)
);
}
break
;
case
METHOD__SEND_TRACE_SEGMENT
:
{
greeter
.
sendTrace
(
paramData
->
sendTraceSegmentParam
->
traceSegment
);
}
break
;
default:
return
0
;
break
;
}
return
1
;
}
sky-php7ext/php.ini
浏览文件 @
90b6e9ef
...
...
@@ -8,8 +8,10 @@
[skywalking]
skywalking.app_code
=
m
api
skywalking.app_code
=
api
skywalking.sampling_rate
=
99.22;
skywalking.log_path
=
/tmp/log
skywalking.header_client_ip_name
=
HTTP_DD_REAL_IP
skywalking.auto_open
=
On
\ No newline at end of file
skywalking.auto_open
=
On
skywalking.send_type
=
1
skywalking.grpc_trace
=
127.0.0.1:50051
\ No newline at end of file
sky-php7ext/php_skywalking.h
浏览文件 @
90b6e9ef
...
...
@@ -24,7 +24,7 @@
extern
zend_module_entry
skywalking_module_entry
;
#define phpext_skywalking_ptr &skywalking_module_entry
#define PHP_SKYWALKING_VERSION "0.
1
.0"
/* Replace with version number for your extension */
#define PHP_SKYWALKING_VERSION "0.
2
.0"
/* Replace with version number for your extension */
#ifdef PHP_WIN32
# define PHP_SKYWALKING_API __declspec(dllexport)
...
...
@@ -44,25 +44,58 @@ extern zend_module_entry skywalking_module_entry;
#define SKY_G(v) (skywalking_globals.v)
#endif
#define SKYWALKING_TRACEID "ts" //TraceId
#define SKYWALKING_STARTTIME "st"//开始时间
#define SKYWALKING_ENDTIME "et" //结束时间
#define SKYWALKING_APP_CODE "ac"// App Code
#define SKYWALKING_FATHER_NODE_DATA "rs"//父节点数据
#define SKYWALKING_SPANS_NODE_DATA "ss"//span节点数据集合
#define SKYWALKING_DISTRIBUTED_TRACEIDS "gt" //DistributedTraceIds
#define SKYWALKING_SPAN_ID "si"//SpanId
#define SKYWALKING_PEERHOST "ph"//PeerHost
#define SKYWALKING_FATHER_SPAN_ID "ps"//父节点传过来的SpanId
#define SKYWALKING_SPAN_SERVER_URI "on" // Span 的服务URI
#define SKYWALKING_SPAN_STRING_PARAM "ts" //Span 的字符串型参数
#define SKYWALKING_SPAN_BOOL_PARAM "tb" //Span 的字符串型参数
#define SKYWALKING_SPAN_INT_PARAM "ti" //Span 的字符串型参数
#define SKYWALKING_SPAN_LOG "lo"//Span 的日志
int
ski_zval_key
=
0
;
#define SKY_MAKE_NULL_ARRAY_NAME(i_zval_key) null_array_##i_zval_key
#define S_SEND_TYPE_CLOSE (1<<0L)
#define S_SEND_TYPE_GRPC (1<<1L)
#define S_SEND_TYPE_WRITE (1<<2L)
#define USE_PARENT_TRACE_ID 1
#define DONOT_USE_PARENT_TRACE_ID 0
#define SKYWALKING_SEGMENT "sg" //全部段节点
#define SKYWALKING_DISTRIBUTED_TRACEIDS "gt"//DistributedTraceIds
#define SKYWALKING_TRACE_SEGMENT_ID "ts"//本次请求id
#define SKYWALKING_APPLICATION_ID "ai"//app id
#define SKYWALKING_APPLICATION_INSTANCE_ID "ii"//实例id
#define SKYWALKING_FATHER_NODE_DATA "rs" //父节点数据
#define SKYWALKING_SPANS_NODE_DATA "ss" //span节点数据集合
#define SKYWALKING_PARENT_TRACE_SEGMENT_ID "ts" //本次请求id
#define SKYWALKING_PARENT_APPLICATION_ID "ai"//app id
#define SKYWALKING_PARENT_SPAN_ID "si"//spanid
#define SKYWALKING_PARENT_SERVICE_ID "vi"//
#define SKYWALKING_PARENT_SERVICE_NAME "vn"
#define SKYWALKING_NETWORK_ADDRESS_ID "ni"
#define SKYWALKING_NETWORK_ADDRESS "nn"
#define SKYWALKING_ENTRY_APPLICATION_INSTANCE_ID "ea"
#define SKYWALKING_ENTRY_SERVICE_ID "ei"
#define SKYWALKING_ENTRY_SERVICE_NAME "en"
#define SKYWALKING_REF_TYPE_VALUE "rv"
#define SKYWALKING_SPAN_ID "si" //SpanId
#define SKYWALKING_SPAN_TYPE_VALUE "tv"
#define SKYWALKING_SPAN_LAYER_VALUE "lv"
#define SKYWALKING_FATHER_SPAN_ID "ps" //父节点传过来的SpanId
#define SKYWALKING_STARTTIME "st" //开始时间
#define SKYWALKING_ENDTIME "et" //结束时间
#define SKYWALKING_COMPONENT_ID "ci"
#define SKYWALKING_COMPONENT_NAME "cn"
#define SKYWALKING_OPERATION_NAME_ID "oi"
#define SKYWALKING_OPERATION_NAME "on"// Span 的服务URI
#define SKYWALKING_PEER_ID "pi"
#define SKYWALKING_PEER "pn"
#define SKYWALKING_IS_ERROR "ie"
#define SKYWALKING_TAGS "to"
#define SKYWALKING_LOGS "lo"
#define SKYWALKING_KEY "k"
#define SKYWALKING_VALUE "v"
#define SKYWALKING_TIME "ti"
#define SKYWALKING_LOG_DATA "ld"
#define RAND_RANGE(__n, __min, __max, __tmax) \
(__n) = ((__min) + (zend_long) ((double) ( (double) (__max) - (__min) + 1.0) * ((__n) / ((__tmax) + 1.0))))
...
...
@@ -88,40 +121,54 @@ void *SKY_UPDATE_PROPERTY(zend_class_entry *cls, zval *tp, const char *name, siz
array_init
(
&
null_array
);
zend_update_property
(
cls
,
tp
,
name
,
name_length
,
&
null_array
);
}
static
void
*
write_log_text
(
char
*
text
);
static
char
*
sky_json_encode
(
zval
*
parameter
);
static
int
_php_filter_validate_domain
(
char
*
domain
,
int
len
,
zend_long
flags
)
;
static
int
_php_filter_validate_ipv4
(
char
*
str
,
size_t
str_len
,
int
*
ip
);
static
int
_php_filter_validate_ipv6
(
char
*
str
,
size_t
str_len
);
static
int
_php_filter_validate_url
(
char
*
value
);
static
zval
*
sky_instance
(
zval
*
this_ptr
,
const
char
*
appCode
);
static
void
date_register_classes
(
TSRMLS_D
);
static
void
_init
(
const
char
*
appCode
,
zval
*
this_ptr
);
static
char
*
build_SWheader_value
(
const
char
*
peer_host
,
zval
*
this_ptr
);
static
zval
*
receive_SWHeader_from_caller
(
zval
*
this_ptr
);
static
char
*
build_SWheader_value
(
const
char
*
peer_host
);
static
zval
receive_SWHeader_from_caller
();
static
char
*
get_millisecond
();
static
char
*
uniqid
();
static
char
*
make_trace_id
();
static
zend_always_inline
zend_uchar
is_sampling
(
zval
*
this_ptr
);
static
char
*
generate_trace_id
(
zval
*
this_ptr
);
static
zend_always_inline
zend_uchar
is_sampling
();
static
char
*
generate_trace_id
();
static
char
*
get_ip
();
static
char
*
get_page_url_and_peer
();
static
long
generate_span_id
(
zval
*
this_ptr
);
static
char
*
generate_distributed_trace_ids
(
zval
*
this_ptr
);
static
void
*
write_log
(
zval
*
this_ptr
,
char
*
text
);
static
zval
*
set_span_nodes_data
(
zval
*
this_ptr
,
zval
*
node_data
);
static
char
*
sky_finishAll
();
static
long
generate_span_id
();
static
void
*
write_log
(
char
*
text
);
static
zval
*
set_span_nodes_data
(
zval
*
node_data
);
static
long
sky_array_unshift
(
zval
*
stack
,
zval
*
var
);
static
void
set_sampling_rate
(
zval
*
this_ptr
,
double
degrees
);
static
void
start_span_of_curl
(
char
*
peer_host
,
zval
*
headers
,
zval
*
this_pr
);
static
void
set_span_param_of_curl
(
char
*
peer_host
,
zval
*
this_pr
);
static
void
make_span_curl_header
(
char
*
peer_host
,
zval
*
headers
,
zval
*
this_pr
);
static
void
set_sampling_rate
(
double
degrees
);
static
void
set_span_param_of_curl
(
char
*
peer_host
);
static
void
make_span_curl_header
(
char
*
peer_host
,
zval
*
headers
);
static
void
start_span
(
zval
*
this_pr
);
static
int
is_auto_open
();
static
void
end_span_of_curl
(
zval
*
this_ptr
,
zval
*
curl
);
void
accel_sky_curl_init
(
INTERNAL_FUNCTION_PARAMETERS
);
void
accel_sky_curl_setopt
(
INTERNAL_FUNCTION_PARAMETERS
);
void
accel_sky_curl_exec
(
INTERNAL_FUNCTION_PARAMETERS
);
void
list_poll
(
comList
*
myroot
);
static
void
*
sky_flush_all
();
static
char
*
_get_current_machine_ip
();
static
int
get_app_instance_id
();
static
int
get_app_id
();
static
char
*
generate_parent_info_from_header
(
char
*
header_name
);
static
void
start_node_span_of_curl
();
static
char
*
generate_parent_trace_id
();
static
zval
*
generate_trace_id_for_array
(
int
use_parent_tid
,
zval
*
z_trace_id
);
static
char
*
_entry_app_name
();
static
char
*
generate_distributed_trace_ids
();
static
int
_entry_app_instance_id
();
static
void
end_node_span_of_curl
(
zval
*
curl
);
static
void
*
send_grpc_param
(
zval
*
all_node_data
);
static
comList
*
create_com_list
();
static
long
_entry_app_name_operation_id
();
static
long
_parent_appname_operation_id
();
static
int
sky_live_pthread
(
pthread_t
tid
);
static
int
add_com_list
(
comList
*
com_list
,
UniqueIdStruct
*
data
);
static
void
(
*
orig_curl_init
)(
INTERNAL_FUNCTION_PARAMETERS
)
=
NULL
;
static
void
(
*
orig_curl_setopt
)(
INTERNAL_FUNCTION_PARAMETERS
)
=
NULL
;
static
void
(
*
orig_curl_exec
)(
INTERNAL_FUNCTION_PARAMETERS
)
=
NULL
;
/*
Declare any global variables you may need between the BEGIN
and END macros here:
...
...
@@ -130,8 +177,10 @@ ZEND_BEGIN_MODULE_GLOBALS(skywalking)
char
*
global_log_path
;
char
*
global_header_client_ip_name
;
char
*
global_app_code
;
long
global_send_type
;
zend_bool
global_auto_open
;
double
global_sampling_rate
;
char
*
global_app_grpc_trace
;
ZEND_END_MODULE_GLOBALS
(
skywalking
)
extern
ZEND_DECLARE_MODULE_GLOBALS
(
skywalking
);
...
...
@@ -146,6 +195,41 @@ extern ZEND_DECLARE_MODULE_GLOBALS(skywalking);
ZEND_TSRMLS_CACHE_EXTERN
()
#endif
#ifdef __unix
#ifdef __linux
#define SKY_OS_NAME "Linux"
#endif
#ifdef __sun
#ifdef __sparc
#define SKY_OS_NAME "Sun SPARC"
#else
#define SKY_OS_NAME "Sun X86"
#endif
#endif
#ifdef _AIX
#define SKY_OS_NAME "AIX"
#endif
#else
#ifdef WINVER
#define SKY_OS_NAME "Windows"
#else
#define SKY_OS_NAME "Unknown"
#endif
#endif
#endif
/* PHP_SKYWALKING_H */
...
...
sky-php7ext/protos/ApplicationRegisterService.proto
0 → 100644
浏览文件 @
90b6e9ef
syntax
=
"proto3"
;
option
java_multiple_files
=
true
;
option
java_package
=
"org.apache.skywalking.apm.network.proto"
;
//register service for ApplicationCode, this service is called when service starts.
service
ApplicationRegisterService
{
rpc
applicationCodeRegister
(
Application
)
returns
(
ApplicationMapping
)
{
}
}
message
KeyWithIntegerValue
{
string
key
=
1
;
int32
value
=
2
;
}
message
Application
{
string
applicationCode
=
1
;
}
message
ApplicationMapping
{
KeyWithIntegerValue
application
=
1
;
}
sky-php7ext/protos/DiscoveryService.proto
0 → 100644
浏览文件 @
90b6e9ef
syntax
=
"proto3"
;
option
java_multiple_files
=
true
;
option
java_package
=
"org.apache.skywalking.apm.network.proto"
;
service
InstanceDiscoveryService
{
rpc
registerInstance
(
ApplicationInstance
)
returns
(
ApplicationInstanceMapping
)
{
}
}
message
ApplicationInstance
{
int32
applicationId
=
1
;
string
agentUUID
=
2
;
int64
registerTime
=
3
;
OSInfo
osinfo
=
4
;
}
message
ApplicationInstanceMapping
{
int32
applicationId
=
1
;
int32
applicationInstanceId
=
2
;
}
message
ApplicationInstanceRecover
{
int32
applicationId
=
1
;
int32
applicationInstanceId
=
2
;
int64
registerTime
=
3
;
OSInfo
osinfo
=
4
;
}
message
ApplicationInstanceHeartbeat
{
int32
applicationInstanceId
=
1
;
int64
heartbeatTime
=
2
;
}
message
OSInfo
{
string
osName
=
1
;
string
hostname
=
2
;
int32
processNo
=
3
;
repeated
string
ipv4s
=
4
;
}
//discovery service for ServiceName by Network address or application code
service
ServiceNameDiscoveryService
{
rpc
discovery
(
ServiceNameCollection
)
returns
(
ServiceNameMappingCollection
)
{
}
}
message
ServiceNameCollection
{
repeated
ServiceNameElement
elements
=
1
;
}
message
ServiceNameMappingCollection
{
repeated
ServiceNameMappingElement
elements
=
1
;
}
message
ServiceNameMappingElement
{
int32
serviceId
=
1
;
ServiceNameElement
element
=
2
;
}
message
ServiceNameElement
{
string
serviceName
=
1
;
int32
applicationId
=
2
;
}
sky-php7ext/protos/TraceSegmentService.proto
0 → 100644
浏览文件 @
90b6e9ef
syntax
=
"proto3"
;
option
java_multiple_files
=
true
;
option
java_package
=
"org.apache.skywalking.apm.network.proto"
;
service
TraceSegmentService
{
rpc
collect
(
stream
UpstreamSegment
)
returns
(
Downstream
)
{
}
}
message
Downstream
{
}
message
KeyWithStringValue
{
string
key
=
1
;
string
value
=
2
;
}
message
UpstreamSegment
{
repeated
UniqueId
globalTraceIds
=
1
;
bytes
segment
=
2
;
// the byte array of TraceSegmentObject
}
message
UniqueId
{
repeated
int64
idParts
=
1
;
}
message
TraceSegmentObject
{
UniqueId
traceSegmentId
=
1
;
repeated
SpanObject
spans
=
2
;
int32
applicationId
=
3
;
int32
applicationInstanceId
=
4
;
bool
isSizeLimited
=
5
;
}
message
TraceSegmentReference
{
RefType
refType
=
1
;
UniqueId
parentTraceSegmentId
=
2
;
int32
parentSpanId
=
3
;
int32
parentApplicationInstanceId
=
4
;
string
networkAddress
=
5
;
int32
networkAddressId
=
6
;
int32
entryApplicationInstanceId
=
7
;
string
entryServiceName
=
8
;
int32
entryServiceId
=
9
;
string
parentServiceName
=
10
;
int32
parentServiceId
=
11
;
}
message
SpanObject
{
int32
spanId
=
1
;
int32
parentSpanId
=
2
;
int64
startTime
=
3
;
int64
endTime
=
4
;
repeated
TraceSegmentReference
refs
=
5
;
int32
operationNameId
=
6
;
string
operationName
=
7
;
int32
peerId
=
8
;
string
peer
=
9
;
SpanType
spanType
=
10
;
SpanLayer
spanLayer
=
11
;
int32
componentId
=
12
;
string
component
=
13
;
bool
isError
=
14
;
repeated
KeyWithStringValue
tags
=
15
;
repeated
LogMessage
logs
=
16
;
}
enum
RefType
{
CrossProcess
=
0
;
CrossThread
=
1
;
}
enum
SpanType
{
Entry
=
0
;
Exit
=
1
;
Local
=
2
;
}
enum
SpanLayer
{
Unknown
=
0
;
Database
=
1
;
RPCFramework
=
2
;
Http
=
3
;
MQ
=
4
;
Cache
=
5
;
}
message
LogMessage
{
int64
time
=
1
;
repeated
KeyWithStringValue
data
=
2
;
}
sky-php7ext/skywalking.c
浏览文件 @
90b6e9ef
此差异已折叠。
点击以展开。
sky-php7ext/skywalking.php
浏览文件 @
90b6e9ef
<?php
$file
=
new
SplFileObject
(
'appid.pid'
,
"w"
);
$written
=
$file
->
fwrite
(
"124124"
);
$file
=
new
SplFileObject
(
'appid.pid'
);
$aa
=
$file
->
current
();
var_dump
(
$aa
);
exit
;
function
getfiles
(
$path
){
foreach
(
scandir
(
$path
)
as
$afile
)
{
if
(
$afile
==
'.'
||
$afile
==
'..'
)
continue
;
if
(
is_file
(
$path
.
'/'
.
$afile
)){
echo
$afile
.
"
\n
"
;
}
}
}
//简单的demo,列出当前目录下所有的文件
getfiles
(
__DIR__
);
exit
;
var_dump
(
base_convert
(
uniqid
(),
16
,
10
));
getMillisecond
();
function
getMillisecond
()
{
list
(
$t1
,
$t2
)
=
explode
(
' '
,
microtime
());
/*$t3 = $t1 * 100000000;
var_dump($t2, substr($t2, -6));
$aa = (float)($t3 . substr($t2, -6));
var_dump( (float)($t3 . substr($t2, -6)));
var_dump( json_encode(array("aaa"=> $aa)));
exit;*/
$millisecond
=
(
float
)
sprintf
(
'%.0f'
,
(
floatval
(
$t1
)
+
floatval
(
$t2
))
*
10000
);
var_dump
(
json_encode
(
array
(
"aaa"
=>
$millisecond
)));
var_dump
(
$millisecond
);
return
$millisecond
;
}
exit
;
var_dump
(
json_encode
([
"applicationCode"
=>
"mapi"
]));
exit
;
exit
;
$br
=
(
php_sapi_name
()
==
"cli"
)
?
""
:
"<br>"
;
if
(
!
extension_loaded
(
'skywalking'
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录