Created
February 27, 2017 01:08
-
-
Save taotetek/5a0dcd0b4cd083af7b4ae702653100ea to your computer and use it in GitHub Desktop.
CZMQ code instrumented with Prometheus via Go shared lib.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <czmq.h> | |
#include "prometheuz.h" | |
void *sender(void *arg) { | |
zsock_t *sender = zsock_new_push ("inproc://demo"); | |
while (1) { | |
zstr_send (sender, "hello"); | |
} | |
} | |
int main(int argc, char *argv[]) { | |
GoString namespace = {"zmq", 3}; | |
StartPrometheuz(namespace); | |
zsock_t *receiver = zsock_new_pull ("inproc://demo"); | |
pthread_t tid[1]; | |
pthread_create (&(tid[0]), NULL, &sender, NULL); | |
printf("starting\n"); | |
int i = 0; | |
while (1) { | |
char *msg = zstr_recv (receiver); | |
free (msg); | |
i++; | |
// cgo overhead is a little high so lets call every 1000 messages | |
if (!(i % 1000)) { | |
// function exported from Go | |
AddMsgs(1000); | |
// function exported from Go | |
AddBytes(50000); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment