nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: celestiaorg/nmt
Pull request #201 (2023-05-25 14:06:40)

Add HexString method for namespace id
## Overview

Implements https://github.com/celestiaorg/nmt/issues/200

rootulp: This namespace does include the namespace version so I think we can include this change here.
Wondertan: Any reason not to change the default behavior of String to be always hex encoded? The current String is sorta useless while having default human-readable support for Stringer everywhere is not, AFAIU. The current String implementation can still be done with string(ID) if anyone needs raw nid in string format. 

@evan-forbes, @rootulp, thoughts? 
rootulp: My rationale for recommending a new `HexString()` method is to avoid breaking compatability

> changing existing String() method (would break compatibility)

If we can verify that no consumers of this library rely on the existing string representation then I think a human readable string method seems like a good idea.

staheri14: @walldiss Could you please revise the title of the PR to capitalize `HexString`? otherwise, it might be misleading, suggesting that the introduced method is private.
Wondertan: > If we can verify that no consumers of this library rely on the existing string representation then I think we can make the breaking change and modify the existing String() method

I verified the usage in the node and it's used only in places where human-readable string is expected.
evan-forbes: I'm fine with mergin both, but I tend to agree that returning hex makes a lot of sense. if we need a string() for some reason, we can just call `string(id)`
rootulp: Merging b/c @walldiss doesn't have permission to.

Patch:
diff --git a/namespace/id.go b/namespace/id.go
index f2ddc7b..d5dd8e7 100644
--- a/namespace/id.go
+++ b/namespace/id.go
@@ -1,6 +1,9 @@
 package namespace
 
-import "bytes"
+import (
+	"bytes"
+	"encoding/hex"
+)
 
 type ID []byte
 
@@ -28,3 +31,8 @@ func (nid ID) Size() IDSize {
 func (nid ID) String() string {
 	return string(nid)
 }
+
+// HexString returns hexadecimal encoding of nid.
+func (nid ID) HexString() string {
+	return hex.EncodeToString(nid)
+}


Test patch:
diff --git a/namespace/id_test.go b/namespace/id_test.go
new file mode 100644
index 0000000..15919b6
--- /dev/null
+++ b/namespace/id_test.go
@@ -0,0 +1,12 @@
+package namespace
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/require"
+)
+
+func TestID_HexString(t *testing.T) {
+	nID := ID("12345678")
+	require.Equal(t, "3132333435363738", nID.HexString())
+}
Repository: census-ecosystem/opencensus-go-exporter-stackdriver
Pull request #104 (2019-03-13 23:56:21)

change ExportMetric api to ExportMetricProto


Patch:
diff --git a/metrics.go b/metrics.go
index dc29bf7..b19ba57 100644
--- a/metrics.go
+++ b/metrics.go
@@ -49,8 +49,14 @@ type metricPayload struct {
 	metric   *metricspb.Metric
 }
 
-// ExportMetric exports OpenCensus Metrics to Stackdriver Monitoring.
-func (se *statsExporter) ExportMetric(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metric *metricspb.Metric) error {
+// ExportMetric exports OpenCensus Metrics proto to Stackdriver Monitoring.
+// Deprecated in lieu of ExportMetricProto
+func (se *statsExporter) ExportMetric(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metricpb *metricspb.Metric) error {
+	return se.ExportMetricProto(ctx, node, rsc, metricpb)
+}
+
+// ExportMetricProto exports OpenCensus Metrics proto to Stackdriver Monitoring.
+func (se *statsExporter) ExportMetricProto(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metric *metricspb.Metric) error {
 	if metric == nil {
 		return errNilMetric
 	}
diff --git a/stackdriver.go b/stackdriver.go
index a6e7748..59f292e 100644
--- a/stackdriver.go
+++ b/stackdriver.go
@@ -345,9 +345,15 @@ func (e *Exporter) ExportView(vd *view.Data) {
 	e.statsExporter.ExportView(vd)
 }
 
+// ExportMetricProto exports OpenCensus Metrics to Stackdriver Monitoring.
+func (e *Exporter) ExportMetricProto(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metric *metricspb.Metric) error {
+	return e.statsExporter.ExportMetricProto(ctx, node, rsc, metric)
+}
+
 // ExportMetric exports OpenCensus Metrics to Stackdriver Monitoring.
+// Deprecated in lieu of ExportMetriProto
 func (e *Exporter) ExportMetric(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metric *metricspb.Metric) error {
-	return e.statsExporter.ExportMetric(ctx, node, rsc, metric)
+	return e.statsExporter.ExportMetricProto(ctx, node, rsc, metric)
 }
 
 // ExportSpan exports a SpanData to Stackdriver Trace.


Test patch:
diff --git a/equivalence_test.go b/equivalence_test.go
index aeda057..54ad10a 100644
--- a/equivalence_test.go
+++ b/equivalence_test.go
@@ -276,7 +276,7 @@ func TestEquivalenceStatsVsMetricsUploads(t *testing.T) {
 
 	ma.forEachRequest(func(emr *agentmetricspb.ExportMetricsServiceRequest) {
 		for _, metric := range emr.Metrics {
-			_ = se.ExportMetric(context.Background(), emr.Node, emr.Resource, metric)
+			_ = se.ExportMetricProto(context.Background(), emr.Node, emr.Resource, metric)
 		}
 	})
 	se.Flush()
Repository: census-ecosystem/opencensus-go-exporter-stackdriver
Pull request #189 (2019-08-29 23:39:49)

Rename ExportMetricsProtoSync to ExportMetricsProto


Patch:
diff --git a/metrics_proto.go b/metrics_proto.go
index f6ff688..83e85c2 100644
--- a/metrics_proto.go
+++ b/metrics_proto.go
@@ -48,9 +48,9 @@ var percentileLabelKey = &metricspb.LabelKey{
 var globalResource = &resource.Resource{Type: "global"}
 var domains = []string{"googleapis.com", "kubernetes.io", "istio.io"}
 
-// ExportMetricsProtoSync exports OpenCensus Metrics Proto to Stackdriver Monitoring synchronously,
+// ExportMetricsProto exports OpenCensus Metrics Proto to Stackdriver Monitoring synchronously,
 // without de-duping or adding proto metrics to the bundler.
-func (se *statsExporter) ExportMetricsProtoSync(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metrics []*metricspb.Metric) error {
+func (se *statsExporter) ExportMetricsProto(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metrics []*metricspb.Metric) error {
 	if len(metrics) == 0 {
 		return errNilMetricOrMetricDescriptor
 	}
diff --git a/stackdriver.go b/stackdriver.go
index 1559b70..7e3cda6 100644
--- a/stackdriver.go
+++ b/stackdriver.go
@@ -347,17 +347,10 @@ func (e *Exporter) ExportView(vd *view.Data) {
 	e.statsExporter.ExportView(vd)
 }
 
-// ExportMetricsProto exports OpenCensus Metrics Proto to Stackdriver Monitoring.
-func (e *Exporter) ExportMetricsProto(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metrics []*metricspb.Metric) error {
-	return e.statsExporter.ExportMetricsProtoSync(ctx, node, rsc, metrics)
-}
-
-// ExportMetricsProtoSync exports OpenCensus Metrics Proto to Stackdriver Monitoring synchronously,
+// ExportMetricsProto exports OpenCensus Metrics Proto to Stackdriver Monitoring synchronously,
 // without de-duping or adding proto metrics to the bundler.
-//
-// Deprecated: experimental API for internal use at OpenTelemetry-Service only.
-func (e *Exporter) ExportMetricsProtoSync(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metrics []*metricspb.Metric) error {
-	return e.statsExporter.ExportMetricsProtoSync(ctx, node, rsc, metrics)
+func (e *Exporter) ExportMetricsProto(ctx context.Context, node *commonpb.Node, rsc *resourcepb.Resource, metrics []*metricspb.Metric) error {
+	return e.statsExporter.ExportMetricsProto(ctx, node, rsc, metrics)
 }
 
 // ExportMetrics exports OpenCensus Metrics to Stackdriver Monitoring


Test patch:
diff --git a/equivalence_test.go b/equivalence_test.go
index 04d9941..a81726f 100644
--- a/equivalence_test.go
+++ b/equivalence_test.go
@@ -337,7 +337,7 @@ func TestEquivalenceStatsVsMetricsUploads(t *testing.T) {
 		})
 
 	// Export the proto Metrics to the Stackdriver backend.
-	se.ExportMetricsProtoSync(context.Background(), nil, nil, metricPbs)
+	se.ExportMetricsProto(context.Background(), nil, nil, metricPbs)
 	se.Flush()
 
 	var stackdriverTimeSeriesFromMetrics []*monitoringpb.CreateTimeSeriesRequest