Skip to content

Make the metric instrument constructors base off MeterProvider implementation #1182

@lzchen

Description

@lzchen

From this comment, the constructors of metric instruments in the SDK need to pass in the explicit type. This will make it so that the implementation of the resulting metric instrument created is dependent on the type that is passed in, not based off of what MeterProvider implementation is used (and in turn, Meter).

For example, if I want to construct a ValueRecorder, and I expect the SDK behaviour, but I do not want to break the user if they are using the api implementation (or any other implementation), I am not actually able to do this. To utilize the SDK ValueRecorder, I MUST pass in this class type to create metric in the SDK. This is bad because then the code will HAVE to take a dependency on the SDK.

The solution is to have explicit create methods for each instrument type. The original reason why we had a generic create_metric was so we did not have to duplicate this code. See java or go.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions