Skip to content
Merged
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
12 changes: 6 additions & 6 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ shards:

action-controller:
git: https://github.com/spider-gazelle/action-controller.git
version: 5.3.13
version: 5.4.2

active-model:
git: https://github.com/spider-gazelle/active-model.git
version: 4.0.0
version: 4.2.2

ameba:
git: https://github.com/crystal-ameba/ameba.git
version: 1.1.0
version: 1.2.0

backtracer:
git: https://github.com/sija/backtracer.cr.git
version: 1.2.2

bindata:
git: https://github.com/spider-gazelle/bindata.git
version: 1.10.0
version: 1.11.0

cron_parser:
git: https://github.com/kostya/cron_parser.git
Expand Down Expand Up @@ -78,7 +78,7 @@ shards:

json-schema:
git: https://github.com/spider-gazelle/json-schema.git
version: 1.2.1
version: 1.3.0

jwt:
git: https://github.com/crystal-community/jwt.git
Expand All @@ -102,7 +102,7 @@ shards:

neuroplastic:
git: https://github.com/spider-gazelle/neuroplastic.git
version: 1.12.0
version: 1.12.1

open_api:
git: https://github.com/elbywan/open_api.cr.git
Expand Down
16 changes: 9 additions & 7 deletions src/source/publishing/influx_publisher.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ module PlaceOS::Source
getter client : Flux::Client
getter bucket : String

alias FieldTypes = Bool | Float64 | String

abstract class CustomMetrics
include JSON::Serializable

Expand All @@ -23,7 +25,7 @@ module PlaceOS::Source

# Add these tags and fields to all the values
property ts_tags : Hash(String, String?)?
property ts_fields : Hash(String, Flux::Point::FieldType?)?
property ts_fields : Hash(String, FieldTypes?)?

# Allow custom measurement name to be used for entries
property measurement : String?
Expand All @@ -32,12 +34,12 @@ module PlaceOS::Source
class ComplexMetric < CustomMetrics
getter ts_hint : String = "complex"

property value : Array(Hash(String, Flux::Point::FieldType?))
property value : Array(Hash(String, FieldTypes?))
property ts_tag_keys : Array(String)?
property ts_map : Hash(String, String)?
end

alias Value = Flux::Point::FieldType | Hash(String, Flux::Point::FieldType?) | Hash(String, Hash(String, Flux::Point::FieldType?)) | Array(Hash(String, Flux::Point::FieldType?)) | CustomMetrics
alias Value = FieldTypes | Hash(String, FieldTypes?) | Hash(String, Hash(String, FieldTypes?)) | Array(Hash(String, FieldTypes?)) | CustomMetrics

def initialize(@client : Flux::Client, @bucket : String)
end
Expand Down Expand Up @@ -92,7 +94,7 @@ module PlaceOS::Source
begin
case raw = Value.from_json(payload)
in CustomMetrics then parse_custom(raw, fields, tags, data, timestamp)
in Flux::Point::FieldType
in FieldTypes
fields[key] = raw
point = Flux::Point.new!(
measurement: data.module_name,
Expand All @@ -102,16 +104,16 @@ module PlaceOS::Source
).tap &.fields.merge!(fields)

[point]
in Hash(String, Flux::Point::FieldType?)
in Hash(String, FieldTypes?)
[parse_hash(raw, nil, fields, tags, data, timestamp)].compact
in Hash(String, Hash(String, Flux::Point::FieldType?))
in Hash(String, Hash(String, FieldTypes?))
pos_uniq = 0
raw.compact_map do |hash_key, hash|
tags["pos_uniq"] = pos_uniq.to_s
pos_uniq += 1
parse_hash(hash, hash_key, fields, tags, data, timestamp)
end
in Array(Hash(String, Flux::Point::FieldType?))
in Array(Hash(String, FieldTypes?))
pos_uniq = 0
raw.compact_map do |hash|
tags["pos_uniq"] = pos_uniq.to_s
Expand Down