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

What should be the schema URL merge behavior when a resource is empty (no attributes) #3710

Open
joaopgrassi opened this issue Oct 2, 2023 · 6 comments
Labels
spec:resource Related to the specification/resource directory triage:accepted:needs-sponsor

Comments

@joaopgrassi
Copy link
Member

The Merge section of the Resource SDK specification, describes how the schemaURL of two resources should be merged. But it is unclear what should happen if one of the merging resources is empty, meaning, has 0 attributes but a non-empty schema url.

For ex, given this scenario:

  • Old resource: has attributes and empty schemaUrl
  • Updating resource: has 0 attributes and schemaUrl: https://opentelemetry.io/docs/specs/otel/schemas/v1.2.0

According with the merge behavior, the resulting resource should receive the schema url of the updating resource.

I wonder if this is correct? Given the resource that will influence the ultimate schema has no attributes, would it be better if, in that case, no schema would be set? Or should the schema be set regardless?

@carlosalberto
Copy link
Contributor

cc @tigrannajaryan

@pyohannes
Copy link
Contributor

I wonder if this is correct? Given the resource that will influence the ultimate schema has no attributes, would it be better if, in that case, no schema would be set? Or should the schema be set regardless?

In my opinion the currently defined behavior is fine. Otherwise you'd get into situations where setting or unsetting an environment variable causes or resolves resource merging errors, which is quite unexpected.

@joaopgrassi
Copy link
Member Author

Otherwise you'd get into situations where setting or unsetting an environment variable causes or resolves resource merging errors, which is quite unexpected.

@pyohannes But it's also the current behavior today, no? By setting the schemaURL from an empty resource, we may be affecting the other resource attribute's value if a transformation happen, no?

@pyohannes
Copy link
Contributor

By setting the schemaURL from an empty resource, we may be affecting the other resource attribute's value if a transformation happen, no?

Well, I'd say that's more a problem of having schema-sensitive resources without specified schema.

From the spec:

Resource detectors that populate resource attributes according to OpenTelemetry semantic conventions MUST ensure that the resource has a Schema URL set to a value that matches the semantic conventions.

@tigrannajaryan
Copy link
Member

For ex, given this scenario:

  • Old resource: has attributes and empty schemaUrl
  • Updating resource: has 0 attributes and schemaUrl: https://opentelemetry.io/docs/specs/otel/schemas/v1.2.0

According with the merge behavior, the resulting resource should receive the schema url of the updating resource.

This seems like the desirable behavior to me. The updating resource's schemaUrl is explicitly provided and I would expect it become the schemaUrl of the resulting resource.

@joaopgrassi
Copy link
Member Author

joaopgrassi commented Oct 3, 2023

Well, I'd say that's more a problem of having schema-sensitive resources without specified schema.

From the spec:

Resource detectors that populate resource attributes according to OpenTelemetry semantic conventions MUST ensure that the resource has a Schema URL set to a value that matches the semantic conventions.

I guess that's fair. What I was thinking is: Let's say I have a resource detector that contains some attributes that happen to follow the OTel semconv, but also it contains other, unrelated attributes. By following the spec, that resource detector should not populate the schema url, as it contains things that are not in the semconv.

But: by getting the Schema URL of the updating resource (and empty), my old resource is now bound to it, and may change because of transformations. If that's intended then we are fine, but I wanted to see if everyone agrees.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec:resource Related to the specification/resource directory triage:accepted:needs-sponsor
Projects
Status: Spec - Accepted
Development

No branches or pull requests

6 participants