Skip to content

Improve Exemplar Interface #1042

Open
Open
@bwplotka

Description

@bwplotka

Using exemplars is quite painful currently. There is a common pattern you want to do such as:

image

I would propose something more natively supported. Some options:

A) Bring ObserveWithExemplar to Observer, why not?
B) Create a separate package that creates natively observers with exemplars (sounds brittle and more to maintain for not a good reason)
C) Create a helper that does something like:

func ExemplarObserve(obs prometheus.Observer, val float64, traceID string) {
	if traceID != "" {
		obs.(prometheus.ExemplarObserver).ObserveWithExemplar(
			val, map[string]string{"trace-id": traceID})
	} else {
		obs.Observe(val)
	}
}

The opinionated state is simple:

  • We want to observe with a trace ID.
  • We want a consistent trace ID label.
  • We want trace ID which is sampled, no point in any other (ofc won't work with tail sampling)
  • Assumption: Empty Trace ID means it's not sampled.

Ideally we have opinionated helper as part of method to Observe itself with configurable trace ID label... 🙈

Having if else when histogram is used is making client instrumentation too verbose IMO. Let's brainstorm this (:

Thoughts? @kakkoyun @juliusv @beorn7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions