Coder Social home page Coder Social logo

nr-battlesnake-attributes's Introduction

Battlesnake Custom Attributes for New Relic

In this repository you can find code and instructions for instrumenting a Battlsnake's performance with New Relic custom attributes. If you would like to add instrumentation in a language that is not yet documented in this repository, please use to following format for consistency (and consider submitting a PR!).

Custom Attribute Format

Move requests

Use the following JSON format for adding your custom attributes. These will appear alongside the relevant Transaction data in New Relic.

This example uses the POST request from the Battlesnake API docs:

{
  "snakeGameId": "game-00fe20da-94ad-11ea-bb37",
  "snakeRules": "standard",
  "snakeTurn": 14,

  "snakeBoardHeight": 11,
  "snakeBoardWidth": 11,
  "snakeBoardFood": "W3sieCI6NSwieSI6NX0seyJ4Ijo5LCJ5IjowfSx7IngiOjIsInkiOjZ9XQ==",
  "snakeBoardHazards": "W3sieCI6MywieSI6Mn1d",

  "snakeName": "My Snake",
  "snakeId": "snake-508e96ac-94ad-11ea-bb37",
  "snakeHealth": 54,
  "snakeLength": 3,
  "snakeData": "eyJib2R5IjpbeyJ4IjowLCJ5IjowfSx7IngiOjEsInkiOjB9LHsieCI6MiwieSI6MH1dLCJoZWFkIjp7IngiOjAsInkiOjB9LCJjb2xvciI6IiNGRjAwMDAifQ==",

  "snakeOpponent_1_Name": "Another Snake",
  "snakeOpponent_1_Id": "snake-b67f4906-94ae-11ea-bb37",
  "snakeOpponent_1_Health": 16,
  "snakeOpponent_1_Length": 4,
  "snakeOpponent_1_Data": "eyJib2R5IjpbeyJ4Ijo1LCJ5Ijo0fSx7IngiOjUsInkiOjN9LHsieCI6NiwieSI6M30seyJ4Ijo2LCJ5IjoyfV0sImhlYWQiOnsieCI6NSwieSI6NH0sImNvbG9yIjoiIzI2Q0YwNCJ9"
}

In order to keep keep the attribute size under the 255 byte limit, some of the board state should be turned into a JSON string and base64 encoded:

Attribute Description
snakeBoardFood board.food in the POST request
snakeBoardHazards board.hazards in the POST request
snakeData The body, head and customizations.color (as color) data for your snake
snakeOpponent_N_Data Same as snakeData for each opponent

These encoded values are optional, but will be utilized for some upcoming custom visualizations in New Relic.

End requests

Use the following JSON format for adding your custom attributes. These will appear alongside the relevant Transaction data in New Relic.

This example uses the POST request from the Battlesnake API docs:

{
  "snakeGameId": "game-00fe20da-94ad-11ea-bb37",
  "snakeRules": "standard",
  "snakeTurn": 14,

  "snakeName": "My Snake",
  "snakeId": "snake-508e96ac-94ad-11ea-bb37",
  "snakeHealth": 54,
  "snakeLength": 3,

  "snakeGameWinnerName": "My Snake",
  "snakeGameWinnerId": "snake-508e96ac-94ad-11ea-bb37",
  "snakeGameIsWin": true,
  "snakeGameReplayLink": "https://play.battlesnake.com/g/game-00fe20da-94ad-11ea-bb37"
}

nr-battlesnake-attributes's People

Watchers

 avatar

nr-battlesnake-attributes's Issues

Add _all_ attribute information for `/end` transaction

At the moment, we're only sending some basic game state as attributes during the /end transaction. We should send the same data that we're sending for the /move transaction.

This will help us build consistent dashboard charts and custom experiences.

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.