Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support unmarshalling JSON-formatted CloudWatch Metric Streams #38407

Closed
axw opened this issue Mar 5, 2025 · 1 comment · Fixed by #38419
Closed

Support unmarshalling JSON-formatted CloudWatch Metric Streams #38407

axw opened this issue Mar 5, 2025 · 1 comment · Fixed by #38419
Labels
enhancement New feature or request

Comments

@axw
Copy link
Contributor

axw commented Mar 5, 2025

Component(s)

extension/encoding/awscloudwatchmetricstreamsencoding

Is your feature request related to a problem? Please describe.

I would like to be able to use the awscloudwatchmetricstreamsencoding extension to unmarshal JSON-formatted metrics from CloudWatch Metric Streams.

Describe the solution you'd like

Implement this:

func (formatJSONUnmarshaler) UnmarshalMetrics([]byte) (pmetric.Metrics, error) {
// TODO implement
return pmetric.Metrics{}, fmt.Errorf("UnmarshalMetrics unimplemented for format %q", formatJSON)
}

Describe alternatives you've considered

No response

Additional context

No response

@axw axw added enhancement New feature or request needs triage New item requiring triage labels Mar 5, 2025
@axw
Copy link
Contributor Author

axw commented Mar 5, 2025

The logic can be extracted from https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/awsfirehosereceiver/internal/unmarshaler/cwmetricstream

The receiver should probably then depend on the extension package to have support for the encoding built-in.

@atoulme atoulme removed the needs triage New item requiring triage label Mar 8, 2025
MovieStoreGuy added a commit that referenced this issue Mar 11, 2025

Verified

This commit was signed with the committer’s verified signature.
KinectTheUnknown David-Joseph Xayavong
…rshalling JSON-formatted CloudWatch Metric Streams (#38419)

#### Description

This PR implements the translation of JSON-formatted CloudWatch Metric
Streams into OpenTelemetry metrics.

It receives a record, and splits that record by each new line. Each of
these parts will correspond to a JSON CloudWatch Metric Stream. It then
translates this metric into an OpenTelemetry metric. The obtained
metrics from the record are returned.

It follows the same logic as
https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/awsfirehosereceiver/internal/unmarshaler/cwmetricstream.

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes
#38407.

<!--Describe what testing was performed and which tests were added.-->
#### Testing

I have added unit tests to:

- Check we can extract open telemetry metrics from JSON valid cloudwatch
metric stream
- Check there are no metrics extracted if the data does not have
expected format (for example, no unit or no value)
- Check we can obtain metrics from a record containing both valid and
invalid cloudwatch metric stream.

You can easily read and study what we get to what we return in the
`testdata/json` files of the extension.

<!--Describe the documentation added.-->
#### Documentation

The coding comments and the README file should be enough for
documentation.

---------

Co-authored-by: Andrew Wilkins <axwalk@gmail.com>
Co-authored-by: Sean Marciniak <30928402+MovieStoreGuy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants