Skip to content

Commit

Permalink
Add common logging to scaler
Browse files Browse the repository at this point in the history
  • Loading branch information
nielm committed Dec 12, 2023
1 parent c41f95b commit 5f1c459
Show file tree
Hide file tree
Showing 14 changed files with 9,123 additions and 7,319 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

test-scaler:

runs-on: ubuntu-latest
runs-on: ubuntu-latestls

defaults:
run:
Expand Down
38 changes: 38 additions & 0 deletions src/autoscaler-common/logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
* Create a Bunyan Logger using structured logging to stdout.
*/
const bunyan = require('bunyan');
const {LoggingBunyan} = require('@google-cloud/logging-bunyan');

// Create logging client.
const loggingBunyan = new LoggingBunyan({
redirectToStdout: true,
projectId: process.env.PROJECT_ID,
logName: 'autoscaler',
useMessageField: false,
});

const logger = bunyan.createLogger({
name: 'cloud-spanner-autoscaler',
streams: [
loggingBunyan.stream('trace'),
],
});

module.exports = {
logger: logger,
};
1,213 changes: 1,213 additions & 0 deletions src/autoscaler-common/package-lock.json

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/autoscaler-common/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "autoscaler-common",
"description": "Common code for Spanner autoscater",
"license": "Apache-2.0",
"author": "Google Inc.",
"dependencies": {
"@google-cloud/logging-bunyan": "^5.0.1",
"bunyan": "^1.8.15"
}
}

Loading

0 comments on commit 5f1c459

Please sign in to comment.