Skip to content

Package plugin: populate ValueList.DSNames when calling write callbacks. #91

Description

@pleimer

Plugin writes do not include new dsnames but instead default to value. To confirm this issue, I used the following code from the docs but changed the dsname. I listened for the messages using the amqp1.

package main

import (
        "context"
        "fmt"
        "time"

        "collectd.org/api"
        "collectd.org/plugin"
)

type examplePlugin struct{}

func (examplePlugin) Read(ctx context.Context) error {
        vl := &api.ValueList{
                Identifier: api.Identifier{
                        Host:   "example.com",
                        Plugin: "goplug",
                        Type:   "gauge",
                },
                Time:     time.Now(),
                Interval: 10 * time.Second,
                Values:   []api.Value{api.Gauge(42)},
                DSNames:  []string{"read"},
        }
        if err := plugin.Write(ctx, vl); err != nil {
                return fmt.Errorf("plugin.Write: %w", err)
        }

        return nil
}

func init() {
	plugin.RegisterRead("example", examplePlugin{})
}

func main() {}

Received Message

[
  {
    "values": [
      42
    ],
    "dstypes": [
      "gauge"
    ],
    "dsnames": [
      "value"
    ],
    "time": 1591894480.918,
    "interval": 10,
    "host": "example.com",
    "plugin": "goplug",
    "plugin_instance": "",
    "type": "gauge",
    "type_instance": ""
  }
]

Expected Message

[
  {
    "values": [
      42
    ],
    "dstypes": [
      "gauge"
    ],
    "dsnames": [
      "read"
    ],
    "time": 1591894480.918,
    "interval": 10,
    "host": "example.com",
    "plugin": "goplug",
    "plugin_instance": "",
    "type": "gauge",
    "type_instance": ""
  }
]

The dsnames field of the message does not container read, but rather the default string value

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions