kong.telemetry.log

The telemetry module provides capabilities for telemetry operations.

kong.telemetry.log(plugin_name, plugin_config, message_type, message, attributes)

Records a structured log entry, to be reported via the OpenTelemetry plugin.

This function has a dependency on the OpenTelemetry plugin, which must be configured to report OpenTelemetry logs.

Phases

  • rewrite, access, balancer, timer, header_filter, response, body_filter, log

Parameters

  • plugin_name (string): the name of the plugin
  • plugin_config (table): the plugin configuration
  • message_type (string): the type of the log message, useful to categorize the log entry
  • message (string): the log message
  • attributes (table): structured information to be included in the attributes field of the log entry

Usage

  1. local attributes = {
  2. http_method = kong.request.get_method()
  3. ["node.id"] = kong.node.get_id(),
  4. hostname = kong.node.get_hostname(),
  5. }
  6. local ok, err = kong.telemetry.log("my_plugin", conf, "result", "successful operation", attributes)