Code Monkey home page Code Monkey logo

Comments (7)

christiand93 avatar christiand93 commented on June 12, 2024

We currently do not track request context for custom logs, therefore we cannot provide correlation_id forwarding.

from cf-nodejs-logging-support.

christiand93 avatar christiand93 commented on June 12, 2024

After some investigation, we have implemented request context bound logging for custom messages. This will keep track of request_id and correlation_id. We documented the correct usage of this feature in the ReadMe file.

Kind regards,
Christian

from cf-nodejs-logging-support.

perdasilva avatar perdasilva commented on June 12, 2024

Hi Christian,

Thanks for getting back to me. Sorry for the vague questions, I checked the code out and saw that it should be showing me the correlation_id in kibana, but it wasn't. I'm working on a python version of the cf_logger. I noticed that if you change the type field to 'log' you start to see correlation_id in the 'Application Logs' section of 'Requests and Logs'. Do you want me to branch, confirm, and create a pull request?

Cheers,

Per

from cf-nodejs-logging-support.

christiand93 avatar christiand93 commented on June 12, 2024

Hi Per,

we could not reproduce this behaviour. In custom log messages, the 'type' field is already set to 'log' and correlation_id is forwarded in any case. We checked our logs with the kibana Discover tab, so we could confirm the correct parsed json data was put through to kibana. It would be nice if you could confirm that the correlation id is missing for you there.

Kind regards,
Christian

from cf-nodejs-logging-support.

perdasilva avatar perdasilva commented on June 12, 2024

Hey Christian,

I think I see the problem. I'm not using the winstonTransport. I will update the code and try again.
I've been basically doing:

var express = require('express');
var log = require('cf-nodejs-logging-support');
var busboy = require('connect-busboy');
var AWS = require('aws-sdk');
var randomstring = require('randomstring');
var proxy = require('proxy-agent');
var crypto = require('crypto');
var app = express();

// setup server and logging
log.setLoggingLevel('info');
app.use(log.logNetwork);
app.use(busboy());

// setup aws
AWS.config.update({
httpOptions: {
agent: proxy('http://proxy.wdf.sap.corp:8080')
}
});
AWS.config.region = 'eu-central-1';
AWS.config.sslEnabled = true;
AWS.config.logger = log;

// create cypher
var encryptionAlgorithm = 'aes-256-ctr';
var encryptionKey = '764efa883dda1e11db47671c4a3bbd9e';
var encrypt = crypto.createCipher(encryptionAlgorithm, encryptionKey);

var handlePost = function(streamFn) {
// use identify function as default
streamFn = streamFn || function(stream) { return stream; }

return function(req, res) {
    if(req.busboy) {
        log.logMessage('info', 'Got request');
        req.busboy.on('file', function (fieldName, fileStream, fileName) {
            uploadToS3(fileName, streamFn(fileStream), function (error, data) {
                res.send(error || data);
            });
        });

        return req.pipe(req.busboy);
    }
}

}

var uploadToS3 = function(name, stream, callback) {
log.logMessage('info', 'Uploading file: ' + name);

var bucket = {
    params: {
        Bucket: 'd054086',
        Key: randomstring.generate() + '/' + name
    }
};

var s3Upload = (new AWS.S3(bucket)).upload({
    Body: stream
});

s3Upload.on('httpUploadProgress', function(event) {
    log.logMessage('info', event);
});

s3Upload.send(function(error, data) {
    stream.end();
    callback(error, data);
});

}

// add routes
app.post('/', handlePost());
app.post('/encrypted', handlePost(function(stream) { return stream.pipe(encrypt); }));

// start server
var port = process.env['PORT'] || 3000;
app.listen(port, function() {
log.logMessage('info', 'server is started on port %d', port)
});

from cf-nodejs-logging-support.

christiand93 avatar christiand93 commented on June 12, 2024

If you want to get the correlation_id from logMessage, you need to call it like this:
req.logMessage(...)

We can't provide correlation_id tracking outside the context of a request, because we cannot be sure which request to correlate to, if there are multiple pending requests.

from cf-nodejs-logging-support.

perdasilva avatar perdasilva commented on June 12, 2024

ahhhh - okie - all clear now. Thank you!! sorry if I caused trouble...

from cf-nodejs-logging-support.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.