wyhaines / opentelemetry-api.cr

The core of open telemetry instrumentation is the OpenTelemetry API/SDK. The initial aim of this shard is to implement the OpenTelemetry specification for metrics, traces, and logs.
Apache License 2.0
12 stars 1 forks source link

fix(trace): type-juggling in `in_span` #7

Closed caspiano closed 2 years ago

caspiano commented 2 years ago

Moves the restriction of the return type to the bottom of the method due to the begin...end block causing the return type to be spuriously nillable.

typeof (a compile-time operation) is used to deduce the correct return type from the block.

wyhaines commented 2 years ago

I included these changes with some other refactors that I did to create an explicit in_span/close_span that doesn't use a block.

Thanks for this PR. I like that technique of using typeof on the yield.