[Feature Request] Add statsd support to Typescript SDK
Is your feature request related to a problem? Please describe.
Per the production deployment docs we've set up metrics using statsd since it's easy to pipe to Datadog for our Temporal server deployment. However, as specified the most important metric to track is ScheduleToStart which is an SDK metric.
Describe the solution you'd like
It would be great to be able to specify statsd configuration similar to the server config in the Typescript SDK on Worker creation to be able to send ScheduleToStart metrics.
Additional context
https://temporalio.slack.com/archives/C01DKSMU94L/p1634848505016400
On a related note, I think the production deployment docs should explicitly call out that ScheduleToStart is an SDK-issued metric, where that metrics piping is set up independently of the server -- maybe this already exist in the docs for the other SDKs. I'm happy to file an issue in the server repo if helpful, or open a PR with suggested documentation updates.
@Sushisource can you please look into this? How easy would it be to support statsd metrics exporter by default in core?
So the way to do this is to just to use the OTel collector exporter and configure the collector to route to statsd. Or, in this case since the real end goal is datadog, the datadog exporter. https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/datadogexporter
I'm really hesitant to add more kinds of exporters into the code directly since this is exactly the territory the collector solves. @mengyazhu96 Let me know if you have any trouble with this approach or it's unclear how to get it going.
Closing this issue @mengyazhu96. We'll add documentation to explain how to set this up.
There's overhead to setting up an OTel collector. It'd be great if the SDK supported routing to DataDog more directly.
I see that there's a Rust DataDog exporter crate but I'm not convinced we should embed it in Core. @Sushisource can you think of a way to optionally include it?
@bergundy These are the options:
- Embed it, always linked in. Optionally enabled. Needs more config options, will increase bin size, and sets precedent that we might include every otel exporter directly in core. Also doesn't work with combining data from Lang SDKs, as now they also need to direct-export to datadog.
- Same as above except force users to recompile core so it isn't always linked in. This obviously is no fun.
- Same as above except dynamically link in somehow. Better than forcing recompile but complex.
I can definitely sympathize with the overhead of deploying an OTel Collector, but it adds a lot of flexibility for users once they do. They can centralize their config, easily export to multiple destinations and collect from multiple sources, etc.
The big problem here is that we emit metrics from both Core and Lang. Every direct export we support it needs to exist in Core and all langs on top of core and that pretty quickly adds up to supporting a lot of different exporters. That, or we figure out piping metrics into one side so it can always emit them for both halves, but as you probably remember that was a sisyphean undertaking when I first went down that path.
It should be noted we don't support statsd natively in Go/Java SDK. Rather they use the abstract "Tally" libs from Uber (and in Go, it's not even compiled in by default). There just so happen to be connectors for that lib to statsd.
Is it possible to provide metrics from core to lang upon request? I think the pull model works w/ prom, otel, etc but I'd have to confirm. Then lang can choose what to do with them, including statsd export. There's an added benefit of having all metrics in one place. The structures for our metrics (counter, gauge, time-based all w/ optional labels) shouldn't be that difficult to abstract if you didn't want the otel-specific structures going over the bridge.
@cretz that's what we initially tried to do for both metrics and traces but from what @Sushisource reports it ended up being a lot of work and didn't have good support from otel.
I still think exporting to lang is more flexible because it allows users to use their library of choice to export telemetry.
It was an absolute nightmare to do that kind of exporting. We could make our own metrics abstractions, but that's a business I don't particularly want to be in. There's quite a bit of complexity in getting that right. I think it's definitely a direction we could eventually end up going, but priorities wise I don't think it's the best use of time at the moment.