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

Adding Resource to MetricRecord #1209

Merged
merged 10 commits into from
Oct 7, 2020

Conversation

codeboten
Copy link
Contributor

Description

Adding the Resource as a parameter to the Batcher (aka Processor see #1203). Not having the resource in the MetricRecord currently causes an issue retrieving resource information in the OTLP exporter.

Fixes #1208

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been update
  • Documentation has been updated

@codeboten codeboten marked this pull request as ready for review October 6, 2020 05:35
@codeboten codeboten requested a review from a team October 6, 2020 05:35
@codeboten codeboten changed the title WIP: Adding Resource to MetricRecord Adding Resource to MetricRecord Oct 6, 2020
@@ -49,7 +50,7 @@ def test_export(self):
)
labels = {"environment": "staging"}
aggregator = SumAggregator()
record = MetricRecord(metric, labels, aggregator)
record = MetricRecord(metric, labels, aggregator, meter.resource)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good to have a test that tests to see if the resource created in the metric record matches the resource in the meterprovider.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the ConsoleMetricsExporter to show the resource and updated the test to validate it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better to remove resource from Meter: codeboten#9

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The spec does specify that a Meter should bind an API with a resource: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/metrics/sdk.md#sdk-terminology, but I guess since we're not making use of the resource yet, it's ok to remove it here for now.

Copy link
Contributor

@lzchen lzchen left a comment

Choose a reason for hiding this comment

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

CHANGELOG?

@codeboten
Copy link
Contributor Author

CHANGELOG?

Added it, not sure how I forgot it.

@codeboten codeboten requested a review from lzchen October 6, 2020 17:22
Copy link
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

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

Please take a look at this: codeboten#9

Copy link
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@@ -352,8 +352,7 @@ def __init__(
instrumentation_info: "InstrumentationInfo",
):
self.instrumentation_info = instrumentation_info
self.processor = Processor(source.stateful)
self.resource = source.resource
self.processor = Processor(source.stateful, source.resource)
Copy link
Contributor

@lzchen lzchen Oct 6, 2020

Choose a reason for hiding this comment

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

Take a look at this comment. I believe we should actually decouple Tracer from TracerProvider, and equivalently, Meter from MeterProvider by removing the source attribute. We should be passing in configuration through the Provider into the constructor of both Tracer and Meter. resource would be one of those configurations. Not sure if you want to do this as part of this PR however.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like issue #1181 already tracks this work, I'd rather do this as a follow up to this PR.

@codeboten codeboten requested a review from lzchen October 7, 2020 15:15
@codeboten codeboten merged commit 8d7cba0 into open-telemetry:master Oct 7, 2020
srikanthccv pushed a commit to srikanthccv/opentelemetry-python that referenced this pull request Nov 1, 2020
* chore: fixing zone from which to fork a new zone

* chore: adding tests for creating zone

Co-authored-by: Mayur Kale <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Metrics SDK: The MetricRecord should have access to the resource
3 participants