-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[pdata] Inconsistent output of enum types String() methods #6251
Comments
I do believe that we can have different behavior between proto defined values and the types. Does not mean we should, but it is acceptable if we decide that. |
@bogdandrutu I also like this approach, but it'll be different from what json marshaler produces. So user will not be able to compare the json values with pdata unless we provide additional methods like I think I'm more inclined towards sticking with what proto provides now for the category 2. Not sure it worth patching json marshaler either. WDYT? |
JSON marshaler per the specs MUST produce ints for the enums, see open-telemetry/opentelemetry-specification#2758 |
@bogdandrutu I inspected all the components that currently use plog.SeverityNumber.String(), ptrace.SpanKind.String(), or ptrace.StatusCode.String() and got the following list separated by categories where the value is being used as: Output payload:
Input payload:
Config options:
Given that we have a pretty big list, we need to be very careful if we go this direction. Some of the components potentially can use the updated string, but they have to go through some graceful transition process. In the meantime we would have to update all of them to keep existing behavior similar to how it's done in open-telemetry/opentelemetry-collector-contrib#16019. Another option would be to expose another method that returns a string representing proto enum constant name, so clients can keep using it instead of |
The problem is that current protocol may not guarantee stability on these strings, so I don't want give this stability from this repo if proto does not give that. |
Sounds good. I submitted a PR in contrib that uses a replicated version of existing methods for now open-telemetry/opentelemetry-collector-contrib#16021 |
#34799) **Description:** Trace `SpanKind` and `StatusCode` are exporting [old enum values](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/04b3b9898b242c0b3b707bc043c025eb9f6f73ba/internal/coreinternal/traceutil/traceutil.go#L13-L47). This change will make these fields consistent with the specification. I have marked this as a breaking change since it may affect queries that filter by these strings. There should be no change to exporter deployments, only to the read queries. See above/below links for more information as well as a sample of the old vs new values. Example: `STATUS_CODE_ERROR` -> `Error` **Link to tracking Issue:** - open-telemetry/opentelemetry-collector#6250 - open-telemetry/opentelemetry-collector#6251 **Testing:** - Updated integration tests
open-telemetry#34799) **Description:** Trace `SpanKind` and `StatusCode` are exporting [old enum values](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/04b3b9898b242c0b3b707bc043c025eb9f6f73ba/internal/coreinternal/traceutil/traceutil.go#L13-L47). This change will make these fields consistent with the specification. I have marked this as a breaking change since it may affect queries that filter by these strings. There should be no change to exporter deployments, only to the read queries. See above/below links for more information as well as a sample of the old vs new values. Example: `STATUS_CODE_ERROR` -> `Error` **Link to tracking Issue:** - open-telemetry/opentelemetry-collector#6250 - open-telemetry/opentelemetry-collector#6251 **Testing:** - Updated integration tests
The pdata module has a few enum type definitions. Some of them defined in proto (2), while others are defined in pdata only (based on proto oneof message fields names) (1).
1. For enum types that are not defined in proto, we use a short version of the enum identifier for the output of String() method in:
pmetric.MetricType
pmetric.NumberDataPointValueType
pmetric.ExemplarValueType
pmetric.ValueType
e.g.:
2. For enums that are defined in proto, we have an inconsistent behavior.
One of the proto-defined enums uses the same approach as in (1):
pmetric.MetricAggregationTemporality
:While other enums (2) reuse the string value defined in proto which is always a full uppercased name:
plog.SeverityNumber
ptrace.SpanKind
ptrace.StatusCode
, e.g.:We should bring all of the values returned by enum
String()
method to a consistent form.There are seem to be several options how to achieve that:
A. Ignore string values defined in proto and use the short terms everywhere. Requires changes in
plog.SeverityNumber.String()
,ptrace.SpanKind.String()
, andptrace.StatusCode.String()
B. Use long version written in uppercase with underscores averywhere. Requires changes in
pmetric.MetricType.String()
,pmetric.NumberDataPointValueType.Sgtring
,pmetric.ExemplarValueType.String()
, andpmetric.ValueType.String()
C. Use values defined in proto for enums (2), but keep the short version for enums (1). Requires changes in
pmetric.MetricAggregationTemporality.String()
onlyThe text was updated successfully, but these errors were encountered: