-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[connector/otlpjson] Do not emit empty batches #35738
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
I think it makes sense to skip empty records. Let's take into account also #35739, since it looks quite related. |
Hello, is this open for contribution, can you assign this to me? |
I think this issue requires further explanation because there is more going on here than just emitting empty objects, and I think we may want additional changes. The example given here highlights the way in which connectors are instanced. For a fuller explanation, see open-telemetry/opentelemetry-collector#10534, but in short, they are instanced per ordered pair of data types. The example depends on using a single configuration for all three signals, so we end up with three instances of the connector (logs->logs, logs->metrics, logs->traces). When data is passed to the connector, we are essentially calling three different functions simultaneously, one for each instance. This means that each instance will try to marshal every line into the corresponding output data type. In this case, each instance will successfully unmarshal one of the three lines, and fail to unmarshal the other two and log an error for each of the failures. I agree that we should not send empty data when unmarshaling fails, but the overall behavior here is not great. Should we really log an error when the Finally, although I don't think it's terribly important, we should note that it's possible to have a valid My proposal: We should unify the instances into a singleton (via There might be a clever way to define a struct such that any valid otlpjson line is very shallowly unmarshaled, to the point where we can assess which deep unmarshaler to use. I'm not an expert on this but maybe something like the following is possible: type AnyType struct {
ResourceLogs []byte `json:"resourceLogs"` // or some other type that doesn't fully unmarshal the content.
ResourceMetrics []byte `json:"resourceMetrics"`
ResourceSpans []byte `json:"resourceSpans"`
} |
Thank's for these details @djaglowski! I wasn't really familiar with the
|
#35739 basically says that invalid JSON is already handled, but invalid otlpjson is ignored. What I'm saying is that there is such a thing as valid otlpjson which is essentially empty. e.g.
I think it was probably also not handling this well. I recall similar discussion occurring when that was first implemented and no one thought of a good solution so we just accepted it may be noisy. Really only because of seeing these issues again that it has prompted me to think through again how it could be handled better. |
On creating a sharedComponent similar to what we have in otelReceiver - we see that every line still would still be processed by each connector. Say we have logs and traces connector - and we choose to parse a line based on a regex match - the line would match to its appropriate data type twice (once in logs and once in traces connector) You can check A simple solution I can think of is (say when you have logs->logs connector)
|
Hmm, I think what is happening is that although the component itself is a singleton, the collector graph still views it as three separate instances, so thinks it needs to send one to each. Apologies for overlooking this. (I think it's a good example of why components should be able to inform the collector graph of whether or not they are a singleton via
I think this might be the best we can do in this component. Most of the time a given file is going to contain telemetry of a uniform type, but when it doesn't, we could recommend to users that they use a routing connector first. I've actually just finished adding the ability to route on a per-log basis, so perhaps this is worth a try. |
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description The connector now does not emit empty batches for invalid otlp payload and throws an error instead. Approach discussed here open-telemetry#35738 (comment) <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#35738 and open-telemetry#35739 <!--Describe what testing was performed and which tests were added.--> #### Testing Manual Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> --------- Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description The connector now does not emit empty batches for invalid otlp payload and throws an error instead. Approach discussed here open-telemetry#35738 (comment) <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#35738 and open-telemetry#35739 <!--Describe what testing was performed and which tests were added.--> #### Testing Manual Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> --------- Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description The connector now does not emit empty batches for invalid otlp payload and throws an error instead. Approach discussed here open-telemetry#35738 (comment) <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes open-telemetry#35738 and open-telemetry#35739 <!--Describe what testing was performed and which tests were added.--> #### Testing Manual Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> --------- Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>
Component(s)
connector/otlpjson
Is your feature request related to a problem? Please describe.
Version: v0.111.0
Steps to reproduce:
telemetrygen
to send logs, metrics, spans to it.) Seeotlp-all.json
file below for a working example.config.yaml:
otlp-all.json:
Actual behavior:
The OTLP/JSON connector emits empty logs, metrics, traces resources. Here is the output from the Debug exporter:
Describe the solution you'd like
Expected behavior:
I would expect the OTLP/JSON connector to not emit empty resources. Here's the output from Debug exporter I would expect:
Describe alternatives you've considered
No response
Additional context
The
Unmarshal(Logs|Metrics|Traces)
methods do not return an error for valid JSON that is not a valid OTLP payload. They just return an empty object of logs/metrics/traces data. See https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.111.0/connector/otlpjsonconnector/traces.go#L55 for example. The code should be updated to not only check for error, but also check if the payload has any data in it.The text was updated successfully, but these errors were encountered: