mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Change resource type for Stackdriver to fix metrics push
Currently, it's forbidden for custom metrics to write to the gae_app resource type. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=131076789
This commit is contained in:
parent
5dc1f716bd
commit
e6beba2d39
1 changed files with 16 additions and 7 deletions
|
@ -38,6 +38,10 @@ import org.joda.time.Duration;
|
|||
@Module
|
||||
public final class StackdriverModule {
|
||||
|
||||
// We need a fake GCE zone to appease Stackdriver's resource model.
|
||||
// TODO(b/31021585): Revisit this if/when gae_instance exists.
|
||||
private static String SPOOFED_GCE_ZONE = "us-central1-f";
|
||||
|
||||
@Provides
|
||||
static Monitoring provideMonitoring(
|
||||
HttpTransport transport,
|
||||
|
@ -56,19 +60,24 @@ public final class StackdriverModule {
|
|||
ModulesService modulesService,
|
||||
@Config("stackdriverMaxQps") int maxQps,
|
||||
@Config("stackdriverMaxPointsPerRequest") int maxPointsPerRequest) {
|
||||
// The MonitoredResource for GAE apps lacks an instance_id field, so we encode it into the
|
||||
// version_id field so that metrics from different instances don't interleave.
|
||||
// The MonitoredResource for GAE apps is not writable (and missing fields anyway) so we just
|
||||
// use the gce_instance resource type instead.
|
||||
return new StackdriverWriter(
|
||||
monitoringClient,
|
||||
projectId,
|
||||
new MonitoredResource()
|
||||
.setType("gae_app")
|
||||
.setType("gce_instance")
|
||||
.setLabels(
|
||||
ImmutableMap.of(
|
||||
"module_id",
|
||||
modulesService.getCurrentModule(),
|
||||
"version_id",
|
||||
modulesService.getCurrentVersion()
|
||||
// The "zone" field MUST be a valid GCE zone, so we fake one.
|
||||
"zone",
|
||||
SPOOFED_GCE_ZONE,
|
||||
// Overload the GCE "instance_id" field with the GAE module name, version and
|
||||
// instance_id.
|
||||
"instance_id",
|
||||
modulesService.getCurrentModule()
|
||||
+ ":"
|
||||
+ modulesService.getCurrentVersion()
|
||||
+ ":"
|
||||
+ modulesService.getCurrentInstanceId())),
|
||||
maxQps,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue