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

Add Resource SDK #101

Merged
merged 1 commit into from
Jun 6, 2020
Merged

Add Resource SDK #101

merged 1 commit into from
Jun 6, 2020

Conversation

lalex
Copy link
Contributor

@lalex lalex commented May 27, 2020

This is an implementation of Resource SDK (#92) and recently added InstrumentationLibrary (TracerCreation).

In this PR minimal changes were made to TracerProvider and Tracer to simplify a merge with the concurrent PRs.

The class for Resource is called ResourceInfo because resource is the reserved word in PHP and it makes difficulties for code analysis tools. Any suggestion on name are welcome.

In specification Resource is proposed as immutable object. Now it is not fully immutable since it uses Attributes collection which is mutable.

@codecov
Copy link

codecov bot commented May 27, 2020

Codecov Report

Merging #101 into master will increase coverage by 0.61%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #101      +/-   ##
============================================
+ Coverage     90.38%   91.00%   +0.61%     
- Complexity       53       57       +4     
============================================
  Files            15       16       +1     
  Lines           364      389      +25     
============================================
+ Hits            329      354      +25     
  Misses           35       35              
Impacted Files Coverage Δ Complexity Δ
tests/unit/Resource/ResourceTest.php 100.00% <100.00%> (ø) 4.00 <4.00> (?)
tests/unit/Trace/TracingTest.php 98.42% <100.00%> (+0.01%) 10.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aa8e52a...b245af1. Read the comment docs.

@bobstrecansky
Copy link
Collaborator

Lalex,

I think this is a very great start on the Resource SDK and TracerCreation Library! You've done a great job of being conscientious of impacting changes; thank you for doing that.

I like your recommendation of ResourceInfo, it seems like it still gets the point across while being far enough away from the reserved word. It's unfortunate in this case that resource is a reserved word in PHP in this particular case. We should potentially put a comment about this inline just for future reference; I made a comment where I think you may be able to add this information.

We should probably create a ticket to make sure that the Attributes collection isn't mutable if that's required to keep the Resource as an immutable object. The spec doesn't explicitly mention that the Attributes collection should be immutable, so maybe we should ask the spec maintainers if that was intentional.

/**
* Service
*/
public const SERVICE_NAME = 'service.name';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we somehow denote whether or not these are required? Might be as simple as a comment after the ; - Just thinking for when we are trying to grok them in the future.

/**
* Kubernetes
*/
public const K8S_CLUSTER_NAME = 'k8s.cluster.name';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Surprising that Github highlights these differently than the other public const variables. My editor did not do the same thing.


public function getAttributes(): Attributes
{
// todo: Attributes::setAttribute() breaks immutability of the Resource
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you planning on breaking this todo out into a separate PR, or are you planning on including it as part of this draft?

@@ -43,6 +49,8 @@ class TracerProvider implements API\TracerProvider
}

$this->spanProcessors = $spanProcessors;
// todo: get Resource from arguments
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you planning on breaking these todos out into a separate PR, or are you planning on including it as part of this draft?

* A Resource is an immutable representation of the entity producing telemetry. For example, a process producing telemetry
* that is running in a container on Kubernetes has a Pod name, it is in a namespace and possibly is part of a Deployment
* which also has a name. All three of these attributes can be included in the Resource.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be prudent to make a note about how we are using ResourceInfo rather than resource here because of the reserved PHP word.

@bobstrecansky
Copy link
Collaborator

@lalex do you have additional thoughts here?

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jun 5, 2020

CLA Check
The committers are authorized under a signed CLA.

@lalex lalex marked this pull request as ready for review June 5, 2020 22:05
@lalex
Copy link
Contributor Author

lalex commented Jun 5, 2020

@bobstrecansky I've merged the latest master and resolved todos and notes.

Copy link
Collaborator

@bobstrecansky bobstrecansky left a comment

Choose a reason for hiding this comment

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

LGTM

@bobstrecansky
Copy link
Collaborator

Verifying that no one else has any qualms in the gitter channel; will merge afterwords.

@bobstrecansky bobstrecansky merged commit 61fa1cf into open-telemetry:master Jun 6, 2020
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.

3 participants