-
Notifications
You must be signed in to change notification settings - Fork 839
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
[DO NOT MERGE] Prototype Entities (otep#264) in Java SDK #6855
base: main
Are you sure you want to change the base?
Conversation
This does NOT update Resource.merge for entities yet. This has many inefficiencies that can be optimised away. - Adds Entity + EntityBuilder for constructing entities in the SDK - Add EntityDetector for discovering entities - Moves `service` and `telemetry.sdk` detection to EntityDetectors - Updates to semconv 1.28.0 for service/telemetry.sdk - Updates Resource + ResourceBuilder to preserve Entity - Creates a ResourceProvider that can be used to construct Resource using entity merge rules. - Hacky `getAttributes` update on Resource to preserve existing behavior. Tests pending.
4d81df2
to
b7421c2
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6855 +/- ##
============================================
- Coverage 90.28% 90.16% -0.12%
- Complexity 6588 6640 +52
============================================
Files 729 736 +7
Lines 19768 19945 +177
Branches 1944 1964 +20
============================================
+ Hits 17847 17984 +137
- Misses 1327 1362 +35
- Partials 594 599 +5 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variety of comments to get the conversation started. I think there still a fair bit to decide in terms of which artifacts these new components live in and to what extent we need to extend the public API, but let's keep the conversation going.
* Returns the URL of the OpenTelemetry schema used by this resource. May be null. | ||
* | ||
* @return An OpenTelemetry schema URL. | ||
* @since 1.4.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @since 1.4.0 |
public abstract Attributes getAttributes(); | ||
|
||
/** | ||
* Returns the URL of the OpenTelemetry schema used by this resource. May be null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe an opportunity to give a better description of what schema url means.
* Returns the URL of the OpenTelemetry schema used by this resource. May be null. | |
* Returns the URL of the OpenTelemetry schema used by this entity, or null if ??? |
What does it mean when schema url is null?
static final Entity create( | ||
String entityType, | ||
Attributes identifying, | ||
Attributes descriptive, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we call these descriptive here, should the getAttributes()
method be renamed to getDescriptiveAttributes()
?
/** | ||
* Modify the descriptive attributes of this Entity. | ||
* | ||
* @param f A thunk which manipulates descriptive attributes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's a thunk?
Separately, what's the motivation behind a consumer rather than the simpler withDescriptive(Attributes atributes)
? The consumer pattern is more clever and lower overhead, but is less intuitive and this probably isn't a place where efficiency matter.s
return new EntityBuilder(this); | ||
} | ||
|
||
public static final EntityBuilder builder() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should make the required properties arguments to create the builder. I.e. entity type.
* the SDK (called "associated entities"). For Example, if the SDK is running in a kubernetes pod, | ||
* it may provide an Entity for that pod. | ||
*/ | ||
public interface EntityDetector { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the thinking behind making EntityDetector a part of the SDK, instead of part of opentelemetry-sdk-extension-autoconfigure-spi
like ResourceProvider?
* | ||
* @return a list of discovered entities. | ||
*/ | ||
List<Entity> detectEntities(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should a single entity detector return multiple entities or a single entity?
package io.opentelemetry.sdk.resources; | ||
|
||
/** A Registry which provides the {@link Resource} to the SDK. */ | ||
public final class ResourceProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have ResourceProvider and will likely need to pick a different name.
Separately, I'm a little confused on the purpose of this thing. Seems like we could get away extending ResourceBuilder to include entity concepts.
// } | ||
|
||
private static String getServiceName() { | ||
return System.getenv().getOrDefault("OTEL_SERVICE_NAME", "unknown_service:java"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We separate out the interpretation of environment variables into autoconfigure, which has proved to be an separation of responsibilities. Should put all built-in entity detectors over there.
|
||
public final class ServiceInstanceDetector implements EntityDetector { | ||
private static final String SCHEMA_URL = "https://opentelemetry.io/schemas/1.28.0"; | ||
private static final String ENTITY_TYPE = "service.instance"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these entity types and their associated identifying / descriptive attributes codified anywhere yet?
This is a prototype of Java SDK updates for Entities OTEP.
Entity
,EntityBuilder
,EntityDetector
to sdk common package.Resource
andResourceBuilder
. Updates merge logic to match OTEP specification.ResourceProvider
which attempts to centralize Resource/Entity logic. This will need to be sorted out with existing sdk-extension ResourceProviders.toString
changes.Note: This prototype does NOT attempt to isolate experimental features into
internal
directories and expose an experimental package. That would be done when fragmenting this prototype into components and submitting "final" variants w/ specification work.