views

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAssetNotFound = errors.New("asset not found")

Functions

func ToDStorageURL added in v0.7.0

func ToDStorageURL(playbackID string) string

Types

type BigQuery added in v0.7.0

type BigQuery interface {
	QueryViewsEvents(ctx context.Context, spec QuerySpec) ([]ViewershipEventRow, error)
	QueryViewsSummary(ctx context.Context, playbackID string) (*ViewSummaryRow, error)
}

func NewBigQuery added in v0.7.0

func NewBigQuery(opts BigQueryOptions) (BigQuery, error)

type BigQueryOptions added in v0.7.0

type BigQueryOptions struct {
	BigQueryCredentialsJSON   string
	ViewershipEventsTable     string
	ViewershipSummaryTable    string
	MaxBytesBilledPerBigQuery int64
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ClientOptions) (*Client, error)

func (*Client) Deprecated_GetTotalViews added in v0.7.0

func (c *Client) Deprecated_GetTotalViews(ctx context.Context, id string) ([]TotalViews, error)

func (*Client) QueryEvents added in v0.7.2

func (c *Client) QueryEvents(ctx context.Context, spec QuerySpec, assetID, streamID string) ([]Metric, error)

func (*Client) QuerySummary added in v0.7.2

func (c *Client) QuerySummary(ctx context.Context, playbackID string) (*Metric, error)

type ClientOptions

type ClientOptions struct {
	Prometheus promClient.Config
	Livepeer   livepeer.ClientOptions

	BigQueryOptions
}

type Metric added in v0.7.0

type Metric struct {
	Timestamp *int64 `json:"timestamp,omitempty"`

	CreatorID   data.Nullable[string] `json:"creatorId,omitempty"`
	ViewerID    data.Nullable[string] `json:"viewerId,omitempty"`
	PlaybackID  data.Nullable[string] `json:"playbackId,omitempty"`
	DStorageURL data.Nullable[string] `json:"dStorageUrl,omitempty"`

	Device     data.Nullable[string] `json:"device,omitempty"`
	DeviceType data.Nullable[string] `json:"deviceType,omitempty"`
	CPU        data.Nullable[string] `json:"cpu,omitempty"`

	OS            data.Nullable[string] `json:"os,omitempty"`
	Browser       data.Nullable[string] `json:"browser,omitempty"`
	BrowserEngine data.Nullable[string] `json:"browserEngine,omitempty"`

	Continent   data.Nullable[string] `json:"continent,omitempty"`
	Country     data.Nullable[string] `json:"country,omitempty"`
	Subdivision data.Nullable[string] `json:"subdivision,omitempty"`
	TimeZone    data.Nullable[string] `json:"timezone,omitempty"`
	GeoHash     data.Nullable[string] `json:"geohash,omitempty"`

	ViewCount        int64                  `json:"viewCount"`
	PlaytimeMins     float64                `json:"playtimeMins"`
	TtffMs           data.Nullable[float64] `json:"ttffMs,omitempty"`
	RebufferRatio    data.Nullable[float64] `json:"rebufferRatio,omitempty"`
	ErrorRate        data.Nullable[float64] `json:"errorRate,omitempty"`
	ExitsBeforeStart data.Nullable[float64] `json:"exitsBeforeStart,omitempty"`
	// Present only on the summary queries. These were imported from the
	// prometheus data we had on the first version of this API and are not
	// shown in the detailed metrics queries (non-/total).
	LegacyViewCount data.Nullable[int64] `json:"legacyViewCount,omitempty"`
}

type Prometheus added in v0.7.0

type Prometheus struct {
	// contains filtered or unexported fields
}

func NewPrometheus added in v0.7.0

func NewPrometheus(config promClient.Config) (*Prometheus, error)

func (*Prometheus) QueryStartViews added in v0.7.0

func (c *Prometheus) QueryStartViews(ctx context.Context, asset *livepeer.Asset) (int64, error)

type QueryFilter added in v0.7.0

type QueryFilter struct {
	PlaybackID string
	CreatorID  string
	UserID     string
}

type QuerySpec added in v0.7.0

type QuerySpec struct {
	From, To    *time.Time
	TimeStep    string
	Filter      QueryFilter
	BreakdownBy []string
	Detailed    bool
}

type TotalViews

type TotalViews struct {
	ID         string `json:"id"`
	StartViews int64  `json:"startViews"`
}

type ViewSummaryRow added in v0.7.0

type ViewSummaryRow struct {
	PlaybackID  bigquery.NullString `bigquery:"playback_id"`
	DStorageURL bigquery.NullString `bigquery:"d_storage_url"`

	ViewCount       int64              `bigquery:"view_count"`
	LegacyViewCount bigquery.NullInt64 `bigquery:"legacy_view_count"`
	PlaytimeMins    float64            `bigquery:"playtime_mins"`
}

type ViewershipEventRow added in v0.7.0

type ViewershipEventRow struct {
	TimeInterval time.Time `bigquery:"time_interval"`

	// breakdown fields
	CreatorID   bigquery.NullString `bigquery:"creator_id"`
	ViewerID    bigquery.NullString `bigquery:"viewer_id"`
	PlaybackID  bigquery.NullString `bigquery:"playback_id"`
	DStorageURL bigquery.NullString `bigquery:"d_storage_url"`

	DeviceType bigquery.NullString `bigquery:"device_type"`
	Device     bigquery.NullString `bigquery:"device"`
	CPU        bigquery.NullString `bigquery:"cpu"`

	OS            bigquery.NullString `bigquery:"os"`
	Browser       bigquery.NullString `bigquery:"browser"`
	BrowserEngine bigquery.NullString `bigquery:"browser_engine"`

	Continent   bigquery.NullString `bigquery:"playback_continent_name"`
	Country     bigquery.NullString `bigquery:"playback_country_name"`
	Subdivision bigquery.NullString `bigquery:"playback_subdivision_name"`
	TimeZone    bigquery.NullString `bigquery:"playback_timezone"`
	GeoHash     bigquery.NullString `bigquery:"playback_geo_hash"`

	ViewCount        int64                `bigquery:"view_count"`
	PlaytimeMins     float64              `bigquery:"playtime_mins"`
	TtffMs           bigquery.NullFloat64 `bigquery:"ttff_ms"`
	RebufferRatio    bigquery.NullFloat64 `bigquery:"rebuffer_ratio"`
	ErrorRate        bigquery.NullFloat64 `bigquery:"error_rate"`
	ExitsBeforeStart bigquery.NullFloat64 `bigquery:"exits_before_start"`
}

Jump to

Keyboard shortcuts

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