Skip to content

C++ SDK creates invalid metrics label name records for Prometheus #297

@erichsueh3

Description

@erichsueh3

Is your feature request related to a problem?
Yes. Currently, when a record that is created by the C++ Metrics SDK, it is created with label names that contain characters which are invalid for a Prometheus backend. When an instrument is created, and add() or record() or observe() is called on these instruments, a KeyValueIterable containing labels is passed to these methods. When these methods are called, the labels are translated to a string, but the current translation is to a string of format {“key”:“\”value\“”}. These double quote characters, which are escaped by \, are invalid in Prometheus.

The Prometheus Exporter (Filed as PRs and under review at #240, #280, #282, #263) takes these records that are created by the C++ Metrics SDK and exports them to a Prometheus backend. The Prometheus backend will scrape an HTTP endpoint exposed by the Prometheus Exporter for a collection of these records with labels invalid in Prometheus; it does not recognize these label names as valid and as a result, no records are recognized as valid and nothing will be scraped.

Describe the solution you'd like
Modify the function KvToString() in instrument.h to remove the addition of the escaped double quote characters to the label string. This way, Prometheus is able to collect on records created by the C++ SDK.

Describe alternatives you've considered
Alternatively, we could modify the Prometheus Exporter to accept these names. When we sanitize a name, we can add functionality to remove double quote characters.

cc @alolita, @reyang, @pyohannes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions