Help us shape the future of Go! Take the 2026 Go Developer Survey

usagedata

package
v3.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package usagedata implements MCP tools for GitLab usage data and service ping metrics.

The package wraps GitLab usage data APIs:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatMetricDefinitionsMarkdown

func FormatMetricDefinitionsMarkdown(out MetricDefinitionsOutput) string

FormatMetricDefinitionsMarkdown renders the metric dictionary as a card whose body is the YAML document inside a fence sized to it.

func FormatNonSQLMetricsMarkdown

func FormatNonSQLMetricsMarkdown(out NonSQLMetricsOutput) string

FormatNonSQLMetricsMarkdown renders the non-SQL half of the Service Ping report as the card of one object.

func FormatQueriesMarkdown

func FormatQueriesMarkdown(out QueriesOutput) string

FormatQueriesMarkdown renders the SQL behind the Service Ping counters as a card whose nested collection is the query per metric.

The instance's version, edition and recording time used to share one line with no list marker in front of it and no escaping on any of the three, so a value carrying a pipe, a tag or a line break wrote whatever it liked into the response. Each is a row of its own now.

func FormatServicePingMarkdown

func FormatServicePingMarkdown(out GetServicePingOutput) string

FormatServicePingMarkdown renders the Service Ping payload as a card: when it was recorded, then the license attributes and the metric counts as nested collections.

func FormatTrackEventMarkdown

func FormatTrackEventMarkdown(out TrackEventOutput) string

FormatTrackEventMarkdown renders the answer to one tracked event as a card.

func FormatTrackEventsMarkdown

func FormatTrackEventsMarkdown(out TrackEventsOutput) string

FormatTrackEventsMarkdown renders the answer to a batch of tracked events as a card.

Types

type GetMetricDefinitionsInput

type GetMetricDefinitionsInput struct{}

GetMetricDefinitionsInput is the input (no params).

type GetNonSQLMetricsInput

type GetNonSQLMetricsInput struct{}

GetNonSQLMetricsInput is the input (no params).

type GetQueriesInput

type GetQueriesInput struct{}

GetQueriesInput is the input (no params).

type GetServicePingInput

type GetServicePingInput struct{}

GetServicePingInput is the input (no params).

type GetServicePingOutput

type GetServicePingOutput struct {
	toolutil.HintableOutput
	RecordedAt string            `json:"recorded_at"`
	License    map[string]string `json:"license"`
	Counts     map[string]int64  `json:"counts"`
}

GetServicePingOutput is the output for getting service ping data.

func GetServicePing

GetServicePing retrieves service ping data (admin-only).

type MetricDefinitionsOutput

type MetricDefinitionsOutput struct {
	toolutil.HintableOutput
	YAML string `json:"yaml"`
	// Truncated reports that the document was cut at [maxMetricDefinitionsBytes]
	// and that YAML holds a prefix rather than the whole definition set.
	Truncated bool `json:"truncated"`
}

MetricDefinitionsOutput is the output for metric definitions.

func GetMetricDefinitions

GetMetricDefinitions retrieves metric definitions as YAML (admin-only).

type NonSQLMetricsOutput

type NonSQLMetricsOutput struct {
	toolutil.HintableOutput
	RecordedAt            string            `json:"recorded_at"`
	UUID                  string            `json:"uuid"`
	Hostname              string            `json:"hostname"`
	Version               string            `json:"version"`
	InstallationType      string            `json:"installation_type"`
	ActiveUserCount       int64             `json:"active_user_count"`
	Edition               string            `json:"edition"`
	LicenseMD5            string            `json:"license_md5"`
	LicenseSHA256         string            `json:"license_sha256"`
	LicenseID             string            `json:"license_id"`
	HistoricalMaxUsers    int64             `json:"historical_max_users"`
	Licensee              map[string]string `json:"licensee"`
	LicenseUserCount      int64             `json:"license_user_count"`
	LicenseStartsAt       string            `json:"license_starts_at"`
	LicenseExpiresAt      string            `json:"license_expires_at"`
	LicensePlan           string            `json:"license_plan"`
	LicenseAddOns         map[string]int64  `json:"license_add_ons"`
	LicenseTrial          string            `json:"license_trial"`
	LicenseSubscriptionID string            `json:"license_subscription_id"`
	License               map[string]string `json:"license"`
	Settings              map[string]string `json:"settings"`
}

NonSQLMetricsOutput is the output for non-SQL metrics.

func GetNonSQLMetrics

GetNonSQLMetrics retrieves non-SQL service ping metrics (admin-only).

type QueriesOutput

type QueriesOutput struct {
	toolutil.HintableOutput
	RecordedAt            string            `json:"recorded_at"`
	UUID                  string            `json:"uuid"`
	Hostname              string            `json:"hostname"`
	Version               string            `json:"version"`
	InstallationType      string            `json:"installation_type"`
	ActiveUserCount       string            `json:"active_user_count"`
	Edition               string            `json:"edition"`
	LicenseMD5            string            `json:"license_md5"`
	LicenseSHA256         string            `json:"license_sha256"`
	LicenseID             string            `json:"license_id"`
	HistoricalMaxUsers    int64             `json:"historical_max_users"`
	Licensee              map[string]string `json:"licensee"`
	LicenseUserCount      int64             `json:"license_user_count"`
	LicenseStartsAt       string            `json:"license_starts_at"`
	LicenseExpiresAt      string            `json:"license_expires_at"`
	LicensePlan           string            `json:"license_plan"`
	LicenseAddOns         map[string]int64  `json:"license_add_ons"`
	LicenseTrial          string            `json:"license_trial"`
	LicenseSubscriptionID string            `json:"license_subscription_id"`
	License               map[string]string `json:"license"`
	Settings              map[string]string `json:"settings"`
	Counts                map[string]string `json:"counts"`
}

QueriesOutput is the output for service ping queries.

func GetQueries

func GetQueries(ctx context.Context, client *gitlabclient.Client, _ GetQueriesInput) (QueriesOutput, error)

GetQueries retrieves service ping SQL queries (admin-only).

type TrackEventInput

type TrackEventInput struct {
	Event                string            `json:"event" jsonschema:"Event name to track,required"`
	SendToSnowplow       *bool             `json:"send_to_snowplow,omitempty" jsonschema:"Whether to send event to Snowplow"`
	NamespaceID          *int64            `json:"namespace_id,omitempty" jsonschema:"Namespace ID"`
	ProjectID            *int64            `json:"project_id,omitempty" jsonschema:"Project ID"`
	AdditionalProperties map[string]string `json:"additional_properties,omitempty" jsonschema:"Additional event properties forwarded to the tracking endpoint"`
}

TrackEventInput is the input for tracking a single event.

type TrackEventOutput

type TrackEventOutput struct {
	toolutil.HintableOutput
	Status string `json:"status"`
}

TrackEventOutput is the output for tracking a single event.

func TrackEvent

func TrackEvent(ctx context.Context, client *gitlabclient.Client, input TrackEventInput) (TrackEventOutput, error)

TrackEvent tracks a single usage event.

type TrackEventsInput

type TrackEventsInput struct {
	Events []TrackEventInput `json:"events" jsonschema:"Array of events to track,required"`
}

TrackEventsInput is the input for tracking multiple events.

type TrackEventsOutput

type TrackEventsOutput struct {
	toolutil.HintableOutput
	Status string `json:"status"`
	Count  int    `json:"count"`
}

TrackEventsOutput is the output for tracking multiple events.

func TrackEvents

func TrackEvents(ctx context.Context, client *gitlabclient.Client, input TrackEventsInput) (TrackEventsOutput, error)

TrackEvents tracks multiple usage events in batch.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL