Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Add Metric Support #10

Merged
merged 6 commits into from
Apr 28, 2020
Merged

Conversation

MrAlias
Copy link
Contributor

@MrAlias MrAlias commented Apr 14, 2020

Add Export method to the Exporter to implement the "go.opentelemetry.io/otel/sdk/export/metric".Exporter interface.

Add transform logic to the transform package to handle OpenTelemetry Records and transform them into New Relic Metrics.

Update existing end-to-end test validate metric exporting.

Copy link
Contributor

@lykkin lykkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

desc := r.Descriptor()
attrs := attributes(service, desc, r.Labels())
switch a := r.Aggregator().(type) {
case aggregator.MinMaxSumCount:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a complete enumeration of aggregator types at this point, or is this just a starting point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the only ones currently exported. There are a few other aggregations, but these are the only two used for all (3) current instruments.

@@ -7,6 +7,8 @@ const (
errorCodeAttrKey = "error.code"
errorMessageAttrKey = "error.message"

serviceNameAttrKey = "service.name"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment: It's interesting to me that our telemetry sdk adds the service.name attr for spans but not for metrics.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the ServiceName is a first class field in the JSON span structure we send to New Relic, so it became a part of the Span struct in the SDK. The inclusion in the metric is just by knowing it needs to be in the free form attributes. Which makes sense why it is kind of the same way in the SDK. Might be worth refactoring the design in the SDK, but the same could be said of the Metric API I guess. 🤷

case aggregator.Sum:
return sum(desc, attrs, a)
}
return nil, ErrUnimplementedAgg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens in otel when this error is returned? Do the metrics get retried next harvest period?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's ultimately going to be up to the configured Controller. This error will get rolled up all the way back to the caller of the Export method this exporter implements on the Exporter interface. This method is called by the Controller in the OpenTelemetry Go SDK. The default "push" Controller (currently the only controller) has a configurable error handler function that by default prints the error to STDERR.

Copy link
Contributor

@purple4reina purple4reina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been unable to thoroughly test this end to end with a sample app due to time constraints. However, I believe that you have already addressed all of my concerns. They are:

  1. Does otel send metrics as a delta or cumulative?
  2. If an error is returned from Export, what happens? Will the metrics be retried again with the next cycle? (if so, this would be bad)
  3. Bumping the version of otel in the go.mod file. This was a concern for me because in my attempts to set up a sample app, I kept getting strange compile errors complaining about missing fields. I made sure to use this branch for testing, and then those seemed to have gone away.

@purple4reina purple4reina merged commit 7832f2a into newrelic:master Apr 28, 2020
@MrAlias MrAlias deleted the add-init-metric-support branch April 28, 2020 22:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants