Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishevent
Commits
9372a68a
Commit
9372a68a
authored
Apr 02, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement and test formatters for %{Varnish:time_firstbyte}x
parent
5353d764
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
25 deletions
+56
-25
format.c
src/format.c
+23
-25
format.h
src/format.h
+3
-0
test_format.c
src/test/test_format.c
+30
-0
No files found.
src/format.c
View file @
9372a68a
...
...
@@ -277,7 +277,7 @@ format_h_##dir(tx_t *tx, char *name, enum VSL_tag_e tag, char **s, \
FORMAT_h
(
client
,
ReqStart
,
0
)
FORMAT_h
(
backend
,
Backend
,
2
)
static
void
static
inline
void
format_IO_client
(
tx_t
*
tx
,
int
req_fld
,
int
pipe_fld
,
char
**
s
,
size_t
*
len
)
{
int
field
;
...
...
@@ -547,41 +547,39 @@ format_Xt(tx_t *tx, char *name, enum VSL_tag_e tag, char **s, size_t *len)
format_tim
(
tx
,
(
const
char
*
)
name
,
s
,
len
);
}
#if 0
static
inline
void
format_Xttfb
(
tx_t
*
tx
,
const
char
*
tname
,
char
**
s
,
size_t
*
len
)
{
char
*
ts
;
static void
format_Xttfb_client(logline_t *ll, char *name, enum VSL_tag_e tag,
char **s, size_t *len)
ts
=
get_hdr
(
tx
,
SLT_Timestamp
,
tname
);
if
(
ts
==
NULL
)
return
;
*
s
=
get_fld
(
ts
,
1
);
*
len
=
strlen
(
*
s
);
}
void
format_Xttfb_client
(
tx_t
*
tx
,
char
*
name
,
enum
VSL_tag_e
tag
,
char
**
s
,
size_t
*
len
)
{
(
void
)
name
;
(
void
)
tag
;
if (TAG(ll,SLT_ReqEnd).len)
RETURN_FLD(TAG(ll,SLT_ReqEnd), 5, s, len);
format_Xttfb
(
tx
,
"Process"
,
s
,
len
);
}
#ifdef BESTATS
static void
format_Xttfb_backend(logline_t *ll, char *name, enum VSL_tag_e tag,
char **s, size_t *len)
void
format_Xttfb_backend
(
tx_t
*
tx
,
char
*
name
,
enum
VSL_tag_e
tag
,
char
**
s
,
size_t
*
len
)
{
(
void
)
name
;
(
void
)
tag
;
if (TAG(ll,SLT_BackendReq).len && TAG(ll,SLT_Fetch_Hdr).len) {
double req_end, fetch_start;
errno = 0;
req_end = strtod(get_fld(&TAG(ll,SLT_BackendReq), 2), NULL);
AZ(errno);
fetch_start = strtod(get_fld(&TAG(ll,SLT_Fetch_Hdr), 2), NULL);
AZ(errno);
sprintf(scratch, "%.9f", fetch_start - req_end);
*s = scratch;
*len = strlen(scratch);
}
format_Xttfb
(
tx
,
"Beresp"
,
s
,
len
);
}
#endif
#if 0
static void
format_VCL_disp(logline_t *ll, char *name, enum VSL_tag_e tag,
...
...
src/format.h
View file @
9372a68a
...
...
@@ -91,3 +91,6 @@ formatter_f format_Xo_client;
formatter_f
format_Xo_backend
;
formatter_f
format_Xt
;
formatter_f
format_Xttfb_client
;
formatter_f
format_Xttfb_backend
;
src/test/test_format.c
View file @
9372a68a
...
...
@@ -1030,6 +1030,35 @@ static const char
return
NULL
;
}
static
const
char
*
test_format_Xttfb
(
void
)
{
tx_t
tx
;
logline_t
rec
;
chunk_t
chunk
;
char
*
str
;
size_t
len
;
printf
(
"... testing format_Xttfb_*()
\n
"
);
init_tx_rec_chunk
(
&
tx
,
&
rec
,
&
chunk
);
MAN
(
chunk
.
data
);
#define TS_PROCESS_PAYLOAD "Process: 1427979230.712416 0.000166 0.000166"
set_record_data
(
&
rec
,
&
chunk
,
TS_PROCESS_PAYLOAD
,
SLT_Timestamp
);
format_Xttfb_client
(
&
tx
,
NULL
,
SLT__Bogus
,
&
str
,
&
len
);
MASSERT
(
strcmp
(
str
,
"0.000166"
)
==
0
);
MASSERT
(
len
==
8
);
#define TS_BERESP_HDR_PAYLOAD "Beresp: 1427979243.588828 0.002837 0.002743"
set_record_data
(
&
rec
,
&
chunk
,
TS_BERESP_HDR_PAYLOAD
,
SLT_Timestamp
);
format_Xttfb_backend
(
&
tx
,
NULL
,
SLT__Bogus
,
&
str
,
&
len
);
MASSERT
(
strcmp
(
str
,
"0.002837"
)
==
0
);
MASSERT
(
len
==
8
);
return
NULL
;
}
static
const
char
*
all_tests
(
void
)
{
...
...
@@ -1057,6 +1086,7 @@ static const char
mu_run_test
(
test_format_Xi
);
mu_run_test
(
test_format_Xo
);
mu_run_test
(
test_format_Xt
);
mu_run_test
(
test_format_Xttfb
);
return
NULL
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment