Skip to content

Commit

Permalink
fix: Update OTEL GCM exporter and remove FAAS workaround (#308)
Browse files Browse the repository at this point in the history
fix(deps): update dependency @google-cloud/opentelemetry-cloud-monitoring-exporter to ^0.18.0
  • Loading branch information
nielm authored Jun 12, 2024
1 parent 849008c commit cdc8b39
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 243 deletions.
234 changes: 18 additions & 216 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@google-cloud/functions-framework": "^3.4.0",
"@google-cloud/logging-bunyan": "^5.1.0",
"@google-cloud/monitoring": "^4.1.0",
"@google-cloud/opentelemetry-cloud-monitoring-exporter": "^0.17.0",
"@google-cloud/opentelemetry-cloud-monitoring-exporter": "^0.18.0",
"@google-cloud/pubsub": "^4.4.1",
"@google-cloud/spanner": "^7.8.0",
"@opentelemetry/api": "^1.9.0",
Expand Down
29 changes: 3 additions & 26 deletions src/autoscaler-common/counters_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,32 +260,9 @@ async function initMetrics() {
}
}

const gcpResources = new GcpDetectorSync().detect();
if (gcpResources.waitForAsyncAttributes) {
await gcpResources.waitForAsyncAttributes();
}

if (process.env.FUNCTION_TARGET) {
// In cloud functions.
// We need to set the platform to generic_task so that the
// function instance ID gets set in the counter resource attributes.
// For details, see
// https://github.com/GoogleCloudPlatform/opentelemetry-operations-js/issues/679
RESOURCE_ATTRIBUTES[Semconv.SEMRESATTRS_CLOUD_PLATFORM] = 'generic_task';

if (gcpResources.attributes[Semconv.SEMRESATTRS_FAAS_ID]?.toString()) {
RESOURCE_ATTRIBUTES[Semconv.SEMRESATTRS_SERVICE_INSTANCE_ID] =
gcpResources.attributes[Semconv.SEMRESATTRS_FAAS_ID].toString();
} else {
logger.warn(
'WARNING: running under Cloud Functions, but FAAS_ID ' +
'resource attribute is not set. ' +
'This may lead to Send TimeSeries errors',
);
}
}

const resources = gcpResources.merge(new Resource(RESOURCE_ATTRIBUTES));
const resources = new GcpDetectorSync()
.detect()
.merge(new Resource(RESOURCE_ATTRIBUTES));
if (resources.waitForAsyncAttributes) {
await resources.waitForAsyncAttributes();
}
Expand Down

0 comments on commit cdc8b39

Please sign in to comment.