Skip to content

[exporter/prometheus] Support Prometheus Created Timestamp feature #32521

Closed
@swar8080

Description

@swar8080

Component(s)

exporter/prometheus

Is your feature request related to a problem? Please describe.

Hello, prometheus has an experimental feature called "Created Timestamp" which solves the problems outlined in this document

Describe the solution you'd like

I think using this involves passing StartTimeUnixNano from the OTEL data model as the Created Timestamp in the prometheus data model. I've got it working locally with just these changes to prometheusexporter/collector.go:

func (c *collector) convertSum(metric pmetric.Metric, resourceAttrs pcommon.Map) (prometheus.Metric, error) {
  ip := metric.Sum().DataPoints().At(0)
  ...
  m, err := prometheus.NewConstMetricWithCreatedTimestamp(desc, metricType, value, ip.StartTimestamp().AsTime(), attributes...)
  ...
}

Describe alternatives you've considered

No response

Additional context

Not sure if the prometheus maintainers think the feature is stable enough to enable by default in the OTEL collector. Or maybe a feature flag makes sense? If not, I can just add this in a fork of the collector for now

cc machine424

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions