Skip to content

Commit 6874e47

Browse files
authored
dynamic_modules: add generic accessors for access logger (envoyproxy#43647)
## Description --- **Commit Message:** dynamic_modules: add generic accessors for access logger **Additional Description:** **Risk Level:** Low **Testing:** CI **Docs Changes:** Added **Release Notes:** N/A --------- Signed-off-by: Rohit Agrawal <rohit.agrawal@databricks.com>
1 parent 9e8d0f3 commit 6874e47

File tree

7 files changed

+1781
-429
lines changed

7 files changed

+1781
-429
lines changed

source/extensions/access_loggers/dynamic_modules/abi_impl.cc

Lines changed: 579 additions & 284 deletions
Large diffs are not rendered by default.

source/extensions/dynamic_modules/abi/abi.h

Lines changed: 136 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ typedef enum envoy_dynamic_module_type_attribute_id {
373373
envoy_dynamic_module_type_attribute_id_XdsUpstreamHostMetadata,
374374
// xds.filter_chain_name
375375
envoy_dynamic_module_type_attribute_id_XdsFilterChainName,
376+
// health_check
377+
envoy_dynamic_module_type_attribute_id_HealthCheck,
376378
} envoy_dynamic_module_type_attribute_id;
377379

378380
/**
@@ -6165,16 +6167,21 @@ bool envoy_dynamic_module_callback_access_logger_get_header_value(
61656167
// ------------------ Access Logger Callbacks - Stream Info Basic --------------
61666168

61676169
/**
6170+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_int with
6171+
* envoy_dynamic_module_type_attribute_id_ResponseCode instead.
6172+
*
61686173
* Get the HTTP response code.
61696174
*
61706175
* @param logger_envoy_ptr is the pointer to the log context.
6171-
* @param response_code_out is the output parameter.
61726176
* @return the HTTP response code, or 0 if not available.
61736177
*/
61746178
uint32_t envoy_dynamic_module_callback_access_logger_get_response_code(
61756179
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr);
61766180

61776181
/**
6182+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6183+
* envoy_dynamic_module_type_attribute_id_ResponseCodeDetails instead.
6184+
*
61786185
* Get the response code details string.
61796186
*
61806187
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6206,6 +6213,9 @@ uint64_t envoy_dynamic_module_callback_access_logger_get_response_flags(
62066213
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr);
62076214

62086215
/**
6216+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6217+
* envoy_dynamic_module_type_attribute_id_RequestProtocol instead.
6218+
*
62096219
* Get the protocol (HTTP/1.0, HTTP/1.1, HTTP/2, HTTP/3).
62106220
*
62116221
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6241,6 +6251,21 @@ void envoy_dynamic_module_callback_access_logger_get_bytes_info(
62416251
envoy_dynamic_module_type_bytes_info* bytes_out);
62426252

62436253
/**
6254+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_bool with
6255+
* envoy_dynamic_module_type_attribute_id_HealthCheck instead.
6256+
*
6257+
* Check if this is a health check request.
6258+
*
6259+
* @param logger_envoy_ptr is the pointer to the log context.
6260+
* @return true if this is a health check, false otherwise.
6261+
*/
6262+
bool envoy_dynamic_module_callback_access_logger_is_health_check(
6263+
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr);
6264+
6265+
/**
6266+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6267+
* envoy_dynamic_module_type_attribute_id_XdsRouteName instead.
6268+
*
62446269
* Get the route name.
62456270
*
62466271
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6252,6 +6277,9 @@ bool envoy_dynamic_module_callback_access_logger_get_route_name(
62526277
envoy_dynamic_module_type_envoy_buffer* result);
62536278

62546279
/**
6280+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6281+
* envoy_dynamic_module_type_attribute_id_XdsVirtualHostName instead.
6282+
*
62556283
* Get the virtual cluster name.
62566284
*
62576285
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6263,25 +6291,21 @@ bool envoy_dynamic_module_callback_access_logger_get_virtual_cluster_name(
62636291
envoy_dynamic_module_type_envoy_buffer* result);
62646292

62656293
/**
6266-
* Check if this is a health check request.
6294+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_int with
6295+
* envoy_dynamic_module_type_attribute_id_UpstreamRequestAttemptCount instead.
62676296
*
6268-
* @param logger_envoy_ptr is the pointer to the log context.
6269-
* @return true if this is a health check, false otherwise.
6270-
*/
6271-
bool envoy_dynamic_module_callback_access_logger_is_health_check(
6272-
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr);
6273-
6274-
/**
62756297
* Get the upstream request attempt count.
62766298
*
62776299
* @param logger_envoy_ptr is the pointer to the log context.
6278-
* @param count_out is the output parameter.
62796300
* @return the attempt count, or 0 if not available.
62806301
*/
62816302
uint32_t envoy_dynamic_module_callback_access_logger_get_attempt_count(
62826303
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr);
62836304

62846305
/**
6306+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6307+
* envoy_dynamic_module_type_attribute_id_ConnectionTerminationDetails instead.
6308+
*
62856309
* Get the connection termination details.
62866310
*
62876311
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6391,6 +6415,9 @@ bool envoy_dynamic_module_callback_access_logger_get_upstream_host(
63916415
envoy_dynamic_module_type_envoy_buffer* result);
63926416

63936417
/**
6418+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6419+
* envoy_dynamic_module_type_attribute_id_UpstreamTransportFailureReason instead.
6420+
*
63946421
* Get the upstream transport failure reason.
63956422
*
63966423
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6411,40 +6438,46 @@ uint64_t envoy_dynamic_module_callback_access_logger_get_upstream_connection_id(
64116438
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr);
64126439

64136440
/**
6414-
* Get the upstream TLS version (e.g., "TLSv1.2", "TLSv1.3").
6441+
* Get the upstream TLS cipher suite. The buffer uses thread-local storage and is valid until the
6442+
* next call to this function or `get_downstream_tls_cipher` on the same thread.
64156443
*
64166444
* @param logger_envoy_ptr is the pointer to the log context.
64176445
* @param result is the output buffer.
6418-
* @return true if TLS version is available, false otherwise.
6446+
* @return true if cipher suite is available, false otherwise.
64196447
*/
6420-
bool envoy_dynamic_module_callback_access_logger_get_upstream_tls_version(
6448+
bool envoy_dynamic_module_callback_access_logger_get_upstream_tls_cipher(
64216449
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr,
64226450
envoy_dynamic_module_type_envoy_buffer* result);
64236451

64246452
/**
6425-
* Get the upstream TLS cipher suite. The buffer uses thread-local storage and is valid until the
6426-
* next call to this function or `get_downstream_tls_cipher` on the same thread.
6453+
* Get the upstream TLS session ID.
64276454
*
64286455
* @param logger_envoy_ptr is the pointer to the log context.
64296456
* @param result is the output buffer.
6430-
* @return true if cipher suite is available, false otherwise.
6457+
* @return true if session ID is available, false otherwise.
64316458
*/
6432-
bool envoy_dynamic_module_callback_access_logger_get_upstream_tls_cipher(
6459+
bool envoy_dynamic_module_callback_access_logger_get_upstream_tls_session_id(
64336460
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr,
64346461
envoy_dynamic_module_type_envoy_buffer* result);
64356462

64366463
/**
6437-
* Get the upstream TLS session ID.
6464+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6465+
* envoy_dynamic_module_type_attribute_id_UpstreamTlsVersion instead.
6466+
*
6467+
* Get the upstream TLS version (e.g., "TLSv1.2", "TLSv1.3").
64386468
*
64396469
* @param logger_envoy_ptr is the pointer to the log context.
64406470
* @param result is the output buffer.
6441-
* @return true if session ID is available, false otherwise.
6471+
* @return true if TLS version is available, false otherwise.
64426472
*/
6443-
bool envoy_dynamic_module_callback_access_logger_get_upstream_tls_session_id(
6473+
bool envoy_dynamic_module_callback_access_logger_get_upstream_tls_version(
64446474
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr,
64456475
envoy_dynamic_module_type_envoy_buffer* result);
64466476

64476477
/**
6478+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6479+
* envoy_dynamic_module_type_attribute_id_UpstreamSubjectPeerCertificate instead.
6480+
*
64486481
* Get the upstream peer certificate subject.
64496482
*
64506483
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6467,6 +6500,9 @@ bool envoy_dynamic_module_callback_access_logger_get_upstream_peer_issuer(
64676500
envoy_dynamic_module_type_envoy_buffer* result);
64686501

64696502
/**
6503+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6504+
* envoy_dynamic_module_type_attribute_id_UpstreamSubjectLocalCertificate instead.
6505+
*
64706506
* Get the upstream local certificate subject (Envoy's own certificate for the upstream connection).
64716507
*
64726508
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6478,6 +6514,9 @@ bool envoy_dynamic_module_callback_access_logger_get_upstream_local_subject(
64786514
envoy_dynamic_module_type_envoy_buffer* result);
64796515

64806516
/**
6517+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6518+
* envoy_dynamic_module_type_attribute_id_UpstreamSha256PeerCertificateDigest instead.
6519+
*
64816520
* Get the upstream peer certificate SHA256 fingerprint.
64826521
*
64836522
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6593,6 +6632,9 @@ bool envoy_dynamic_module_callback_access_logger_get_upstream_local_dns_san(
65936632
// ------------------ Access Logger Callbacks - Connection/TLS Info ------------
65946633

65956634
/**
6635+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_int with
6636+
* envoy_dynamic_module_type_attribute_id_ConnectionId instead.
6637+
*
65966638
* Get the connection ID.
65976639
*
65986640
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6602,6 +6644,9 @@ uint64_t envoy_dynamic_module_callback_access_logger_get_connection_id(
66026644
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr);
66036645

66046646
/**
6647+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_bool with
6648+
* envoy_dynamic_module_type_attribute_id_ConnectionMtls instead.
6649+
*
66056650
* Check if mTLS was used.
66066651
*
66076652
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6611,6 +6656,9 @@ bool envoy_dynamic_module_callback_access_logger_is_mtls(
66116656
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr);
66126657

66136658
/**
6659+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6660+
* envoy_dynamic_module_type_attribute_id_ConnectionRequestedServerName instead.
6661+
*
66146662
* Get the requested server name (SNI).
66156663
*
66166664
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6622,6 +6670,9 @@ bool envoy_dynamic_module_callback_access_logger_get_requested_server_name(
66226670
envoy_dynamic_module_type_envoy_buffer* result);
66236671

66246672
/**
6673+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6674+
* envoy_dynamic_module_type_attribute_id_ConnectionTlsVersion instead.
6675+
*
66256676
* Get the downstream TLS version.
66266677
*
66276678
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6633,6 +6684,9 @@ bool envoy_dynamic_module_callback_access_logger_get_downstream_tls_version(
66336684
envoy_dynamic_module_type_envoy_buffer* result);
66346685

66356686
/**
6687+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6688+
* envoy_dynamic_module_type_attribute_id_ConnectionSubjectPeerCertificate instead.
6689+
*
66366690
* Get the downstream peer certificate subject.
66376691
*
66386692
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6644,6 +6698,9 @@ bool envoy_dynamic_module_callback_access_logger_get_downstream_peer_subject(
66446698
envoy_dynamic_module_type_envoy_buffer* result);
66456699

66466700
/**
6701+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6702+
* envoy_dynamic_module_type_attribute_id_ConnectionSha256PeerCertificateDigest instead.
6703+
*
66476704
* Get the downstream peer certificate SHA256 fingerprint.
66486705
*
66496706
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6711,6 +6768,9 @@ bool envoy_dynamic_module_callback_access_logger_get_downstream_peer_fingerprint
67116768
envoy_dynamic_module_type_envoy_buffer* result);
67126769

67136770
/**
6771+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6772+
* envoy_dynamic_module_type_attribute_id_ConnectionSubjectLocalCertificate instead.
6773+
*
67146774
* Get the downstream local certificate subject (Envoy's own certificate).
67156775
*
67166776
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6870,6 +6930,9 @@ bool envoy_dynamic_module_callback_access_logger_get_filter_state(
68706930
envoy_dynamic_module_type_module_buffer key, envoy_dynamic_module_type_envoy_buffer* result);
68716931

68726932
/**
6933+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
6934+
* envoy_dynamic_module_type_attribute_id_RequestId instead.
6935+
*
68736936
* Get the request ID (x-request-id header value or generated).
68746937
*
68756938
* @param logger_envoy_ptr is the pointer to the log context.
@@ -6951,6 +7014,9 @@ bool envoy_dynamic_module_callback_access_logger_get_ja4_hash(
69517014
envoy_dynamic_module_type_envoy_buffer* result);
69527015

69537016
/**
7017+
* @deprecated Use envoy_dynamic_module_callback_access_logger_get_attribute_string with
7018+
* envoy_dynamic_module_type_attribute_id_ConnectionTransportFailureReason instead.
7019+
*
69547020
* Get the downstream transport failure reason.
69557021
*
69567022
* @param logger_envoy_ptr is the pointer to the log context.
@@ -7010,6 +7076,56 @@ bool envoy_dynamic_module_callback_access_logger_get_upstream_protocol(
70107076
int64_t envoy_dynamic_module_callback_access_logger_get_upstream_pool_ready_duration_ns(
70117077
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr);
70127078

7079+
// -----------------------------------------------------------------------------
7080+
// Access Logger Callbacks - Generic Attribute Accessors
7081+
// -----------------------------------------------------------------------------
7082+
// These callbacks provide a generic attribute-based interface for accessing
7083+
// stream info data, following the same pattern as the HTTP filter attribute
7084+
// accessors. They use the same envoy_dynamic_module_type_attribute_id enum.
7085+
7086+
/**
7087+
* envoy_dynamic_module_callback_access_logger_get_attribute_string is called by the module to get
7088+
* a string attribute value from the access log context. If the attribute is not accessible or the
7089+
* value is not a string, this returns false.
7090+
*
7091+
* @param logger_envoy_ptr is the pointer to the log context.
7092+
* @param attribute_id is the ID of the attribute.
7093+
* @param result is the pointer to the buffer where the string value will be stored.
7094+
* @return true if the operation is successful, false otherwise.
7095+
*/
7096+
bool envoy_dynamic_module_callback_access_logger_get_attribute_string(
7097+
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr,
7098+
envoy_dynamic_module_type_attribute_id attribute_id,
7099+
envoy_dynamic_module_type_envoy_buffer* result);
7100+
7101+
/**
7102+
* envoy_dynamic_module_callback_access_logger_get_attribute_int is called by the module to get
7103+
* an integer attribute value from the access log context. If the attribute is not accessible or the
7104+
* value is not an integer, this returns false.
7105+
*
7106+
* @param logger_envoy_ptr is the pointer to the log context.
7107+
* @param attribute_id is the ID of the attribute.
7108+
* @param result is the pointer to the variable where the integer value will be stored.
7109+
* @return true if the operation is successful, false otherwise.
7110+
*/
7111+
bool envoy_dynamic_module_callback_access_logger_get_attribute_int(
7112+
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr,
7113+
envoy_dynamic_module_type_attribute_id attribute_id, uint64_t* result);
7114+
7115+
/**
7116+
* envoy_dynamic_module_callback_access_logger_get_attribute_bool is called by the module to get
7117+
* a boolean attribute value from the access log context. If the attribute is not accessible or the
7118+
* value is not a boolean, this returns false.
7119+
*
7120+
* @param logger_envoy_ptr is the pointer to the log context.
7121+
* @param attribute_id is the ID of the attribute.
7122+
* @param result is the pointer to the variable where the boolean value will be stored.
7123+
* @return true if the operation is successful, false otherwise.
7124+
*/
7125+
bool envoy_dynamic_module_callback_access_logger_get_attribute_bool(
7126+
envoy_dynamic_module_type_access_logger_envoy_ptr logger_envoy_ptr,
7127+
envoy_dynamic_module_type_attribute_id attribute_id, bool* result);
7128+
70137129
// -----------------------------------------------------------------------------
70147130
// Access Logger Callbacks - Metrics
70157131
// -----------------------------------------------------------------------------

source/extensions/dynamic_modules/abi_impl.cc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,31 @@ __attribute__((weak)) uint32_t envoy_dynamic_module_callback_access_logger_get_a
18801880
return 0;
18811881
}
18821882

1883+
__attribute__((weak)) bool envoy_dynamic_module_callback_access_logger_get_attribute_bool(
1884+
envoy_dynamic_module_type_access_logger_envoy_ptr, envoy_dynamic_module_type_attribute_id,
1885+
bool*) {
1886+
IS_ENVOY_BUG("envoy_dynamic_module_callback_access_logger_get_attribute_bool: not implemented in "
1887+
"this context");
1888+
return false;
1889+
}
1890+
1891+
__attribute__((weak)) bool envoy_dynamic_module_callback_access_logger_get_attribute_int(
1892+
envoy_dynamic_module_type_access_logger_envoy_ptr, envoy_dynamic_module_type_attribute_id,
1893+
uint64_t*) {
1894+
IS_ENVOY_BUG("envoy_dynamic_module_callback_access_logger_get_attribute_int: not implemented in "
1895+
"this context");
1896+
return false;
1897+
}
1898+
1899+
__attribute__((weak)) bool envoy_dynamic_module_callback_access_logger_get_attribute_string(
1900+
envoy_dynamic_module_type_access_logger_envoy_ptr, envoy_dynamic_module_type_attribute_id,
1901+
envoy_dynamic_module_type_envoy_buffer*) {
1902+
IS_ENVOY_BUG(
1903+
"envoy_dynamic_module_callback_access_logger_get_attribute_string: not implemented in "
1904+
"this context");
1905+
return false;
1906+
}
1907+
18831908
__attribute__((weak)) void envoy_dynamic_module_callback_access_logger_get_bytes_info(
18841909
envoy_dynamic_module_type_access_logger_envoy_ptr, envoy_dynamic_module_type_bytes_info*) {
18851910
IS_ENVOY_BUG("envoy_dynamic_module_callback_access_logger_get_bytes_info: not implemented in "

0 commit comments

Comments
 (0)