Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to clean self-data metric? #5917

Open
rockingl opened this issue Oct 24, 2024 · 2 comments
Open

How to clean self-data metric? #5917

rockingl opened this issue Oct 24, 2024 · 2 comments
Labels
blocked:specification Waiting on clarification of the OpenTelemetry specification before progress can be made enhancement New feature or request

Comments

@rockingl
Copy link

rockingl commented Oct 24, 2024

Hi,
First of all, thank you for your excellent work.
Recently, I encountered some problems while doing push notifications for monitoring. Here is my code.

         // create http oltp exporter,exporter private data(similar to promethus collector.textfile.directory),not Datapoint
        exporter, _ := otlpmetrichttp.New(ctx, otlpmetrichttp.WithInsecure(), otlpmetrichttp.WithEndpoint(endpoint),
		otlpmetrichttp.WithURLPath(urlpath))

        // create provider
	meterProvider := metric.NewMeterProvider(metric.WithReader(metric.NewPeriodicReader(exporter, metric.WithInterval(15*time.Second))))
	otel.SetMeterProvider(meterProvider)

        // create meter
	meter := otel.GetMeterProvider().Meter("test_metric")
	
        // promethus: tag -> value
        // Notice:private data(has existed), not Datapoint
        opt1 := api.WithAttributes(
	      attribute.Key("a").String("b"),
	      attribute.Key("c").String("d"),
	)
        opt2 := api.WithAttributes(
	      attribute.Key("a").String("b"),
	      attribute.Key("c").String("e"), // value is changed
	)
        // create gauge metric name
	gauge,_ := meter.Float64Gauge("test_float64gauage", api.WithDescription("a fun little gauge"))

        // exporter data 
	cnt := 1.0
	for i := 0; i < 2; i++{
		time.Sleep(15 * time.Second)
		cnt++
		gauge.Record(context.Background(), cnt, opt1)
	}

        // end,i hope this attribute disappear, because it's not on the record

	cnt = 10.0
        for i := 0; i < 2; i++ {
		time.Sleep(15 * time.Second)
		cnt++
		gauge.Record(context.Background(), cnt, opt2)
	} 
        //  use the new attribute instead

My goal is to keep only the latest data, but this is not the case. However, two data appear, and the value of the first data has not changed. Is there a cleanup/update mechanism that can clean up the attribute data? Or is my approach wrong and there is another approach that is more suitable for this scenario? Any help would be appreciated,thanks!

@rockingl rockingl added the enhancement New feature or request label Oct 24, 2024
@dmathieu
Copy link
Member

Removing metrics is not something currently supported.
The specification for that addition is however being discussed here: open-telemetry/opentelemetry-specification#2232

@dmathieu dmathieu added the blocked:specification Waiting on clarification of the OpenTelemetry specification before progress can be made label Oct 24, 2024
@rockingl
Copy link
Author

Removing metrics is not something currently supported. The specification for that addition is however being discussed here: open-telemetry/opentelemetry-specification#2232

thanks! I want to achieve what I want, is there any alternative solution? (Previously, the node_exporter export solution was used. However, due to the large number of machines and the inability to fully connect the network, this solution was abandoned.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked:specification Waiting on clarification of the OpenTelemetry specification before progress can be made enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants