We’d like feedback on the `CallId` feature. If you...
# ktor
o
We’d like feedback on the
CallId
feature. If you have a homebrew version of such a feature, or would like to try it, please tell us how it works and if it suites your needs. That’s the last feature before we go towards 1.0 and start fixing only bugs and biggest pain points.
e
we have our own version of that feature, but planning to replace with Jaeger/Zipkin solution
also we have micrometer.io integration to provide prometheus endpoint, which is almost standard in kubernetes environment
o
We don’t provide a complete tracing solution, of course, but would like an integration with something popular enough. Do I understand it correctly that we need to support Zipking headers, like
X-B3-TraceId
? That should be easy with call-id feature configuration
e
I hope so. Now i’m using something like this https://gist.github.com/enleur/9e65fa005cbb881176df282aa63f8bd0
c
It will be something like this for now
Copy code
install(CallLogging) {
                    mdc("span_id") { call -> call.request.header("X─B3-SpanId") ?: UUID.randomUUID().toString() }
}
👍 1
k
Micrometer is a good facade to hook in
c
@enleur please note that
UUID.randomUUID()
is blocking so your server could hang
m
another way to generate random stuff quickly (not cryptograhpically secure! just a "probably unique" thing like UUIDs) is to generate a random HMAC key, then HMAC an incrementing counter every time you need another random string.
You only use the entropy pool once at initialization, so you won't block later.
c
On server you may need haveged to avoid it
m
havaged is no longer recommended btw
unfortunately the best you can do today, which still isn't great, is run recent kernel + libc with proper syscall wrappers that will block until enough entropy has been gathered on first boot.
I think OpenBSD was the first to do it mostly right, but newish Linux + glibc also have support IIRC
e
@cy it’s not really blocking, it’s just CPU intensive operation 🙂
m
It can block on entropy pool starvation. I have seen it in practice...
c
It is using SecureRandom that reads /dev/random by default
It's quite easy to see it
Some distributions doesn't have haveged so you can face it
m
with modern CSPRNGs there is a basically unlimited supply of randomness once the pool has been initialized, but not everyone is using those...
c
oops, sorry for offtop
m
true that 🙂 Hopefully this digression was informative
For more about CSPRNG / /dev/random / etc, see archives of http://www.metzdowd.com/mailman/listinfo/cryptography
there was a HUGE thread a few months back that dug deep
d
@enleur @kenkyee There' an open pull request for Micrometer.io, it would be great to have feedback and I could finish it up. I use it internally, but it would be nice to provide the main metrics people use https://github.com/ktorio/ktor/pull/480
e
@dave08 I think it should go as a separate package to avoid io.dropwizard.metrics dependencies
1
d
True, would you know how to seperate them? I don't really know advanced Gradle well enough... @enleur. Otherwise, anything else missing? I was about to add a histogram, but not sure if it's better for the user to configure them according to their own SLAs...
e
d
Thanks, I'll a look as soon as a have a chance 🙂