Skip to content

Commit

Permalink
fix: apply AsDimensions to otlp client (#35)
Browse files Browse the repository at this point in the history
This allows users to specify their PrescientDimensions to be attached to each metric datum itself with an otlp sender.
It unfortunately adds a memory cost for each batch being sent, but this allows users to send metrics
to providers who ingest OTLP but may use a different backend (like Prometheus).
  • Loading branch information
tylerburdsall authored Mar 14, 2024
1 parent b147ecc commit a6ba19a
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ class OpentelemetryClient(

private fun AggregatedBatch.asGoofyOtlpMetricSequence(): Sequence<Metric> = sequence {
for ((position, measurements) in this@asGoofyOtlpMetricSequence.positions) {
val otlpDimensions = position.map { it.asOtlpKeyValue() }
// Push down our shared dimensions to each datum leaf if required. For systems that may ingest OTLP metrics
// but use a different backing system (e.g. OTLP -> Prometheus)
val otlpDimensions = position.map { it.asOtlpKeyValue() } + when (prescientDimensions) {
is PrescientDimensions.AsDimensions -> prescientDimensions.sharedDimensions.asOtlpDimensions()
is PrescientDimensions.AsResource -> emptySequence()
}
for ((measurementName, aggregation) in measurements) {
when (aggregation) {
is Aggregation.Histogram -> {
Expand Down

0 comments on commit a6ba19a

Please sign in to comment.