CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/golang-github-com-prometheus--client-model

Data model artifacts for Prometheus

Overall
score

93%

Evaluation93%

1.13x

Agent success when using this tile

Overview
Eval results
Files

task.mdevals/scenario-9/

Counter Exemplars with Context

Build a protobuf payload for a single counter metric that carries exemplar context (labels, value, timestamp) without leaking exemplar labels into the metric's base label set.

Capabilities

Counter exemplar payload

  • Serializes a counter metric named "request_duration_seconds_total" with base labels method=GET and status=200, attaches an exemplar containing trace_id=abc-123, exemplar value 0.42, and timestamp 2023-11-20T10:00:00Z, and returns bytes that decode back to those exact values. @test
  • If the provided exemplar timestamp is the zero value, returns an error instead of emitting a payload. @test
  • Ensures metric labels remain service=checkout and region=us-east-1, while exemplar labels remain trace_id=xyz-789 and span_id=def-456, with no cross-contamination between the two label sets. @test

Implementation

@generates

API

package exemplar

import "time"

// MarshalCounterWithExemplar builds a single-sample counter metric payload with an exemplar and returns the protobuf bytes.
func MarshalCounterWithExemplar(
    metricName string,
    metricLabels map[string]string,
    exemplarLabels map[string]string,
    counterValue float64,
    exemplarValue float64,
    exemplarTime time.Time,
) ([]byte, error)

Dependencies { .dependencies }

Prometheus client model { .dependency }

Provides protobuf data model types for metrics and exemplars.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/golang-github-com-prometheus--client-model

tile.json