opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

Implement `SpanExporter#forceFlush`

Open dyladan opened this issue 2 years ago • 13 comments

Span exporter interface should have a ForceFlush as specified here: https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#forceflush

Since we have already released the interface stable without this, we can only add it as an optional property on the interface.

dyladan avatar Jun 29 '22 15:06 dyladan

I'll can knock this one out

sgracias1 avatar Jun 29 '22 17:06 sgracias1

Since we have already released the interface stable without this, we can only add it as an optional property on the interface.

Isn't this a semver minor change? I think we discussed a similar issue in API a while ago and that time the agreement was that it is ok that a new minor has new APIs to be implemented by consumers.

Flarna avatar Jun 30 '22 20:06 Flarna

@open-telemetry/javascript-maintainers what do you think? @Flarna is right when I talked to ted about this he said it's ok that SDK implementers should have a lower expectation of stability. The spec does state force flush is a required method.

dyladan avatar Jul 01 '22 14:07 dyladan

I'm not clearly getting the point here. Is @Flarna suggesting that the new method added in the SDK interfaces can be a non-optional one?

legendecas avatar Jul 01 '22 14:07 legendecas

I only read the argument why it needs to be optional and I don't agree with this. New API is semver minor in my opinion.

Looking into the linked spec part it says forceFlush is optional. But that spec is about SDK not exporters. SDK calls SpanProcessor and this one calls SpanExporter. Not sure at all here what forceFlush on SpanExporter should actually do as SpanExporters do not cache/store/collect any data - they just export. So there should be nothing to flush at all.

Maybe abort would make sense to stop a long running export operation but that's a different topic.

Flarna avatar Jul 01 '22 20:07 Flarna

Seems I read the wrong part in spec as above link points to TracerProvider#forceFlush. SpanExporter#forceFlus in turn is optional according to spec and therefore I think it's better to add it as optional.

There might be quite some exporters (e.g. ConsoleExporter,...) where ForceFlush makes no sense so no need for them to implement a dummy.

Flarna avatar Jul 01 '22 21:07 Flarna

@Flarna sorry I didn't find an indication in the spec that says that SpanExporter#forceFlush is optional. Would you mind sharing where you find that?

legendecas avatar Jul 04 '22 09:07 legendecas

Here spec says The exporter must support two functions: Export and Shutdown. ForceFlush is a SHOULD API therefore optional.

Flarna avatar Jul 04 '22 11:07 Flarna

Thank you for pointing that out. In that sense, I agree that it is a good idea to mark the method as an optional one.

legendecas avatar Jul 04 '22 16:07 legendecas

Thank you for the spec pointer, sorry been a little slammed at work, will try and get back to this tomorrow

sgracias1 avatar Jul 07 '22 17:07 sgracias1

I'm reading the spec and I see SHOULD requirements for behaviors of ForceFlush but I don't see anywhere that the existence of the function itself is SHOULD. I think the method is required but the behaviors are only SHOULD because some might be impossible (sync shutdown or similar)

dyladan avatar Jul 07 '22 17:07 dyladan

@dyladan you think the function should not be optional? The Interface Definition section does not mention forceFlush which I would take to mean it would be optional? I do see the ForceFlush section itself doesn't indicate it should be optional

sgracias1 avatar Jul 07 '22 17:07 sgracias1

Spec doesn't make this clear at all. Created https://github.com/open-telemetry/opentelemetry-specification/issues/2652 to get some clarity.

dyladan avatar Jul 07 '22 18:07 dyladan

@dyladan I know @sgracias1 mentioned picking this up in the past, but if you're ok with it I'd be happy to pick this issue up since it doesn't look like an update has happened in awhile.

JacksonWeber avatar Mar 07 '23 19:03 JacksonWeber

@pichlermarc I noticed @sgracias1 created a PR for this issue here: https://github.com/open-telemetry/opentelemetry-js/pull/3071 but was never merged since a few comments from @dyladan needed to be incorporated. Can I grab those changes and push them up with the appropriate changes made?

JacksonWeber avatar Mar 09 '23 23:03 JacksonWeber

Can I grab those changes and push them up with the appropriate changes made?

That's a good question, I'm actually not sure what the procedure for this is yet (I should know it, though).

I reached out to @dyladan as he's usually more knowledgeable in this area, and will let you know as soon as I have an adequate answer. :slightly_smiling_face:

pichlermarc avatar Mar 10 '23 11:03 pichlermarc

@JacksonWeber, we have done it in the past but try to avoid doing it.

I'd recommend reaching out to @sgracias1 before grabbing and pushing the changes; having a short comment from them on the original PR that it's okay to grab would go a long way. :slightly_smiling_face:

pichlermarc avatar Mar 13 '23 09:03 pichlermarc

Should I work on this Issue @pichlermarc @dyladan

ashutosh887 avatar Apr 20 '23 02:04 ashutosh887

@ashutosh887 I still haven't been able to get ahold of @sgracias1

JacksonWeber avatar Apr 20 '23 03:04 JacksonWeber

@JacksonWeber, in that case, I think going ahead with the PR would be fine. I'll start a thread on Slack with them (I'll include you in the thread) in case they come back online at some point :slightly_smiling_face:

pichlermarc avatar Apr 20 '23 07:04 pichlermarc

@pichlermarc @dyladan I created a new PR for this, resolved merge conflicts and tidied up a bit. https://github.com/open-telemetry/opentelemetry-js/pull/3753. Let me know if everything looks good!

JacksonWeber avatar Apr 24 '23 23:04 JacksonWeber