Metrics Documentation

Official Go developer resources and documentation for openziti/Metrics with 3 stars. Verified technical context for AI.

3 stars Go Go 1 file ยท ~2,796 tokens
RAW Doc

File: README.md

Ziti Metrics Library

This is a metrics library which is built on, and extends the
go-metrics library.

It extends it by adding the following:

  1. A Dispose method is defined on metrics, so they can be cleaned up, for metrics tied to transient entities.
  2. Reference counted metrics
  3. A Visitor over the registry, so collected metrics can be reported to any sink.

v2

v2 is collection-only. The metrics wire format (the MetricsMessage protobuf,
the message builder, and the interval/usage counter reporting subsystem) has been
removed; consumers that need to serialize metrics own that format themselves and
read a registry through AcceptVisitor. Import as
github.com/openziti/metrics/v2.

v3

v3 separates reference counted metrics from plain ones. Meter and Histogram behave like
every other accessor: they return the existing metric or create it, may be called as often as
is convenient, and Dispose removes the metric. RefCountedMeter and RefCountedHistogram
take a reference on every call and Dispose releases one; the metric is torn down when the last
reference goes. Use those for metrics whose owner can be replaced under the same name, so a
replacement that has already resolved the metric does not have it torn down by the outgoing
owner's Dispose. A name is bound to the accessor kind that created it, and resolving it through
the other kind panics. Import as github.com/openziti/metrics/v3.


File: CODE_OF_CONDUCT.md

All open source projects managed by OpenZiti share a common code of conduct which all contributors are expected to follow. Please be sure you read, understand and adhere to the guidelines expressed therein.


File: CONTRIBUTING.md

Contributing

NetFoundry welcomes all and any contributions. All open source projects managed by NetFoundry share a common
guide for contributions.

If you are eager to contribute to a NetFoundry-managed open source project please read and act accordingly.


File: SECURITY.md

Security Policy

Please refer to the openziti-security repository for details of the security policies and processes for this repository.


File: .golangci.yml

version: "2"
linters:
exclusions:
rules:
# ST1006: the codebase deliberately uses "self" as the receiver name per
# openziti house style.
- linters:
- staticcheck
text: "ST1006"


File: .github/dependabot.yml

version: 2
updates:

  • package-ecosystem: gomod
    directory: "/"
    schedule:
    interval: daily
    open-pull-requests-limit: 10
    ignore:
    • dependency-name: github.com/lucas-clemente/quic-go
      versions:
      • "> 0.18.1"

File: .github/workflows/codeql-analysis.yml

For most projects, this workflow file will not need changing; you simply need

to commit it to your repository.

You may wish to alter this file to override the set of languages analyzed,

or to provide custom queries or build logic.

******** NOTE ********

We have attempted to detect the languages in your repository. Please check

the `language` matrix defined below to confirm you have the correct set of

supported CodeQL languages.

name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '40 13 * * 2'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

text
strategy:
  fail-fast: false
  matrix:
    language: [ 'go' ]
    # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
    # Learn more:
    # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
  uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
  uses: github/codeql-action/init@v1
  with:
    languages: ${{ matrix.language }}
    # If you wish to specify custom queries, you can do so here or in a config file.
    # By default, queries listed here will override any specified in a config file.
    # Prefix the list here with "+" to use these queries and those in the config file.
    # queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
  uses: github/codeql-action/autobuild@v1

# โ„น๏ธ Command-line programs to run using the OS shell.
# ๐Ÿ“š https://git.io/JvXDl

# โœ๏ธ If the Autobuild fails above, remove it and uncomment the following three lines
#    and modify them (or add more) to build your code if your project
#    uses a compiled language

#- run: |
#   make bootstrap
#   make release

- name: Perform CodeQL Analysis
  uses: github/codeql-action/analyze@v1

File: .github/workflows/golangci-lint.yml

name: golangci-lint
on:
pull_request:
permissions:
contents: read

Optional: allow read access to pull request. Use with `only-new-issues` option.

pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

text
- name: Install Go
    uses: actions/setup-go@v5
    with:
      go-version-file: ./go.mod

  - name: golangci-lint
    uses: golangci/golangci-lint-action@v7
    with:
      # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
      version: v2.5.0

      # Optional: working directory, useful for monorepos
      # working-directory: somedir

      # Optional: golangci-lint command line arguments.
      # args: --issues-exit-code=0

      # Optional: show only new issues if it's a pull request. The default value is `false`.
      # only-new-issues: true

      # Optional: if set to true then the all caching functionality will be complete disabled,
      #           takes precedence over all other caching options.
      # skip-cache: true

      # Optional: if set to true then the action don't cache or restore ~/go/pkg.
      # skip-pkg-cache: true

      # Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
      # skip-build-cache: true

File: .github/workflows/main.yml

name: build

on:
push:
branches:
- main
- release-*
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v3
with:
persist-credentials: false

text
- name: Install Go
    uses: actions/setup-go@v5
    with:
      go-version-file: ./go.mod

  - name: Install Ziti CI
    uses: openziti/ziti-ci@v1

  - name: Build and Test
    run: go test ./...

  - name: Release
    env:
      gh_ci_key: ${{ secrets.GH_CI_KEY }}
      ziti_ci_gpg_key: ${{ secrets.ZITI_CI_GPG_KEY }}
      ziti_ci_gpg_key_id: ${{ secrets.ZITI_CI_GPG_KEY_ID }}
    if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release-')
    run: |
      $(go env GOPATH)/bin/ziti-ci configure-git
      $(go env GOPATH)/bin/ziti-ci tag -v -f version

File: .github/workflows/mattermost-channel-posts.yml

name: mattermost-ziti-webhook
on:
issues:
issue_comment:
pull_request_review:
types: [ submitted ]
pull_request_review_comment:
pull_request:
types: [ opened, reopened, ready_for_review, closed ]
fork:
push:
tags:
- '*'
release:
types: [ released ]
workflow_dispatch:
watch:
types: [ started ]

jobs:
send-notifications:
runs-on: ubuntu-latest
name: POST Webhook
if: github.actor != 'dependabot[bot]'
steps:
- uses: openziti/ziti-mattermost-action-py@main
if: |
github.repository_owner == 'openziti'
&& ((github.event_name != 'pull_request_review')
|| (github.event_name == 'pull_request_review' && github.event.review.state == 'approved'))
with:
zitiId: ${{ secrets.ZITI_MATTERMOST_IDENTITY }}
webhookUrl: ${{ secrets.ZHOOK_URL }}
eventJson: ${{ toJson(github.event) }}
senderUsername: "GitHubZ"
destChannel: "dev-notifications"

text
- uses: openziti/ziti-mattermost-action-py@main
    if: |
      github.repository_owner == 'openziti'
      && ((github.event_name != 'pull_request_review')
      || (github.event_name == 'pull_request_review' && github.event.review.state == 'approved'))
    with:
      zitiId: ${{ secrets.ZITI_MATTERMOST_IDENTITY }}
      webhookUrl: ${{ secrets.ZHOOK_URL }}
      eventJson: ${{ toJson(github.event) }}
      senderUsername: "GitHubZ"
      destChannel: "github-sig-core"

File: .github/workflows/mattermost-webhook.yml

name: mattermost-ziti-webhook
on:
create:
delete:
issues:
issue_comment:
pull_request_review:
pull_request_review_comment:
pull_request:
push:
fork:
release:

jobs:
mattermost-ziti-webhook:
runs-on: ubuntu-latest
name: POST Webhook
if: github.actor != 'dependabot[bot]'
env:
ZITI_LOG: 99
ZITI_NODEJS_LOG: 99
steps:
- uses: openziti/ziti-webhook-action@main
with:
ziti-id: ${{ secrets.ZITI_MATTERMOST_IDENTITY }}
webhook-url: ${{ secrets.ZITI_MATTERMOST_WEBHOOK_URL }}
webhook-secret: ${{ secrets.ZITI_MATTERMOSTI_WEBHOOK_SECRET }}


File: .github/workflows/update-dependency.yml

name: update-dependency
on:
workflow_dispatch:
inputs:
updated-dependency:
required: true

jobs:
build:
if: github.ref == 'refs/heads/update-dependency'
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

text
- name: Install Go
    uses: actions/setup-go@v3
    with:
      go-version: '1.19.x'

  - name: Install Ziti CI
    uses: openziti/ziti-ci@v1

  - name: Update Dependency
    env:
      gh_ci_key: ${{ secrets.GH_CI_KEY }}
      ziti_ci_gpg_key: ${{ secrets.ZITI_CI_GPG_KEY }}
      ziti_ci_gpg_key_id: ${{ secrets.ZITI_CI_GPG_KEY_ID }}
    run: |
      $(go env GOPATH)/bin/ziti-ci configure-git
      $(go env GOPATH)/bin/ziti-ci update-go-dependency  ${{ github.event.inputs.updated-dependency }}

  - name: Build and Test
    run: go test ./... --tags apitests

  - name: Complete Dependency Update
    run: $(go env GOPATH)/bin/ziti-ci complete-update-go-dependency