-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds compute metrics * Fixes lint * Removes execution ID from metrics labels * Fixes CI * Fixes CI * Fixes CI
- Loading branch information
1 parent
a4d3c22
commit cb9c185
Showing
5 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,38 @@ | ||
package compute | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"go.opentelemetry.io/otel/metric" | ||
|
||
"github.com/smartcontractkit/chainlink-common/pkg/beholder" | ||
"github.com/smartcontractkit/chainlink-common/pkg/metrics" | ||
|
||
localMonitoring "github.com/smartcontractkit/chainlink/v2/core/monitoring" | ||
) | ||
|
||
const timestampKey = "computeTimestamp" | ||
|
||
type computeMetricsLabeler struct { | ||
metrics.Labeler | ||
computeHTTPRequestCounter metric.Int64Counter | ||
} | ||
|
||
func newComputeMetricsLabeler(l metrics.Labeler) (*computeMetricsLabeler, error) { | ||
computeHTTPRequestCounter, err := beholder.GetMeter().Int64Counter("capabilities_compute_http_request_count") | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to register compute http request counter: %w", err) | ||
} | ||
|
||
return &computeMetricsLabeler{Labeler: l, computeHTTPRequestCounter: computeHTTPRequestCounter}, nil | ||
} | ||
|
||
func (c *computeMetricsLabeler) with(keyValues ...string) *computeMetricsLabeler { | ||
return &computeMetricsLabeler{c.With(keyValues...), c.computeHTTPRequestCounter} | ||
} | ||
|
||
func (c *computeMetricsLabeler) incrementHTTPRequestCounter(ctx context.Context) { | ||
otelLabels := localMonitoring.KvMapToOtelAttributes(c.Labels) | ||
c.computeHTTPRequestCounter.Add(ctx, 1, metric.WithAttributes(otelLabels...)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters