opentelemetry-sdk-workers icon indicating copy to clipboard operation
opentelemetry-sdk-workers copied to clipboard

OpenTelemetry Propagator Support

Open RichiCoder1 opened this issue 2 years ago • 7 comments

I didn't implement propagator support originally as I was worried about potential global assumptions they were making, but after more research I think it may be reasonable to expose this as a config option with a default.

RichiCoder1 avatar Feb 06 '23 20:02 RichiCoder1

Is propagation of headers like tracestate still broken due to no ContextManager being registered during initialization?

I was debugging some stuff around active context, but kept getting the default ROOT_CONTEXT.

From the docs, it made it clear that SDKs that fail to register a context manager will always default to the ROOT_CONTEXT as active.

Schachte avatar Mar 27 '23 06:03 Schachte

@Schachte This SDK (currently) effectively doesn't have a concept of a "global" context and anything trying to use @opentelemetry/api's concept of a context will fail. This is because until very recently, Workers had no concept of async context.

This will be fixed with #26 when I get around to it, but in the meantime this is the "real" context.

RichiCoder1 avatar Mar 27 '23 13:03 RichiCoder1

@RichiCoder1 ah nice, I understand now. I was adapting some of these ideas into a mini test project and was confused why my active context was always empty.

Great library!

Schachte avatar Mar 27 '23 15:03 Schachte

@Schachte absolutely! Hopefully the gap between the official JS and my lib will shrink over time 😄. Happy to hear any other feedback

RichiCoder1 avatar Mar 27 '23 15:03 RichiCoder1

@RichiCoder1 Same! I assume it will, same on the Workers side. Was main issue with the http exporter from OTEL the mixed use of XHR/window that caused a lot of issues for you in CF Workers?

Just getting started messing with OTEL with CF workers and feel like I probably ran into a lot of the same fun as you before I read your lib :)

Schachte avatar Mar 27 '23 16:03 Schachte

Yah, the Otel libs (reasonably) make a lot of assumptions that their either in a standard Node environment or a standard Web environment, both of which break down in Worker-like environments like Cloudflare Workers. They haven't really had the bandwidth to address that, hence this SDK as a patch fix.

RichiCoder1 avatar Mar 27 '23 16:03 RichiCoder1

👍 sweet. Well thanks again for a great lib, was able to dissect a lot of OTEL weirdness combing through your logic. Cheers!

Schachte avatar Mar 27 '23 16:03 Schachte