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

fix: eslint errors #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
extends: airbnb
rules:
no-param-reassign: [error, { props: false }]
no-unused-vars: [2, {args: after-used, argsIgnorePattern: "_"}]
new-cap: 0
8 changes: 4 additions & 4 deletions lib/http/routers/FunctionsRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const SchemaResponse = require('../SchemaResponse');
const router = new Router();
const { bodyParserLimit } = require('../../support/config');
const { reportError } = require('../../support/tracing');
const { RecordOtelError } = require('../../support/opentelemetry')
const { RecordOtelError } = require('../../support/opentelemetry');

function codeFileName(namespace, codeId) {
return `${namespace}/${codeId}.js`;
Expand Down Expand Up @@ -195,7 +195,7 @@ router.delete('/:namespace/:id', async (req, res, next) => {
});


router.all('/:namespace/:id/run', bodyParser.json({ limit: bodyParserLimit }), async (req, res, next) => {
router.all('/:namespace/:id/run', bodyParser.json({ limit: bodyParserLimit }), async (req, res, _) => {
const { namespace, id } = req.params;
const memoryStorage = req.app.get('memoryStorage');
const sandbox = req.app.get('sandbox');
Expand Down Expand Up @@ -277,7 +277,7 @@ router.all('/:namespace/:id/run', bodyParser.json({ limit: bodyParserLimit }), a
code: code.code,
});
errTracker.notify(err);
RecordOtelError(err)
RecordOtelError(err);
}
});

Expand Down Expand Up @@ -336,7 +336,7 @@ router.put('/pipeline', bodyParser.json({ limit: bodyParserLimit }), async (req,
res.json(result.body);
} catch (err) {
reportError(span, err);
RecordOtelError(err)
RecordOtelError(err);
const status = err.statusCode || 500;
metric.observePipelineRun(status);
res.status(status).json({ error: err.message });
Expand Down
2 changes: 1 addition & 1 deletion lib/http/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ morgan.token('response-sectime', (req, res) => {
return secs.toFixed(3);
});
const app = express();
const traceEngine = config.trace.engine
const traceEngine = config.trace.engine;
app.use(morgan(config.log.morganFormat));
app.use(expressOpentracing.default({ tracer }));

Expand Down
2 changes: 1 addition & 1 deletion lib/support/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const DEFAULT_GLOBAL_MODULES = [
];

module.exports = {
host: process.env.HOSTNAME || "localhost",
host: process.env.HOSTNAME || 'localhost',
port: ConfigDiscovery.getInt('PORT', 8100),
metricsPort: ConfigDiscovery.getInt('METRICS_PORT', 8101),
useNodeCluster: ConfigDiscovery.getBool('USE_NODE_CLUSTER', true),
Expand Down
36 changes: 18 additions & 18 deletions lib/support/opentelemetry.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ const { ExpressInstrumentation } = require('@opentelemetry/instrumentation-expre
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector-grpc');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { IORedisInstrumentation } = require('@opentelemetry/instrumentation-ioredis')
const config = require('./config')

const { IORedisInstrumentation } = require('@opentelemetry/instrumentation-ioredis');
const config = require('./config');
const opentelemetry = require('@opentelemetry/api');

const OtelConfig = config.trace.otel;
const HOST = config.host
const HOST = config.host;

const collectorOptions = {
serviceName: OtelConfig.service,
url: `${OtelConfig.collector.host}:${OtelConfig.collector.port}`,
concurrencyLimit: 10
}
serviceName: OtelConfig.service,
url: `${OtelConfig.collector.host}:${OtelConfig.collector.port}`,
concurrencyLimit: 10,
};

const provider = new NodeTracerProvider();

provider.resource = provider.resource.merge({
attributes: {
"service.instance.id": HOST
}
})
'service.instance.id': HOST,
},
});

const exporter = new CollectorTraceExporter(collectorOptions);
provider.addSpanProcessor(new BatchSpanProcessor(exporter, {
Expand All @@ -39,11 +39,11 @@ registerInstrumentations({
span.updateName(`${attrs['http.method']} ${attrs['http.target']}`);
span.setAttribute('functions.route', attrs['http.route']);
span.setAttribute('functions.url', attrs['http.url']);
},
},
ignoreOutgoingUrls: [/.*\/agent_listener/, /.*\/sampling/],
ignoreIncomingPaths: [/.*\/healthcheck/, /.*\/metrics/, /.*\/sampling/]
ignoreIncomingPaths: [/.*\/healthcheck/, /.*\/metrics/, /.*\/sampling/],
}),
new ExpressInstrumentation()
new ExpressInstrumentation(),
],
});

Expand All @@ -63,10 +63,10 @@ function FinalizeSpanMiddleware(req, res, next) {
}

function RecordOtelError(err) {
const span = tracer.startSpan('Exception Throwed')
span.recordException(err.stack)
span.setStatus({code: opentelemetry.SpanStatusCode.ERROR })
span.end()
const span = tracer.startSpan('Exception Throwed');
span.recordException(err.stack);
span.setStatus({ code: opentelemetry.SpanStatusCode.ERROR });
span.end();
}

module.exports = { StartSpanMiddleware, FinalizeSpanMiddleware, RecordOtelError };