Skip to content

mdatagen: attribute with type bytes generates erroneous unit tests #29923

@mmynk

Description

@mmynk

Component(s)

cmd/mdatagen

What happened?

Description

Defining an attribute in metadata.yaml with bytes type generates unit tests which do not compile. The schema defines bytes as a valid type for an attribute.

However, the unit tests tries to create byte arrays like:

mb.RecordMetric1(ts, bytes("attr1-val")

However, I believe it should be:

mb.RecordMetric1(ts, []byte("attr1-val")

Steps to Reproduce

Define an attribute in metadata.yaml as:

attributes:
  attr1:
    description: An attribute with type bytes
    type: bytes

metrics:
  metric1:
  desciption: A metric
  enabled: true
  sum:
    value_type: int
    monotonic: true
  unit: kg
  attributes:
    - attr1

Expected Result

A compiling unit test

Actual Result

A not compiling unit test

Collector version

v0.90.0

Environment information

Environment

OS: Ubuntu v22.04
Compiler(if manually compiled): go 1.21.3 linux/amd64

OpenTelemetry Collector configuration

No response

Log output

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcmd/mdatagenmdatagen command

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions