attributesprocessor

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

README

Attributes Processor

Supported pipeline types: traces

The attributes processor modifies attributes of a span. Please refer to config.go for the config spec.

It optionally supports the ability to include/exclude spans.

It takes a list of actions which are performed in order specified in the config. The supported actions are:

  • insert: Inserts a new attribute in spans where the key does not already exist.
  • update: Updates an attribute in spans where the key does exist.
  • upsert: Performs insert or update. Inserts a new attribute in spans where the key does not already exist and updates an attribute in spans where the key does exist.
  • delete: Deletes an attribute from a span.
  • hash: Hashes (SHA1) an existing attribute value.

For the actions insert, update and upsert,

  • key is required
  • one of value or from_attribute is required
  • action is required.
  # Key specifies the attribute to act upon.
- key: <key>
  action: {insert, update, upsert}
  # Value specifies the value to populate for the key.
  # The type is inferred from the configuration.
  value: <value>

  # Key specifies the attribute to act upon.
- key: <key>
  action: {insert, update, upsert}
  # FromAttribute specifies the attribute from the span to use to populate
  # the value. If the attribute doesn't exist, no action is performed.
  from_attribute: <other key>

For the delete action,

  • key is required
  • action: delete is required.
# Key specifies the attribute to act upon.
- key: <key>
  action: delete

For the hash action,

  • key is required
  • action: hash is required.
# Key specifies the attribute to act upon.
- key: <key>
  action: hash

The list of actions can be composed to create rich scenarios, such as back filling attribute, copying values to a new key, redacting sensitive information. The following is a sample configuration.

processors:
  attributes/example:
    actions:
      - key: db.table
        action: delete
      - key: redacted_span
        value: true
        action: upsert
      - key: copy_key
        from_attribute: key_original
        action: update
      - key: account_id
        value: 2245
      - key: account_password
        action: delete
      - key: account_email
        action: hash

Refer to config.yaml for detailed examples on using the processor.

Documentation

Overview

Package attributesprocessor contains the logic to modify attributes of a span. It supports insert, update, upsert and delete as actions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SHA1AttributeHasher

func SHA1AttributeHasher(attr pdata.AttributeValue)

SHA1AttributeHasher hashes an AttributeValue using SHA1 and returns a hashed version of the attribute. In practice, this would mostly be used for string attributes but we support all types for completeness/correctness and eliminate any surprises.

Types

type Action

type Action string

Action is the enum to capture the four types of actions to perform on an attribute.

const (
	// INSERT adds the key/value to spans when the key does not exist.
	// No action is applied to spans where the key already exists.
	INSERT Action = "insert"

	// UPDATE updates an existing key with a value. No action is applied
	// to spans where the key does not exist.
	UPDATE Action = "update"

	// UPSERT performs the INSERT or UPDATE action. The key/value is
	// insert to spans that did not originally have the key. The key/value is
	// updated for spans where the key already existed.
	UPSERT Action = "upsert"

	// DELETE deletes the attribute from the span. If the key doesn't exist,
	//no action is performed.
	DELETE Action = "delete"

	// HASH calculates the SHA-1 hash of an existing value and overwrites the value
	// with it's SHA-1 hash result.
	HASH Action = "hash"
)

type ActionKeyValue

type ActionKeyValue struct {
	// Key specifies the attribute to act upon.
	// This is a required field.
	Key string `mapstructure:"key"`

	// Value specifies the value to populate for the key.
	// The type of the value is inferred from the configuration.
	Value interface{} `mapstructure:"value"`

	// FromAttribute specifies the attribute from the span to use to populate
	// the value. If the attribute doesn't exist, no action is performed.
	FromAttribute string `mapstructure:"from_attribute"`

	// Action specifies the type of action to perform.
	// The set of values are {INSERT, UPDATE, UPSERT, DELETE, HASH}.
	// Both lower case and upper case are supported.
	// INSERT - Inserts the key/value to spans when the key does not exist.
	//          No action is applied to spans where the key already exists.
	//          Either Value or FromAttribute must be set.
	// UPDATE - Updates an existing key with a value. No action is applied
	//          to spans where the key does not exist.
	//          Either Value or FromAttribute must be set.
	// UPSERT - Performs insert or update action depending on the span
	//          containing the key. The key/value is insert to spans
	//          that did not originally have the key. The key/value is updated
	//          for spans where the key already existed.
	//          Either Value or FromAttribute must be set.
	// DELETE - Deletes the attribute from the span. If the key doesn't exist,
	//          no action is performed.
	// This is a required field.
	Action Action `mapstructure:"action"`
}

ActionKeyValue specifies the attribute key to act upon.

type Config

type Config struct {
	configmodels.ProcessorSettings `mapstructure:",squash"`

	filterspan.MatchConfig `mapstructure:",squash"`

	// Actions specifies the list of attributes to act on.
	// The set of actions are {INSERT, UPDATE, UPSERT, DELETE}.
	// This is a required field.
	Actions []ActionKeyValue `mapstructure:"actions"`
}

Config specifies the set of attributes to be inserted, updated, upserted and deleted and the properties to include/exclude a span from being processed. This processor handles all forms of modifications to attributes within a span. Prior to any actions being applied, each span is compared against the include properties and then the exclude properties if they are specified. This determines if a span is to be processed or not. The list of actions is applied in order specified in the configuration.

type Factory

type Factory struct {
}

Factory is the factory for Attributes processor.

func (*Factory) CreateDefaultConfig

func (f *Factory) CreateDefaultConfig() configmodels.Processor

CreateDefaultConfig creates the default configuration for the processor. Note: This isn't a valid configuration because the processor would do no work.

func (*Factory) CreateMetricsProcessor

CreateMetricsProcessor creates a metrics processor based on this config.

func (*Factory) CreateTraceProcessor

CreateTraceProcessor creates a trace processor based on this config.

func (*Factory) Type

func (f *Factory) Type() configmodels.Type

Type gets the type of the config created by this factory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL