Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
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
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
af7abf92
Commit
af7abf92
authored
9 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Enable runtime configuration of tracers
parent
8507e150
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/grpc/grpc.h
+10
-0
10 additions, 0 deletions
include/grpc/grpc.h
src/core/debug/trace.c
+24
-18
24 additions, 18 deletions
src/core/debug/trace.c
test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c
+4
-0
4 additions, 0 deletions
...ore/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c
with
38 additions
and
18 deletions
include/grpc/grpc.h
+
10
−
0
View file @
af7abf92
...
@@ -524,6 +524,16 @@ void grpc_server_shutdown_and_notify(grpc_server *server, void *tag);
...
@@ -524,6 +524,16 @@ void grpc_server_shutdown_and_notify(grpc_server *server, void *tag);
Implies grpc_server_shutdown() if one was not previously performed. */
Implies grpc_server_shutdown() if one was not previously performed. */
void
grpc_server_destroy
(
grpc_server
*
server
);
void
grpc_server_destroy
(
grpc_server
*
server
);
/** Enable or disable a tracer.
Tracers (usually controlled by the environment variable GRPC_TRACE)
allow printf-style debugging on GRPC internals, and are useful for
tracking down problems in the field.
Use of this function is not strictly thread-safe, but the
thread-safety issues raised by it should not be of concern. */
int
grpc_tracer_set_enabled
(
const
char
*
name
,
int
enabled
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
src/core/debug/trace.c
+
24
−
18
View file @
af7abf92
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
#include
<string.h>
#include
<string.h>
#include
<grpc/grpc.h>
#include
<grpc/support/alloc.h>
#include
<grpc/support/alloc.h>
#include
<grpc/support/log.h>
#include
<grpc/support/log.h>
#include
"src/core/support/env.h"
#include
"src/core/support/env.h"
...
@@ -80,27 +81,10 @@ static void parse(const char *s) {
...
@@ -80,27 +81,10 @@ static void parse(const char *s) {
char
**
strings
=
NULL
;
char
**
strings
=
NULL
;
size_t
nstrings
=
0
;
size_t
nstrings
=
0
;
size_t
i
;
size_t
i
;
tracer
*
t
;
split
(
s
,
&
strings
,
&
nstrings
);
split
(
s
,
&
strings
,
&
nstrings
);
for
(
i
=
0
;
i
<
nstrings
;
i
++
)
{
for
(
i
=
0
;
i
<
nstrings
;
i
++
)
{
const
char
*
s
=
strings
[
i
];
grpc_tracer_set_enabled
(
strings
[
i
],
1
);
if
(
0
==
strcmp
(
s
,
"all"
))
{
for
(
t
=
tracers
;
t
;
t
=
t
->
next
)
{
*
t
->
flag
=
1
;
}
}
else
{
int
found
=
0
;
for
(
t
=
tracers
;
t
;
t
=
t
->
next
)
{
if
(
0
==
strcmp
(
s
,
t
->
name
))
{
*
t
->
flag
=
1
;
found
=
1
;
}
}
if
(
!
found
)
{
gpr_log
(
GPR_ERROR
,
"Unknown trace var: '%s'"
,
s
);
}
}
}
}
for
(
i
=
0
;
i
<
nstrings
;
i
++
)
{
for
(
i
=
0
;
i
<
nstrings
;
i
++
)
{
...
@@ -121,3 +105,25 @@ void grpc_tracer_init(const char *env_var) {
...
@@ -121,3 +105,25 @@ void grpc_tracer_init(const char *env_var) {
gpr_free
(
t
);
gpr_free
(
t
);
}
}
}
}
int
grpc_tracer_set_enabled
(
const
char
*
name
,
int
enabled
)
{
tracer
*
t
;
if
(
0
==
strcmp
(
name
,
"all"
))
{
for
(
t
=
tracers
;
t
;
t
=
t
->
next
)
{
*
t
->
flag
=
1
;
}
}
else
{
int
found
=
0
;
for
(
t
=
tracers
;
t
;
t
=
t
->
next
)
{
if
(
0
==
strcmp
(
name
,
t
->
name
))
{
*
t
->
flag
=
enabled
;
found
=
1
;
}
}
if
(
!
found
)
{
gpr_log
(
GPR_ERROR
,
"Unknown trace var: '%s'"
,
name
);
return
0
;
/* early return */
}
}
return
1
;
}
This diff is collapsed.
Click to expand it.
test/core/end2end/fixtures/chttp2_socket_pair_with_grpc_trace.c
+
4
−
0
View file @
af7abf92
...
@@ -147,6 +147,10 @@ int main(int argc, char **argv) {
...
@@ -147,6 +147,10 @@ int main(int argc, char **argv) {
grpc_test_init
(
argc
,
argv
);
grpc_test_init
(
argc
,
argv
);
grpc_init
();
grpc_init
();
GPR_ASSERT
(
0
==
grpc_tracer_set_enabled
(
"also-doesnt-exist"
,
0
));
GPR_ASSERT
(
1
==
grpc_tracer_set_enabled
(
"http"
,
1
));
GPR_ASSERT
(
1
==
grpc_tracer_set_enabled
(
"all"
,
1
));
for
(
i
=
0
;
i
<
sizeof
(
configs
)
/
sizeof
(
*
configs
);
i
++
)
{
for
(
i
=
0
;
i
<
sizeof
(
configs
)
/
sizeof
(
*
configs
);
i
++
)
{
grpc_end2end_tests
(
configs
[
i
]);
grpc_end2end_tests
(
configs
[
i
]);
}
}
...
...
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