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 detector #174

Merged
merged 9 commits into from
Aug 16, 2020
Merged

Add resource detector #174

merged 9 commits into from
Aug 16, 2020

Conversation

TommyCpp
Copy link
Contributor

@TommyCpp TommyCpp commented Aug 12, 2020

Fix #167
See open-telemetry/oteps#111 for proposal
Also fixes the bug in test mod of Resource

@TommyCpp TommyCpp force-pushed the env branch 2 times, most recently from 42bda30 to 72f6074 Compare August 12, 2020 01:22
Add import in tests mod.
See oteps#111 for details
Fix lint.
According to the proposal. detect should accept a timeout parameter and return Resource regardless.
@TommyCpp TommyCpp marked this pull request as ready for review August 13, 2020 03:35
@TommyCpp TommyCpp requested a review from a team August 13, 2020 03:35
Copy link
Member

@jtescher jtescher left a comment

Choose a reason for hiding this comment

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

Thanks @TommyCpp, looking good just a few small nits

src/sdk/env.rs Outdated
@@ -0,0 +1,88 @@
//! EnvResourceDetector
//!
//! Implementation of ResourceDetector in extract information from environment.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
//! Implementation of ResourceDetector in extract information from environment.
//! Implementation of `ResourceDetector` to extract a `Resource` from environment variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

src/sdk/env.rs Outdated
const OTEL_RESOURCE_ATTRIBUTES: &str = "OTEL_RESOURCE_ATTRIBUTES";

/// Resource detector implements ResourceDetector and is used to extractor general SDK configuration from environment
/// See https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/resource/semantic_conventions#telemetry-sdk for semantic conventions.
Copy link
Member

Choose a reason for hiding this comment

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

Can we wrap these to 80 characters? rustfmt currently doesn't do this automatically, but the style guide for comments in rust seems to be 80 currently https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/guide.md#comments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing. Don't think I can break the url but will wrap other comments.

src/sdk/env.rs Outdated
/// Resource detector implements ResourceDetector and is used to extractor general SDK configuration from environment
/// See https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/resource/semantic_conventions#telemetry-sdk for semantic conventions.
#[derive(Debug)]
pub struct EnvResourceDetector {}
Copy link
Member

Choose a reason for hiding this comment

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

we've been using _private here so we could add more without breaking changes (forces people to use the new method) e.g.

pub struct CorrelationContextPropagator {
_private: (),
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point!

src/sdk/env.rs Outdated
/// Extract key value pairs and construct a resource from resources string like key1=value1,key2=value2,...
fn construct_otel_resources(s: String) -> Resource {
let mut key_values = vec![];
for entries in s.split(',') {
Copy link
Member

Choose a reason for hiding this comment

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

split_terminator here may be preferable as it will have the behavior people probably expect form trailing commas

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds reasonable. Thanks!


/// Describes an entity about which identifying information and metadata is exposed.
///
/// Items are sorted by key, and are only overwritten if the value is an empty string.
/// Items are sorted by keys, and are only overwritten if the value is an empty string.
Copy link
Member

Choose a reason for hiding this comment

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

Sorted by keys is also a little awkward, maybe "sorted by their key"?

See PR discussion for details.
Copy link
Member

@jtescher jtescher left a comment

Choose a reason for hiding this comment

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

Looks good!

@jtescher
Copy link
Member

@TommyCpp I think you can merge your own PRs once approved now 👍

@TommyCpp
Copy link
Contributor Author

@jtescher I tried but I don't think I can. Maybe you will have to be maintainer to do that?

@jtescher
Copy link
Member

Hm maybe, the permissions in the otel org seem a little overly complicated to me. I'll just merge this for now 🤷‍♂️

@jtescher jtescher merged commit b425587 into open-telemetry:master Aug 16, 2020
@TommyCpp TommyCpp deleted the env branch September 23, 2020 02:19
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.

Add resource detector
2 participants