Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: feat: Add Stackdriver integration #59

Closed
wants to merge 1 commit into from

Conversation

grant
Copy link
Contributor

@grant grant commented Jul 19, 2019

WIP: Adds StackDriver Debug, Trace, and Profiler support.

TODO:

  • Add an env var option for disabling the integration
  • Fix the tests
    • Add setup to Travis: https://www.npmjs.com/package/@google-cloud/profiler#basic-set-up
      • Create GOOGLE_APPLICATION_CREDENTIALS
    • Error: @google-cloud/profiler Failed to create profile
      • request to HTTP function
      • @google-cloud/profiler Failed to create profile, waiting 9.3s to try again: Error: Could not refresh access token: A Not Found error was returned while attempting to retrieve an accesstoken for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have any permission scopes specified: Could not refresh access token: Unsuccessful response status code. Request failed with status code 404
        @google-cloud/debug-agent Failed to re-register debuggee eco-emissary-99515: Error: Could not refresh access token: A Not Found error was returned while attempting to retrieve an accesstoken for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have any permission scopes specified: Could not refresh access token: Unsuccessful response status code. Request failed with status code 404
        1) should return transformed body
        

Open Questions

  • Should these be normal dependancies rather than devDependancies?
  • How can we test this PR?

Fixes: #57

}

// Start Trace
trace.start();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the trace-agent needed to be started as the very first part of the app:

require('@google-cloud/trace-agent').start();

See https://www.npmjs.com/package/@google-cloud/trace-agent#usage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's a hard requirement, we have it imported after http and on-finish modules, which I don't think have a starter script like this.

I think that suggestion is just added to ensure that the full trace is added rather than a partial trace.

d.run(() => {
d.run(async () => {
// Start the debugger (if not alreay started)
const tools = startTooling();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is overhead both in starting the tooling, and ongoing performance overhead. Is there a way for the user to opt out of this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ease in turning instrumentation on and off, it would be nice to toggle this with an environment variable instead of something requiring a redeployment (e.g., adjusted container entrypoint)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The PRD specifies the following semantics:

Enable/disable Stackdriver APM
As a developer, I can enable or disable individual Stackdriver APM features. The on/off state is controlled by an environment variable as follows:

Stackdriver APM feature Environment variable
Stackdriver Trace GOOGLE_CLOUD_TRACE_ENABLED

If the environment variable is set to false or if it is not set, the feature should be disabled by default.

By default, Stackdriver APM features are enabled on Cloud Functions
As a developer on Cloud Functions, when I deploy my function Stackdriver Trace is enabled by default. The container into which my function is deployed will, e.g., automatically set the value of the GOOGLE_CLOUD_TRACE_ENABLED environment variable to true.

@@ -26,6 +26,8 @@ import * as express from 'express';
import * as http from 'http';
import * as onFinished from 'on-finished';

import { startTooling } from './tools';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: diagnostics instead of tools?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if the specific file name matters.

@@ -0,0 +1,60 @@
import * as debugAgent from '@google-cloud/debug-agent';
import * as profiler from '@google-cloud/profiler';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that profiler currently has limitations on working with musl.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Do you recommend removing it? Or what is the suggestion?

@grant
Copy link
Contributor Author

grant commented Aug 26, 2019

In terms of fixing this PR, we need to setup gcloud with Travis and add the env var.
Added these TODOs to the PR description.

@grant
Copy link
Contributor Author

grant commented May 18, 2020

This PR needs more of a design doc and solution across all FFs. Let's continue in the GitHub issue.

@grant grant closed this May 18, 2020
@grant grant deleted the grant_stackdriver_trace branch March 23, 2021 15:59
@grant grant restored the grant_stackdriver_trace branch March 23, 2021 15:59
@grant grant deleted the grant_stackdriver_trace branch March 23, 2021 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants