I am using newrelic's ruby sdk to develop a custom plugin. When I run the sample app, on the terminal it shows that the data is successfully captured. But when i go to the site, it cannot search the metrics and due to that I cannot look at any data reported.
the plugin name and everthing else shows up but don't where the data is going.
This what the agent file looks like:
require "rubygems"
require "bundler/setup"
require "newrelic_plugin"
module ExampleAgent
class Agent < NewRelic::Plugin::Agent::Base
agent_guid "com.phytel.Product1"
agent_version "1.0.1"
agent_config_options :hostname # frequency of the periodic functions
agent_human_labels("Product1") { "Call Statuses" }
def poll_cycle
# x = Time.now.to_f * hertz * Math::PI * 2
report_metric "Component/Status/Progressing", "Value", 10
report_metric "Component/Status/Scheduled", "Value", 20
report_metric "Component/Status/Busy", "Value", 2
end
end
#
# Register this agent with the component.
# The ExampleAgent is the name of the module that defines this
# driver (the module must contain at least three classes - a
# PollCycle, a Metric and an Agent class, as defined above).
#
NewRelic::Plugin::Setup.install_agent :example, ExampleAgent
#
# Launch the agent; this never returns.
#
NewRelic::Plugin::Run.setup_and_run
end
Don't put the Component part in your metric name. The SDK automatically adds that for you.
Related
I'm confused about a difference I'm seeing in Nokogiri commands run from Rails Console and what I get from the same commands run in a Rails Helper.
In Rails Console, I am able to capture the data I want with these commands:
endpoint = "https://basketball-reference.com/leagues/BAA_1947_totals.html"
browser = Watir::Browser.new(:chrome)
browser.goto(endpoint)
#doc_season = Nokogiri::HTML.parse(URI.open("https://basketball-reference.com/leagues/BAA_1947_totals.html"))
player_season_table = #doc_season.css("tbody")
rows = player_season_table.css("tr")
rows.search('.thead').each(&:remove) #THIS WORKED
rows[0].at_css("td").try(:text) # Gets single player name
rows[0].at_css("a").attributes["href"].try(:value) # Gets that player page URL
However, my rails helper that is meant to take those commands and fold them into methods:
module ScraperHelper
def target_scrape(url)
browser = Watir::Browser.new(:chrome)
browser.goto(url)
doc = Nokogiri::HTML.parse(browser.html)
end
def league_year_prefix(year, league = 'NBA')
# aba_seasons = 1968..1976
baa_seasons = 1947..1949
baa_seasons.include?(year) ? league_year = "BAA_#{year}" : league_year = "#{league}_#{year}"
end
def players_total_of_season(year, league = 'NBA')
# always the latter year of the season, first year is 1947 no quotes
# ABA is 1968 to 1976
league_year = league_year_prefix(year, league)
#doc_season = target_scrape("http://basketball-reference.com/leagues/#{league_year}_totals.html")
end
def gather_players_from_season
player_season_table = #doc_season.css("tbody")
rows = player_season_table.css("tr")
rows.search('.thead').each(&:remove)
puts rows[0].at_css("td").try(:text)
puts rows[0].at_css("a").attributes["href"].try(:value)
end
end
On that module, I try to emulate the rails console commands and break them into modules. And to test it out (since I don't have any other functionality or views built yet), I run Rails console, include this helper and run the methods.
But I get wildly different results.
in the gather_players_from_season method, I can see that
player_season_table = #doc_season.css("tbody")
Is no longer grabbing the same data it grabbed when run as a command line by line. It also doesn't like the attributes method here:
puts rows[0].at_css("a").attributes["href"].try(:value)
So my first thought is a difference in gems maybe? Watir is launching the headless browser. Nokogiri isn't causing errors as near as I can tell.
Your first thought of comparing the Gem versions is a great idea, but I am noticing a difference between the two code solutions:
In the Rails Console
the code parses the HTML with URI.open: Nokogiri::HTML.parse(URI.open("some html"))
In the ScraperHelper code
the code does not call URI.open, Nokogiri::HTML.parse("some html")
Perhaps that difference will return different values and make the rest of the ScraperHelper return unexpected results.
I know how to add translations to my custom module (with .po-files in \i18n-folder). I also know how to force Odoo.sh to automatically update my custom module during build, with updating the version-number.
This works fine for data, views, and so on. But is doesn't seem to work for my translations. I always have to go to Developer-mode -> Settings -> Translations -> Activate/update.
How can I also automate the update of my translations?
EDIT:
I've found the post_init_hook, and tried the following:
# coding: utf-8
from odoo import api, fields, models, _, SUPERUSER_ID
def install_languages(cr, registry):
""" Post init function """
env = api.Environment(cr, SUPERUSER_ID, {})
# install DE language
lang_de = env['base.language.install'].create({'lang': 'de_DE', 'overwrite': False})
env['base.language.install'].lang_install(lang_de)
The line env['base.language.install'].create({'lang': 'de_DE', 'overwrite': False}) however, generates a build-warning with Transient module states were reset, and then a build-error occurs Failed to load registry and Failed to load database....
EDIT 2:
the error had another cause and is fixed.
the post_init gives no error, but also does not update the language.
I am working on a Jira/Rally (CA Agile Central) integration and can get a basic sync to work, however some fields require a more complex transformation when syncing them between Jira and Rally.
For this I can see that the CA Agile Connector (https://help.rallydev.com/jira-installation-user-guide) provides some support for "custom field handlers" which are written in Ruby and follow a format like:
# Copyright 2015 CA Technologies. All Rights Reserved.
require 'rallyeif/wrk/field_handlers/field_handler'
module RallyEIF
module WRK
module FieldHandlers
class MyCustomFieldHandler < OtherFieldHandler
def initialize(field_name = nil)
super(field_name)
end
# ... more code here ...
end
end
end
end
However when I create that file and add the following to my connector config:
...
<Connector>
<FieldMapping>
<Field>
<Rally>Description</Rally>
<Other>Description</Other>
<Direction>TO_RALLY</Direction>
</Field>
...
</FieldMapping>
<OtherFieldHandlers>
<MyCustomFieldHandler>
<FieldName>Description</FieldName>
</MyCustomFieldHandler>
</OtherFieldHandlers>
</Connector>
...
When running the connector I get the following error:
[2017-08-22 20:25:39 Z] ERROR : RallyEIF::WRK::Connector.rescue in block in read_field_handlers - For RallyEIF::WRK::JiraConnection: Could not find class for MyCustomFieldHandler
The documentation does not mention how to use the custom handlers at all, so I'm wondering if anyone has used this feature and can share some information on how to declare and use the custom field handlers.
I tested connector version 4.7.2 and it worked. Things to check:
within the folder where the connector is invoked, there must be a folder named "field_handlers"
within this "field_handlers" folder, there must be a file (as you have shown above) with "class MyCustomFieldHandler < ...."
There is an example on the help pages. It's for HP-ALM (QC) not for JIRA, but the concept is the same:
https://help.rallydev.com/QC-custom-fieldhandler.pxml
End of ideas so far.
I'm trying to create a gem which exposes an ActionCable channel, but I can't get it to work.
This is my gem
# lib/my_channel.rb
class MyChannel < ActionCable::Channel::Base
def wait(data)
# logic ...
end
end
# lib/engine.rb
module MyApp
class Engine < ::Rails::Engine
isolate_namespace MyApp
end
end
I then add the gem to my main applications Gemfile, run bundle install, start up the console and run MyChannel. Which don't yield and error, meaning that the channel as been included properly.
I then add this to my main application
// application.js
var socket = "ws://localhost:3000/cable";
var cable = ActionCable.createConsumer(socket);
cable.subscriptions.create({ "channel": "MyChannel" }, {
received: function(){
// ...
}
});
But I'm getting this error
Subscription class not found ({"command"=>"subscribe", "identifier"=>"{\"channel\":\"MyChannel\"}"})
What am I missing?
This answer doesn't apply to gems, only making channels within a Rails app.
Your my_channel.rb is located in the wrong place. I'm not sure if behaviour has changed between the betas (I'm using beta3), but it should be located in app/channels/application_cable/.
I was experiencing the same issue, and realized my channel file was named inappropriately (host.rb instead of host_channel.rb). After renaming the file, it started working.
I believe the channel files are only searched for with the specific location and naming scheme (app/channels/application_cable/*_channel.rb) by default.
I am quite new to C++ socket programming. Since I am in an FRC team, I need to communicate between my application and the Compact RIO via an interface known as "Network Tables". I need to communicate from my C++ vision application to our robot code in Java. How do I implement NetworkTables in regular C++?
So here is what I did in python but the concept is the same. The goal would be to move motors based on values (sensor data) from what you receive in your driver station? so, how do I accomplish this... data transfers will be done through network tables
first, initlize...
from networktables import NetworkTables
# As a client to connect to a robot
NetworkTables.initialize(server='roborio-XXX-frc.local')
creating the instance you will be able to access NetworkTables conections, configure settings, listeners and create table objects which is what is actually being used to send data
next,
sd = NetworkTables.getTable('SmartDashboard')
sd.putNumber('someNumber', 1234)
otherNumber = sd.getNumber('otherNumber')
Here, we're interacting with the SmartDashboard and calling two methods, to send and recieve values.
another example, from API docs
#!/usr/bin/env python3
#
# This is a NetworkTables server (eg, the robot or simulator side).
#
# On a real robot, you probably would create an instance of the
# wpilib.SmartDashboard object and use that instead -- but it's really
# just a passthru to the underlying NetworkTable object.
#
# When running, this will continue incrementing the value 'robotTime',
# and the value should be visible to networktables clients such as
# SmartDashboard. To view using the SmartDashboard, you can launch it
# like so:
#
# SmartDashboard.jar ip 127.0.0.1
#
import time
from networktables import NetworkTables
# To see messages from networktables, you must setup logging
import logging
logging.basicConfig(level=logging.DEBUG)
NetworkTables.initialize()
sd = NetworkTables.getTable("SmartDashboard")
i = 0
while True:
print("dsTime:", sd.getNumber("dsTime", -1))
sd.putNumber("robotTime", i)
time.sleep(1)
i += 1