forked from damoun/twitch_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,266 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Release Charts | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Configure Git | ||
run: | | ||
git config user.name "$GITHUB_ACTOR" | ||
git config user.email "$GITHUB_ACTOR@users.noreply.github.com" | ||
- name: Run chart-releaser | ||
uses: helm/chart-releaser-action@v1.7.0 | ||
env: | ||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{ | ||
// Place your twitch_exporter workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and | ||
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope | ||
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is | ||
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | ||
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. | ||
// Placeholders with the same ids are connected. | ||
// Example: | ||
// "Print to console": { | ||
// "scope": "javascript,typescript", | ||
// "prefix": "log", | ||
// "body": [ | ||
// "console.log('$1');", | ||
// "$2" | ||
// ], | ||
// "description": "Log output to console" | ||
// } | ||
"collector": { | ||
"description": "Quickly create a collector", | ||
"scope": "go", | ||
"prefix": "collector", | ||
"body": [ | ||
"package collector", | ||
"", | ||
"import (", | ||
"\t\"log/slog\"", | ||
"", | ||
"\t\"github.com/damoun/twitch_exporter/config\"", | ||
"", | ||
"\t\"github.com/nicklaw5/helix/v2\"", | ||
"\t\"github.com/prometheus/client_golang/prometheus\"", | ||
")", | ||
"", | ||
"type metricCollector struct {", | ||
"\tlogger *slog.Logger", | ||
"\tclient *helix.Client", | ||
"\tchannelNames *config.ChannelNames", | ||
"", | ||
"\tmetric typedDesc", | ||
"}", | ||
"", | ||
"func init() {", | ||
"\tregisterCollector(\"metric\", defaultEnabled, NewMetricCollector)", | ||
"}", | ||
"", | ||
"func NewMetricCollector(logger *slog.Logger, client *helix.Client, cfg *config.Config) (Collector, error) {", | ||
"\tc := metricCollector{", | ||
"\t\tlogger: logger,", | ||
"\t\tclient: client,", | ||
"\t\tchannelNames: cfg.Twitch.Channels,", | ||
"", | ||
"\t\tmetric: typedDesc{prometheus.NewDesc(", | ||
"\t\t\tprometheus.BuildFQName(namespace, \"\", \"metric\"),", | ||
"\t\t\t\"metric description\",", | ||
"\t\t\t[]string{\"username\"}, nil,", | ||
"\t\t), prometheus.GaugeValue},", | ||
"\t}", | ||
"", | ||
"\treturn c, nil", | ||
"}", | ||
"", | ||
"func (c metricCollector) Update(ch chan<- prometheus.Metric) error {", | ||
"\tif len(*c.channelNames) == 0 {", | ||
"\t\treturn ErrNoData", | ||
"\t}", | ||
"", | ||
"\tch <- c.metric.mustNewConstMetric(float64(1), \"username\")", | ||
"", | ||
"\treturn nil", | ||
"}", | ||
], | ||
"isFileTemplate": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Package", | ||
"type": "go", | ||
"request": "launch", | ||
"mode": "auto", | ||
"program": "${workspaceFolder}", | ||
"args": [ | ||
"--twitch.channel", | ||
"timthetatman" | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.