
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
github.com/google/go-metrics-stackdriver
This library provides a stackdriver sink for applications instrumented with the go-metrics library.
This is not an officially supported Google product.
In general the author of this package would recommend instrumenting custom metrics for new code by following the official GCP documentation, especially for new applications.
This package is intended as a way to publish metrics for applications that are already instrumented with go-metrics
without having to use a sidecar process like stackdriver-prometheus-sidecar.
Between v0.5.0 and v0.6.0, the behavior of the IncrCounter()
method changed: previously it would create a GAUGE
metric kind, but from v0.6.0 forward it will create a CUMULATIVE
metric kind. (See https://github.com/google/go-metrics-stackdriver/issues/18 for a discussion.)
However, once a MetricDescriptor has been created in Google Cloud Monitoring, its metricKind
field cannot be changed. So if you have any existing GAUGE
metrics that were created by IncrCounter()
, you will see errors in your logs when the v0.6.0 client attempts to update them and fails. Your options for handling this are:
IncrCounter
(creating a new metricDescriptor with a different name), or:CUMULATIVE
metricAdditionally, v0.6.0 adds ResetCounter()
and ResetCounterWithLabels()
methods: calling these methods resets the counter value to zero.
stackdriver.NewSink's return value satisfies the go-metrics library's MetricSink interface. When providing a stackdriver.Sink
to libraries and applications instrumented against MetricSink
, the metrics will be aggregated within this library and written to stackdriver as Generic Task timeseries metrics.
import "github.com/google/go-metrics-stackdriver"
...
client, _ := monitoring.NewMetricClient(context.Background())
ss := stackdriver.NewSink(client, &stackdriver.Config{
ProjectID: projectID,
})
...
ss.SetGauge([]string{"foo"}, 42)
ss.IncrCounter([]string{"baz"}, 1)
ss.AddSample([]string{"method", "const"}, 200)
The full example can be run from a cloud shell console to test how metrics are collected and displayed.
You can also try out the example using Cloud Run!
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.