mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 08:57:12 +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
|
@Module
|
||||||
public final class StackdriverModule {
|
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
|
@Provides
|
||||||
static Monitoring provideMonitoring(
|
static Monitoring provideMonitoring(
|
||||||
HttpTransport transport,
|
HttpTransport transport,
|
||||||
|
@ -56,19 +60,24 @@ public final class StackdriverModule {
|
||||||
ModulesService modulesService,
|
ModulesService modulesService,
|
||||||
@Config("stackdriverMaxQps") int maxQps,
|
@Config("stackdriverMaxQps") int maxQps,
|
||||||
@Config("stackdriverMaxPointsPerRequest") int maxPointsPerRequest) {
|
@Config("stackdriverMaxPointsPerRequest") int maxPointsPerRequest) {
|
||||||
// The MonitoredResource for GAE apps lacks an instance_id field, so we encode it into the
|
// The MonitoredResource for GAE apps is not writable (and missing fields anyway) so we just
|
||||||
// version_id field so that metrics from different instances don't interleave.
|
// use the gce_instance resource type instead.
|
||||||
return new StackdriverWriter(
|
return new StackdriverWriter(
|
||||||
monitoringClient,
|
monitoringClient,
|
||||||
projectId,
|
projectId,
|
||||||
new MonitoredResource()
|
new MonitoredResource()
|
||||||
.setType("gae_app")
|
.setType("gce_instance")
|
||||||
.setLabels(
|
.setLabels(
|
||||||
ImmutableMap.of(
|
ImmutableMap.of(
|
||||||
"module_id",
|
// The "zone" field MUST be a valid GCE zone, so we fake one.
|
||||||
modulesService.getCurrentModule(),
|
"zone",
|
||||||
"version_id",
|
SPOOFED_GCE_ZONE,
|
||||||
modulesService.getCurrentVersion()
|
// Overload the GCE "instance_id" field with the GAE module name, version and
|
||||||
|
// instance_id.
|
||||||
|
"instance_id",
|
||||||
|
modulesService.getCurrentModule()
|
||||||
|
+ ":"
|
||||||
|
+ modulesService.getCurrentVersion()
|
||||||
+ ":"
|
+ ":"
|
||||||
+ modulesService.getCurrentInstanceId())),
|
+ modulesService.getCurrentInstanceId())),
|
||||||
maxQps,
|
maxQps,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue