Skip to content

Custom encoder? #46

@ackintosh

Description

@ackintosh

I would like to send (partial) metrics stored the Registry in original JSON format differ from OpenMetrics, into an endpoint different from Prometheus server.

Here is a pseudo code, shows what I want to do:

        let mut registry = <Registry>::default();

        // (omitted)

        // Using the OpenMetrics format.
        let mut buffer = vec![];
        encode(&mut buffer, &registry).unwrap();

        // On the other hand, send (partial) metrics in JSON, into an endpoint different from Prometheus server.
        let mut data = vec![];
        for (descriptor, metric) in registry.iter() {
            if descriptor.name() == "__test__" {
                data.push(
                    translate_to_json(metric), // original JSON format
                );
            }
        }
        send(data); // send to an endpoint different from Prometheus server

I think I need to implement custom encoder, translate metrics to JSON format.

Please let me know if there is any good way. 🙏

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