Git Product home page Git Product logo

Comments (4)

yannmh avatar yannmh commented on June 15, 2024

Thanks a lot for the detailed explanations @gnarf !

I like the idea of making the 'trim' strategy configurable. I reckon 'head' should probably be the default behavior.

We'll work on it for the next version 🚀

from datadogpy.

gnarf avatar gnarf commented on June 15, 2024

Considering the errors are USUALLY at the bottom when there are errors, I
like the one that mixes a bit of head and a bit of tail best

On Mon, Oct 19, 2015 at 6:55 PM, Yann [email protected] wrote:

Thanks a lot for the detailed explanations @gnarf
https://github.com/gnarf !

I like the idea of making the 'trim' strategy configurable. I reckon
'head' should probably be the default behavior.

We'll work on it for the next version [image: 🚀]


Reply to this email directly or view it on GitHub
#91 (comment).

from datadogpy.

yannmh avatar yannmh commented on June 15, 2024

You make a point, the third option sounds more reasonable.
Thanks again @gnarf.

from datadogpy.

gnarf avatar gnarf commented on June 15, 2024

This code is like really quick and dirty, but this is what I implemented in my own node.js script (if it helps at all)

Note: output contains stderr + stdout

module.exports = function(err, event) {
  var text = "%%%\nExit Code: " + event.exit + " Time: " + (event.time/1000).toFixed(3) + "s\n";

  var payload_text_limit = 4000;

  if (event.output.length > (payload_text_limit - text.length - 100) ) {
    text += 'Start:\n```\n';
    var lines = event.output.split('\n');
    while (text.length < (payload_text_limit / 3)) {
      text += lines.shift() + '\n';
    }
    text += '```\n';
    text += '...trimmed...\n';
    text += '```\n';

    var ending = '```\n';
    while ((ending.length + text.length + lines[lines.length-1].length + 1) < payload_text_limit) {
      ending = lines.pop() + '\n' + ending;
    }
    text += ending;
  } else {
    text += 'Output:\n```\n' + event.output + '\n```\n';
  }

  var properties = {
    tags: [ '#deploy:' + event.eventData.owner + '/' + event.eventData.repo, '#env:{{ deploy_env }}' ],
    host: os.hostname(),
    alert_type: event.exit ? 'error' : 'success',
    date_happened: event.start,
    source_type_name: 'deploy',
  };
  dogapi.event.create("[" + os.hostname() + "] deploy " + event.filename, text, properties);
};

I'm not proud of the readability or methods this thing uses, but hey - it works ;)

from datadogpy.

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.