Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
001b7f48
Commit
001b7f48
authored
9 years ago
by
Matt Jordan
Committed by
Gerrit Code Review
9 years ago
Browse files
Options
Downloads
Plain Diff
Merge "res_statsd: Add functions that support variable arguments" into 13
parents
0f88f909
3354b325
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/asterisk/statsd.h
+46
-2
46 additions, 2 deletions
include/asterisk/statsd.h
res/res_statsd.c
+48
-0
48 additions, 0 deletions
res/res_statsd.c
with
94 additions
and
2 deletions
include/asterisk/statsd.h
+
46
−
2
View file @
001b7f48
...
...
@@ -57,9 +57,31 @@ AST_OPTIONAL_API(void, ast_statsd_log_string, (const char *metric_name,
/*!
* \brief Send a stat to the configured statsd server.
* \since 13.7.0
*
* The is the most flexible function for sending a message to the statsd server,
* but also the least easy to use. See ast_statsd_log() or
* This is the most flexible function for sending a message to the statsd
* server. In addition to allowing the string value and sample rate to be specified,
* the metric_name can be formed as a printf style string with variable
* arguments.
*
* \param metric_name Format string (UTF-8) specifying the name of the metric.
* \param metric_type Type of metric to send.
* \param value Value to send.
* \param sample_rate Percentage of samples to send.
*
* Example Usage:
* \code
* ast_statsd_log_string_va(AST_STATSD_GUAGE, "+1", 1.0, "endpoints.states.%s", state_name);
* \endcode
*/
AST_OPTIONAL_API_ATTR
(
void
,
format
(
printf
,
1
,
5
),
ast_statsd_log_string_va
,
(
const
char
*
metric_name
,
const
char
*
metric_type
,
const
char
*
value
,
double
sample_rate
,
...),
{});
/*!
* \brief Send a stat to the configured statsd server.
*
* The is nearly the most flexible function for sending a message to the statsd
* server, but also the least easy to use. See ast_statsd_log() or
* ast_statsd_log_sample() for a slightly more convenient interface.
*
* \param metric_name String (UTF-8) name of the metric.
...
...
@@ -71,6 +93,28 @@ AST_OPTIONAL_API(void, ast_statsd_log_string, (const char *metric_name,
AST_OPTIONAL_API
(
void
,
ast_statsd_log_full
,
(
const
char
*
metric_name
,
const
char
*
metric_type
,
intmax_t
value
,
double
sample_rate
),
{});
/*!
* \brief Send a stat to the configured statsd server.
* \since 13.7.0
*
* This is the most flexible function for sending a message to the statsd
* server. In addition to allowing the value and sample rate to be specified,
* the metric_name can be formed as a printf style string with variable
* arguments.
*
* \param metric_name Format string (UTF-8) specifying the name of the metric.
* \param metric_type Type of metric to send.
* \param value Value to send.
* \param sample_rate Percentage of samples to send.
*
* Example Usage:
* \code
* ast_statsd_log_full_va(AST_STATSD_TIMER, rtt, 1.0, "endpoint.%s.rtt", endpoint_name);
* \endcode
*/
AST_OPTIONAL_API_ATTR
(
void
,
format
(
printf
,
1
,
5
),
ast_statsd_log_full_va
,
(
const
char
*
metric_name
,
const
char
*
metric_type
,
intmax_t
value
,
double
sample_rate
,
...),
{});
/*!
* \brief Send a stat to the configured statsd server.
* \param metric_name String (UTF-8) name of the metric.
...
...
This diff is collapsed.
Click to expand it.
res/res_statsd.c
+
48
−
0
View file @
001b7f48
...
...
@@ -160,6 +160,54 @@ void AST_OPTIONAL_API_NAME(ast_statsd_log_full)(const char *metric_name,
}
AST_THREADSTORAGE
(
statsd_buf
);
void
AST_OPTIONAL_API_NAME
(
ast_statsd_log_string_va
)(
const
char
*
metric_name
,
const
char
*
metric_type
,
const
char
*
value
,
double
sample_rate
,
...)
{
struct
ast_str
*
buf
;
va_list
ap
;
int
res
;
buf
=
ast_str_thread_get
(
&
statsd_buf
,
128
);
if
(
!
buf
)
{
return
;
}
va_start
(
ap
,
sample_rate
);
res
=
ast_str_set_va
(
&
buf
,
0
,
metric_name
,
ap
);
va_end
(
ap
);
if
(
res
==
AST_DYNSTR_BUILD_FAILED
)
{
return
;
}
ast_statsd_log_string
(
ast_str_buffer
(
buf
),
metric_type
,
value
,
sample_rate
);
}
void
AST_OPTIONAL_API_NAME
(
ast_statsd_log_full_va
)(
const
char
*
metric_name
,
const
char
*
metric_type
,
intmax_t
value
,
double
sample_rate
,
...)
{
struct
ast_str
*
buf
;
va_list
ap
;
int
res
;
buf
=
ast_str_thread_get
(
&
statsd_buf
,
128
);
if
(
!
buf
)
{
return
;
}
va_start
(
ap
,
sample_rate
);
res
=
ast_str_set_va
(
&
buf
,
0
,
metric_name
,
ap
);
va_end
(
ap
);
if
(
res
==
AST_DYNSTR_BUILD_FAILED
)
{
return
;
}
ast_statsd_log_full
(
ast_str_buffer
(
buf
),
metric_type
,
value
,
sample_rate
);
}
void
AST_OPTIONAL_API_NAME
(
ast_statsd_log
)(
const
char
*
metric_name
,
const
char
*
metric_type
,
intmax_t
value
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment