Skip to content

Stage errors for repo integration#2017

Merged
stephenplusplus merged 29 commits intogoogleapis:masterfrom
cristiancavalli:error-library-integration
Apr 6, 2017
Merged

Stage errors for repo integration#2017
stephenplusplus merged 29 commits intogoogleapis:masterfrom
cristiancavalli:error-library-integration

Conversation

@cristiancavalli
Copy link
Contributor

@cristiancavalli cristiancavalli commented Feb 23, 2017

TODOS:

  • Refactor test directory to follow repo conventions
  • Unit and system tests pass
  • Fix linting errors
  • Switch from diagnostics-common to gcp-common

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 23, 2017
@cristiancavalli
Copy link
Contributor Author

cc @GoogleCloudPlatform/node-team

@ofrobots
Copy link
Contributor

ofrobots commented Feb 23, 2017

This PR brings in the Stackdriver Error Reporting library as a client library. This is currently available as the @google/cloud-errors module. It would good to convert this to be the actual client library for Stackdriver error reporting (in the interest of minimizing the number of 'official' modules that work with Stackdriver error reporting). That is, we want to rename the module to be @google-cloud/error-reporting.

At the moment this only has support for the 'write' side of the Error Reporting API, but we expect to add the 'read' side of the API in follow-ons.

@cristiancavalli
Copy link
Contributor Author

@GoogleCloudPlatform/node-team ready for a look

"undef": true,
"unused": "vars",
"globals": {
/* Mocha-provided globals */

This comment was marked as spam.

sudo: false
language: node_js
node_js:
- '0.12'

This comment was marked as spam.

This comment was marked as spam.

*/
CustomStackTrace.prototype.setFilePath = function(filePath) {

this.filePath = isString(filePath) ? filePath: '';

This comment was marked as spam.

This comment was marked as spam.

Copy link
Contributor

@kjin kjin left a comment

Choose a reason for hiding this comment

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

Looks good from my end (w/ nit).

Fuzzer.prototype.generate.array = function(len, ofOneType, currentDepth, allowedDepth) {

var lenChecked = isNumber(len) ? len : random(1, 10);
var availableTypes = (isString(ofOneType) && (indexOf(this.types(), ofOneType) > -1)) ? [ofOneType]: this.types();

This comment was marked as spam.

@@ -0,0 +1,8 @@
sudo: false

This comment was marked as spam.

@@ -0,0 +1,5 @@
/bin

This comment was marked as spam.

@@ -0,0 +1,29 @@
# Node.js Agent for Google Cloud Errors ChangeLog

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,80 @@
#!/usr/bin/env bash

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

"main": "index.js",
"repository": "GoogleCloudPlatform/google-cloud-node",
"scripts": {
"test": "$(npm bin)/nyc --exclude=\"fuzzer.js\" $(npm bin)/mocha ./test/unit/*.js",

This comment was marked as spam.

@@ -0,0 +1,55 @@
{
"name": "@google-cloud/error-reporting",
"version": "0.1.0",

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,55 @@
{

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

"scripts": {
"test": "$(npm bin)/nyc --exclude=\"fuzzer.js\" $(npm bin)/mocha ./test/unit/*.js",
"integration-tests": "$(npm bin)/nyc --exclude=\"error-message.js\" $(npm bin)/mocha ./test/system-test/*.js",
"style": "$(npm bin)/jshint lib index.js",

This comment was marked as spam.

"repository": "GoogleCloudPlatform/google-cloud-node",
"scripts": {
"test": "$(npm bin)/nyc --exclude=\"fuzzer.js\" $(npm bin)/mocha ./test/unit/*.js",
"integration-tests": "$(npm bin)/nyc --exclude=\"error-message.js\" $(npm bin)/mocha ./test/system-test/*.js",

This comment was marked as spam.

"@google-cloud/common": "^0.12.0",
"extend": "^3.0.0",
"is": "^3.2.0",
"lodash.has": "^4.5.2"

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@cristiancavalli
Copy link
Contributor Author

@stephenplusplus ready for another look

@stephenplusplus
Copy link
Contributor

@cristiancavalli thanks! As far as the code of the library itself, I'm going to remain hands-off there and let you guys run it the way you see fit. As long as you're happy with how it looks and acts, I'm not concerned if it doesn't follow the conventions of the other parts of our library. I'm mostly concerned with the details of the integration when it comes to testing, releasing, and docs. Those are the types of questions I've brought up in comments above, attached to their relevant files in the PR. PTAL for those and feel free to elaborate on the expectations for these integrations.

> **This is not an official Google product.** This module is experimental and may not be ready for use.
> This module uses APIs that may be undocumented and are subject to change without notice.

This modules provides Stackdriver Error Reporting support for Node.js applications.

This comment was marked as spam.

This comment was marked as spam.


Container Engine nodes need to also be created with the `https://www.googleapis.com/auth/cloud-platform` scope, which is configurable during cluster creation. Alternatively, you can follow the instructions for using a service account under [running elsewhere](#running-elsewhere). It's recommended that you store the service account credentials as [Kubernetes Secret](http://kubernetes.io/v1.1/docs/user-guide/secrets.html).

## Running elsewhere

This comment was marked as spam.

This comment was marked as spam.

```JS
var express = require('express');
var app = express();
// Will create a errors instance based off env variables

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,230 @@
# Node.js module for Stackdriver Error Reporting

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

path: '/error',
handler: function(request, reply) {
throw new Error('Custom error message');
reply('Something broke!');

This comment was marked as spam.

This comment was marked as spam.

"repository": "GoogleCloudPlatform/google-cloud-node",
"scripts": {
"test": "nyc --exclude=\"fuzzer.js\" $(npm bin)/mocha ./test/unit/*.js",
"system-test": "nyc --exclude=\"error-message.js\" $(npm bin)/mocha ./test/system-test/*.js",

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,353 @@
/**

This comment was marked as spam.

This comment was marked as spam.

"test": "nyc --exclude=\"fuzzer.js\" $(npm bin)/mocha ./test/unit/*.js",
"system-test": "nyc --exclude=\"error-message.js\" $(npm bin)/mocha ./test/system-test/*.js",
"lint": "jshint src/ index.js",
"docs": "jsdoc -d docs index.js src/",

This comment was marked as spam.

This comment was marked as spam.

"main": "index.js",
"repository": "GoogleCloudPlatform/google-cloud-node",
"scripts": {
"test": "nyc --exclude=\"fuzzer.js\" $(npm bin)/mocha ./test/unit/*.js",

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

"@google-cloud/common": "^0.12.0",
"extend": "^3.0.0",
"is": "^3.2.0",
"lodash.has": "^4.5.2"

This comment was marked as spam.

@stephenplusplus
Copy link
Contributor

Moving the convo about how we're planning to integrate out here instead of in the code comments section

RE: #2017 (comment)

Let me know if this sounds right. Before we merge, this is the extent of our process integration.

The GCN CI:

@cristiancavalli
Copy link
Contributor Author

@stephenplusplus Your proposal seems like the best given the current constraints

@stephenplusplus
Copy link
Contributor

Cool, then @callmehiphop, can you step in and figure out what we need to do for docs?

Also cc @lukesneeringer for any thoughts on the "big picture" plan outlined above.

@ofrobots
Copy link
Contributor

For the purposes of making progress on this PR, it makes sense to skip CI for now, but I would expect a follow-on refactor to add the unit tests and system tests back into the CI. At least that is my understanding of the integration here.

@lukesneeringer
Copy link
Contributor

For the purposes of making progress on this PR, it makes sense to skip CI for now, but I would expect a follow-on refactor to add the unit tests and system tests back into the CI. At least that is my understanding of the integration here.

That makes me all kinds of nervous. Is there a hard deliverable or OKR to get this done?

What is the challenge here? Is it just moving the tests up one level, or something else?

@ofrobots
Copy link
Contributor

@lukesneeringer The idea was to keep the review burden on y'all for the initial PR low. If that is not a problem, then we can add the CI refactoring here too. I am not too worried though as the origin repo for this code is still running CI, and my expectation is that we will immediately follow-up on with CI support this repo once this PR lands.

@lukesneeringer
Copy link
Contributor

@ofrobots Sold.

@ofrobots
Copy link
Contributor

I am guessing that the 'sold' refers to landing + following up with a PR to enable CI support. @cristiancavalli, @stephenplusplus anything else that remains to be done before proceeding here?

@cristiancavalli
Copy link
Contributor Author

@ofrobots 👍

@lukesneeringer
Copy link
Contributor

@ofrobots It essentially meant, "I accept what you said and am happy with it." Sorry. :-)

@stephenplusplus
Copy link
Contributor

I believe we still need to figure out the docs, which is why this is assigned to @callmehiphop.

Copy link
Contributor

@callmehiphop callmehiphop left a comment

Choose a reason for hiding this comment

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

For a documentation review, we need a few things

Overview configs

Essentially I think we just need the following code added to the OVERVIEW map

    'error-reporting': {
      title: 'Error Reporting',
      instanceName: 'errors'
    },

Otherwise I found the examples in the index.js file to be kind of lacking? We don't quite follow the ways of JSDoc, so this would be the only file to really show up on our doc site.

A few alterations are also needed within our documentation scripts, but I can put a PR together for that this afternoon.

* @memberof Configuration
* @public
* @function getCredentials
* @returns {Credentials\Null} - returns the _credentials property

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -0,0 +1,97 @@
/**

This comment was marked as spam.

* this function will also return an interface which can be used manually via
* the `report` function property, with hapi via the `hapi` object property or
* with express via the `express` function property.
* @function initConfiguration

This comment was marked as spam.

uncaughtException(client, config);

// Build the application interfaces for use by the hosting application
this.hapi = hapi(client, config);

This comment was marked as spam.

@stephenplusplus
Copy link
Contributor

Adding onto the comment about examples in index.js, is it possible to move this file to the src directory?

@cristiancavalli
Copy link
Contributor Author

cristiancavalli commented Apr 4, 2017

@stephenplusplus @callmehiphop Thanks for the feedback gentlemen! Changes are posted

cc @ofrobots

@cristiancavalli cristiancavalli force-pushed the error-library-integration branch from df8c167 to 58af011 Compare April 4, 2017 20:08
@cristiancavalli
Copy link
Contributor Author

@stephenplusplus freshly rebased

@stephenplusplus
Copy link
Contributor

Looks like the lint task is failing. Can you run 'npm run lint' from the root directory to take a look?

@cristiancavalli
Copy link
Contributor Author

@stephenplusplus updated

@cristiancavalli
Copy link
Contributor Author

cristiancavalli commented Apr 5, 2017

@stephenplusplus @callmehiphop

I'm having some trouble with the snippet test, specifically this error from the ci:

Cannot find module '../packages/error-reporting/node_modules/@google-cloud/error-reporting

Would you gentlemen know where this is coming from and how to fix it?

@ofrobots
Copy link
Contributor

ofrobots commented Apr 6, 2017

@stephenplusplus @lukesneeringer bump. It would be good to be able to land this soon.

@callmehiphop
Copy link
Contributor

@cristiancavalli sorry I didn't catch this one in my docs review! When we write examples we don't include any snippets on how to require the module itself. This code usually is generated and included within an overview. After which, we assume any requiring of @google-cloud packages is showing how to integrate with other modules - so we do some magic to require the local instance of whatever package.

Long story short, the fix would be to remove the require('@google-cloud/error-reporting') parts of the examples from the docs.

@cristiancavalli
Copy link
Contributor Author

@callmehiphop Thanks for the info! Updated the PR and added fake injection dependencies for snippet tests.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 475eedb on cristiancavalli:error-library-integration into ** on GoogleCloudPlatform:master**.

@cristiancavalli
Copy link
Contributor Author

Build is now passing on CircleCI

cc @stephenplusplus @ofrobots

@stephenplusplus stephenplusplus merged commit 4fc204c into googleapis:master Apr 6, 2017
@stephenplusplus
Copy link
Contributor

Hooray!! 🎉 🍰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: error-reporting cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants