a pure-php client

64 views
Skip to first unread message

gggeek

unread,
Apr 26, 2011, 1:23:45 PM4/26/11
to Pinba Engine development list
I'd like to build a pure-php implementation of the data-gathering part
of pinba, that will send data to a pinba-engine for collection.
Since I plan to deliver as a plugin to existing php apps that are
deployed on many different customers platforms, using a custom php
extension is a no go - offering a limited subset of the pinba-
extension functionality is an acceptable compromise otoh.

So the questions I have hare:
- did anybody try this before?
- is the net protocol between pinba extension and engine documented
somewhere?

Thanks
Gaetano

Antony Dovgal

unread,
Apr 27, 2011, 12:41:38 AM4/27/11
to pinba-...@googlegroups.com
On 04/26/2011 09:23 PM, gggeek wrote:
> I'd like to build a pure-php implementation of the data-gathering part
> of pinba, that will send data to a pinba-engine for collection.
> Since I plan to deliver as a plugin to existing php apps that are
> deployed on many different customers platforms, using a custom php
> extension is a no go - offering a limited subset of the pinba-
> extension functionality is an acceptable compromise otoh.
>
> So the questions I have hare:
> - did anybody try this before?

Probably not, 'cause I've never heard about it.

> - is the net protocol between pinba extension and engine documented
> somewhere?

Pinba uses Google Protocol Buffers as a protocol.
I can see several GPB implementations in PHP:
https://github.com/drslump/Protobuf-PHP
https://github.com/undr/phpbuf
and there are probably some more.

Look in the extension (or daemon) sources for pinba.proto, that's the proto file you
need to use to be able to 'speak' to Pinba daemon.

Let me know if you need any help, I think such thing could be useful for other people
and I might want to add it to the distribution.

--
Wbr,
Antony Dovgal
---
http://pinba.org - realtime statistics for PHP

Olivier POITREY

unread,
Apr 27, 2011, 2:33:36 AM4/27/11
to pinba-...@googlegroups.com, Pinba Engine development list
I did a naive implementation of the protocol in node.js for pinba_http, a HTTP to Pinba gateway that ease the tracking of client side events. The code is available on github: https://github.com/rs/pinba_http

Hope it can help you.

> --
> ---
> Pinba Engine development mailing list
> To unsubscribe, send an email to pinba-engine...@googlegroups.com

Gaetano Giunta

unread,
Apr 27, 2011, 4:54:16 AM4/27/11
to pinba-...@googlegroups.com
Antony Dovgal wrote:
> On 04/26/2011 09:23 PM, gggeek wrote:
>> I'd like to build a pure-php implementation of the data-gathering part
>> of pinba, that will send data to a pinba-engine for collection.
>> Since I plan to deliver as a plugin to existing php apps that are
>> deployed on many different customers platforms, using a custom php
>> extension is a no go - offering a limited subset of the pinba-
>> extension functionality is an acceptable compromise otoh.
>>
>> So the questions I have hare:
>> - did anybody try this before?
>
> Probably not, 'cause I've never heard about it.
>
>> - is the net protocol between pinba extension and engine documented
>> somewhere?
>
> Pinba uses Google Protocol Buffers as a protocol.
> I can see several GPB implementations in PHP:
> https://github.com/drslump/Protobuf-PHP
> https://github.com/undr/phpbuf
> and there are probably some more.

As far as I understand, that is used only for serialization of the messages. The network part does not rely on "standard" rpc protocols, correct?

Antony Dovgal

unread,
Apr 27, 2011, 5:09:28 AM4/27/11
to pinba-...@googlegroups.com
On 04/27/2011 12:54 PM, Gaetano Giunta wrote:
>> Pinba uses Google Protocol Buffers as a protocol.
>> I can see several GPB implementations in PHP:
>> https://github.com/drslump/Protobuf-PHP
>> https://github.com/undr/phpbuf
>> and there are probably some more.
>
> As far as I understand, that is used only for serialization of the messages.
>The network part does not rely on "standard" rpc protocols, correct?

The network part is as simple as that: the serialized message is sent by UDP to the server using sendto().

Gaetano Giunta

unread,
Apr 27, 2011, 12:41:21 PM4/27/11
to pinba-...@googlegroups.com
Antony Dovgal wrote:
On 04/27/2011 12:54 PM, Gaetano Giunta wrote:
 Pinba uses Google Protocol Buffers as a protocol.
 I can see several GPB implementations in PHP:
 https://github.com/drslump/Protobuf-PHP
 https://github.com/undr/phpbuf
 and there are probably some more.

As far as I understand, that is used only for serialization of the messages.
The network part does not rely on "standard" rpc protocols, correct?

The network part is as simple as that: the serialized message is sent by UDP to the server using sendto().

Ok, so here's an alpha version of the code.
Caveat: it is only minimally tested (I did not even set up a pinba server to check if the messages generated by the code are ok).
The GPB encoding code was taken from the protobuf library, but simplified to reduce bloat and be compatible with older php versions (original code used namespaces).

What about next steps? I can set this up on github as my own project, or it could be incorporated into pinba's main repo...

Bye
Gaetano

pinba_php.zip

gggeek

unread,
Dec 12, 2012, 3:16:05 PM12/12/12
to pinba-...@googlegroups.com

ps: code is now on github
Reply all
Reply to author
Forward
0 new messages